package com.ankaibei.workFlow.webadmin.api;

import cn.hutool.core.util.ObjectUtil;
import com.ankaibei.workFlow.webadmin.ankaibei.entity.ProjectInfoEntity;
import com.ankaibei.workFlow.webadmin.ankaibei.mapper.ProjectInfoMapper;
import com.ankaibei.workFlow.webadmin.ankaibei.service.ProjectInfoService;
import com.ankaibei.workflow.api.ProjectApi;
import com.ankaibei.workflow.response.CodeEnum;
import com.ankaibei.workflow.response.ResMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @author wyy
 * @subject
 * @creat 2023/6/30
 */
@RestController
@RequestMapping("/foreign/admin/upms/project")
public class ProjectApiService implements ProjectApi {
    @Resource
    private ProjectInfoService projectInfoService;

    @Override
    @RequestMapping("/getProjectInfoByProjectName")
    public ResMsg findProjectInfo(String projectName) {
        List<ProjectInfoEntity> list = projectInfoService.getProjectInfoByProjectName(projectName);
        return new ResMsg(CodeEnum.OK, list);
    }

    @Override
    @RequestMapping("/getProjectInfoByCode")
    public ResMsg findProjectInfoByCode(String projectCode) {
        if(ObjectUtil.isNotEmpty(projectCode)){
            ProjectInfoEntity pro = projectInfoService.getProjectInfoByCode(projectCode);
            return new ResMsg(CodeEnum.OK, pro);
        }
        return new ResMsg(CodeEnum.PARAM_IS_NULL);
    }
}
