package com.bonus.material.clz.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.clz.domain.IwsProjectBean;
import com.bonus.material.clz.domain.vo.IwsProjectVo;
import com.bonus.material.clz.service.IwsProjectService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Objects;

/**
 * @author : 阮世耀
 * @version : 1.0
 * @PackagePath: com.bonus.material.app.controller
 * @CreateTime: 2025-06-11  16:39
 * @Description: i皖送分公司工程信息控制器
 */
@RestController
@RequestMapping("/app/iwsProject")
@Tag(name = "i皖送分公司工程信息控制器")
@Validated
public class IwsProjectController extends BaseController {

    @Resource
    private IwsProjectService iwsProjectService;

    @GetMapping("/selectIwsProjectVoByProjectId")
    @Operation(summary = "根据工程ID获取工程信息", description = "根据工程id查询工程信息")
    public AjaxResult selectIwsProjectVoByProjectId(@RequestParam(value = "projectId") @NotBlank(message = "工程ID不能为空") String projectId){
        IwsProjectBean iwsProjectBean = iwsProjectService.selectIwsProjectVoByProjectId(projectId);
        return Objects.nonNull(iwsProjectBean) ? success(iwsProjectBean) : warn("未查询到信息");
    }

    @GetMapping("/selectIwsAuditConfigPersonByOrgCode")
    @Operation(summary = "根据分公司编码查询审核人员配置", description = "根据分公司编码查询审核人员配置")
    public AjaxResult selectIwsAuditConfigPersonByOrgCode(@RequestParam(value = "orgCode") @NotBlank(message = "分公司编码不能为空") String orgCode){
        List<IwsProjectVo> configList = iwsProjectService.selectIwsAuditConfigPersonByOrgCode(orgCode);
        return !CollectionUtils.isEmpty(configList) ? success(configList) : warn("配置信息为空");
    }
}
