package com.shkj.wms.controller.common;

import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.AjaxResult;
import com.shkj.common.core.domain.Result;
import com.shkj.common.utils.MessageUtils;
import com.shkj.common.utils.StringUtils;
import com.shkj.wms.enums.LanguagesEnum;
import com.shkj.wms.service.IBaseDeriveService;
import com.shkj.wms.service.IBaseLogicAreaService;
import com.shkj.wms.utils.FirstLetterUtil;
import lombok.RequiredArgsConstructor;
import org.apache.tomcat.jni.Local;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Locale;

/**
 * 公共方法
 *
 * @author lch
 * @menu 公共方法
 * @date 2022-03-19
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wms/common")
public class WmsCommonController extends BaseController {


    @Autowired
    IBaseDeriveService iBaseDeriveService;

    @Autowired
    IBaseLogicAreaService iBaseLogicAreaService;

    @GetMapping("/changeLanguages")
    public AjaxResult changeLanguages(String lang) {
        if (StringUtils.isBlank(lang) || LanguagesEnum.getLanguagesEnum(lang) == null) {
           return AjaxResult.error();
        }
        return AjaxResult.success();
    }


    /**
     * 根据输入的字符串获取对应的首字母
     */
    @GetMapping("/getFirstLetter/{content}")
    public Result<String> getFirstLetter(@PathVariable String content) {
        return Result.ok().data(FirstLetterUtil.getFirstLetter(content));
    }

    /**
     * 根据输入的字符串获取对应的首字母
     */
    @GetMapping("/test")
    public Result<String> test(String tip) {
        return Result.ok().data(MessageUtils.message(tip));
    }

    /**
     * 根据输入的字符串获取对应的首字母
     */
    @GetMapping("/test2")
    public Result<String> test(String tip, String msg) {
        return Result.err().msg(msg, tip);
    }

//    /**
//     * 查询派生表
//     * @param bo
//     * @return
//     */
//    @GetMapping("/getBaseDeriveList")
//    public Result<BaseDerive> getBaseDeriveList(BaseDerive bo) {
//        return  Result.ok().data(iBaseDeriveService.selectBaseDeriveList(bo));
//    }
//
//    /**
//     * 查看逻辑区域列表
//     * @param bo
//     * @return
//     */
//    @GetMapping("/getBaseLogicAreaList")
//    public Result<BaseLogicArea> queryBaseLogicalAreaList(BaseLogicAreaQueryListBo bo) {
//        bo.setBranchId(SecurityUtils.getCurrentBranchId());
//     return Result.ok().data(iBaseLogicAreaService.queryBaseLogicAreaList(bo));
//
//    }


}
