package com.njcn.csdevice.controller.project;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
import com.njcn.csdevice.pojo.param.AppProjectAuditParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAddParm;
import com.njcn.csdevice.pojo.param.CsEngineeringAuditParm;
import com.njcn.csdevice.pojo.vo.EngineeringProjectRelationVo;
import com.njcn.csdevice.service.IEngineeringProjectService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author xy
 * @date 2026/1/29
 */
@Slf4j
@RestController
@RequestMapping("/engineeringProjectRelation")
@Api(tags = " 工程信息管理(不分权限)")
@AllArgsConstructor
public class EngineeringProjectController extends BaseController {

    private final IEngineeringProjectService csEngineeringService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addEngineering")
    @ApiOperation("新增工程信息")
    public HttpResult<Boolean> addEngineering(@Validated @RequestBody CsEngineeringAddParm csEngineeringAddParm){
        String methodDescribe = getMethodDescribe("addEngineering");
        boolean result = csEngineeringService.addEngineering(csEngineeringAddParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateEngineering")
    @ApiOperation("修改工程信息")
    public HttpResult<Boolean> updateEngineering(@Validated @RequestBody CsEngineeringAuditParm csEngineeringAuditParm){
        String methodDescribe = getMethodDescribe("updateEngineering");
        boolean result = csEngineeringService.updateEngineering(csEngineeringAuditParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/deleteEngineering")
    @ApiOperation("删除工程信息")
    public HttpResult<Boolean> deleteEngineering(@RequestParam("id") String id){
        String methodDescribe = getMethodDescribe("deleteEngineering");
        boolean result = csEngineeringService.deleteEngineering(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addProject")
    @ApiOperation("新增项目信息")
    public HttpResult<Boolean> addProject(@Validated @RequestBody AppProjectAddParm param){
        String methodDescribe = getMethodDescribe("addProject");
        boolean result = csEngineeringService.addProject(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/updateProject")
    @ApiOperation("修改项目信息")
    public HttpResult<Boolean> updateProject(@Validated @RequestBody AppProjectAuditParm param){
        String methodDescribe = getMethodDescribe("updateProject");
        boolean result = csEngineeringService.updateProject(param);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/deleteProject")
    @ApiOperation("删除项目信息")
    public HttpResult<Boolean> deleteProject(@RequestParam("id") String id){
        String methodDescribe = getMethodDescribe("deleteProject");
        boolean result = csEngineeringService.deleteProject(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/list")
    @ApiOperation("查询工程信息列表")
    public HttpResult<List<EngineeringProjectRelationVo>> getList(){
        String methodDescribe = getMethodDescribe("getList");
        List<EngineeringProjectRelationVo> result = csEngineeringService.getList();
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }

}
