package com.sy.coinage.app.controller;

import com.sy.coinage.core.annotation.CurrentUser;
import com.sy.coinage.core.vo.CacheUserVO;
import com.sy.coinage.core.vo.OptVO;
import com.sy.coinage.sys.service.IDictService;
import com.sy.coinage.sys.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Api(tags = "App-初始化字典信息接口")
@RestController
@RequestMapping(value = "/app")
public class ConfInitController {
    @Autowired
    private IDictService dictService;

    @Autowired
    private IUserService userService;


    @ApiOperation(value = "App-获取初始字典")
    @GetMapping(value = "/init")
    public Object init(@CurrentUser CacheUserVO user) {
        Map<String, Object> data = new HashMap<>();
        // 总库
        List<OptVO> wareOpt = this.dictService.opt("wareOpt", -1);
        data.put("wareOpt", wareOpt);
        // 来源部门
        List<OptVO> resDeptOpt = this.dictService.opt("workShopOpt", -1);
        data.put("resDeptOpt", resDeptOpt);
        // 来源部门
        List<OptVO> locationOpt = this.dictService.opt("locationOpt", -1);
        data.put("locationOpt", locationOpt);
        // 来源部门
        List<OptVO> shopWareOpt = this.dictService.opt("shopWareOpt", -1);
        data.put("shopWareOpt", shopWareOpt);
        return data;
    }

}
