package com.njcn.csdevice.controller.equipment;


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.mapper.CsSoftInfoMapper;
import com.njcn.csdevice.pojo.po.CsSoftInfoPO;
import com.njcn.csdevice.service.ICsSoftInfoService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
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.*;

/**
 * <p>
 * 系统软件表 前端控制器
 * </p>
 *
 * @author xuyang
 * @since 2023-08-09
 */
@Slf4j
@RestController
@RequestMapping("/csSoftInfo")
@Api(tags = "装置程序信息")
@AllArgsConstructor
@Validated
public class CsSoftInfoController extends BaseController {

    private final CsSoftInfoMapper csSoftInfoMapper;
    private final ICsSoftInfoService csSoftInfoService;

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/findSoftInfo")
    @ApiOperation("获取程序软件信息")
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public HttpResult<CsSoftInfoPO> findSoftInfo(@RequestParam String id){
        String methodDescribe = getMethodDescribe("findSoftInfo");
        CsSoftInfoPO po = csSoftInfoMapper.selectById(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/saveSoftInfo")
    @ApiOperation("保存程序软件信息")
    @ApiImplicitParam(name = "po", value = "po", required = true)
    public HttpResult<String> saveSoftInfo(@RequestBody CsSoftInfoPO po){
        String methodDescribe = getMethodDescribe("saveSoftInfo");
        csSoftInfoService.save(po);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/removeSoftInfo")
    @ApiOperation("删除程序软件信息")
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public HttpResult<String> removeSoftInfo(@RequestParam String id){
        String methodDescribe = getMethodDescribe("removeSoftInfo");
        csSoftInfoService.removeById(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }
}

