package com.cool.store.controller.webb;

import com.cool.store.entity.EnumInfoDO;
import com.cool.store.enums.ZxjpEnum;
import com.cool.store.response.ResponseResult;
import com.cool.store.response.XgjVicePresidentResponse;
import com.cool.store.service.EnumInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: WangShuo
 * @Date: 2025/04/08/15:31
 * @Version 1.0
 * @注释:
 */
@Api("获取枚举数据")
@RestController
@RequestMapping("/pc/enumInfo")
public class PCEnumInfoController {

    @Resource
    private EnumInfoService enumInfoService;

    @GetMapping("/getVicePresident")
    @ApiOperation("获取副总裁名单")
    public ResponseResult<List<XgjVicePresidentResponse>> getVicePresident() {
        List<EnumInfoDO> list = enumInfoService.getByTypeCode(ZxjpEnum.XGJ_VICE_PRESIDENT.getCode());
        List<XgjVicePresidentResponse> responses = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(list)){
            for (EnumInfoDO enumInfoDO : list){
                XgjVicePresidentResponse xgjVicePresidentResponse = new XgjVicePresidentResponse();
                xgjVicePresidentResponse.setAffiliatedOrganization(enumInfoDO.getSysKey());
                xgjVicePresidentResponse.setName(enumInfoDO.getSysValue());
                responses.add(xgjVicePresidentResponse);
            }
        }
        return ResponseResult.success(responses);
    }

    @GetMapping("/getDeclareGoodsDate")
    @ApiOperation("获取报货日期")
    public ResponseResult<List<String>> getDeclareGoodsDate() {
        List<EnumInfoDO> list = enumInfoService.getByTypeCode(ZxjpEnum.DECLARE_GOODS_DATE.getCode());
        List<String> responses = new ArrayList<>();
        if (CollectionUtils.isNotEmpty(list)){
            for (EnumInfoDO enumInfoDO : list){
                responses.add(enumInfoDO.getSysValue());
            }
        }
        return ResponseResult.success(responses);
    }
}
