xiejun
2023-12-06 e9a590e862148092027510b15d33cdd32691a6f5
Source/UBCS/ubcs-service/ubcs-code/src/main/java/com/vci/ubcs/code/controller/CodePhaseAttrController.java
@@ -1,115 +1,129 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package com.vci.ubcs.code.controller;
import com.vci.ubcs.code.service.CodePhaseAttrServiceI;
import com.vci.starter.web.pagemodel.BaseQueryObject;
import com.vci.starter.web.pagemodel.BaseResult;
import com.vci.starter.web.pagemodel.DataGrid;
import com.vci.starter.web.util.VciBaseUtil;
import com.vci.ubcs.code.dto.CodePhaseAttrDTO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.vci.ubcs.code.entity.CodePhaseAttr;
import com.vci.ubcs.code.mapper.CodePhaseAttrMapper;
import com.vci.ubcs.code.service.ICodePhaseAttrService;
import com.vci.ubcs.code.vo.pagemodel.CodePhaseAttrVO;
import org.springframework.beans.factory.annotation.Autowired;
import com.vci.ubcs.code.wrapper.CodePhaseAttrWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.Collection;
import javax.validation.Valid;
/**
 * 阶段的属性控制器
 * 编码库定义-模板阶段-属性 控制器
 *
 * @author weidy
 * @date 2022-01-24
 * @author yuxc
 * @since 2023-04-20
 */
@RestController
@AllArgsConstructor
@RequestMapping("/codePhaseAttrController")
public class CodePhaseAttrController {
    /**
    * 阶段的属性 服务
    */
    @Autowired
    private CodePhaseAttrServiceI codePhaseAttrService;
@Api(value = "编码库定义-模板阶段-属性", tags = "编码库定义-模板阶段-属性接口")
public class CodePhaseAttrController extends BladeController {
    /**
     * 阶段的属性列表
     * @param baseQueryObject 基础查询对象,包含查询条件,分页,排序等
     * @return 阶段的属性显示对象列表
     */
    @GetMapping("/gridCodePhaseAttr")
    public DataGrid<CodePhaseAttrVO> gridCodePhaseAttr(BaseQueryObject baseQueryObject){
        if(baseQueryObject == null){
            baseQueryObject = new BaseQueryObject();
        }
        return codePhaseAttrService.gridCodePhaseAttr(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper());
    }
    /**
     * 增加 阶段的属性
     * @param codePhaseAttrDTO 阶段的属性数据传输对象
     * @return 执行结果,success为true表示成功,msg是失败的提示信息,obj是添加完成后的显示对象
     */
    @PostMapping( "/addSave")
    public BaseResult<CodePhaseAttrVO> addSave(@RequestBody CodePhaseAttrDTO codePhaseAttrDTO){
         CodePhaseAttrVO codePhaseAttrVO = codePhaseAttrService.addSave(codePhaseAttrDTO);
         return BaseResult.success(codePhaseAttrVO);
    }
   private final ICodePhaseAttrService CodePhaseattrService;
    /**
     * 修改 阶段的属性
     * @param codePhaseAttrDTO 阶段的属性数据传输对象
     * @return 执行结果,success为true表示成功,msg是失败的提示信息,obj是添加完成后的显示对象
     */
    @PutMapping("/editSave")
    public BaseResult<CodePhaseAttrVO> editSave(@RequestBody CodePhaseAttrDTO codePhaseAttrDTO){
        CodePhaseAttrVO codePhaseAttrVO = codePhaseAttrService.editSave(codePhaseAttrDTO);
        return BaseResult.success(codePhaseAttrVO);
    }
   private CodePhaseAttrMapper codePhaseAttrMapper;
   /**
    * 编码库定义-模板阶段-属性 详情
    */
   @GetMapping("/detail")
   @ApiOperationSupport(order = 1)
   @ApiOperation(value = "详情", notes = "传入CodePhaseattr")
   public R<CodePhaseAttrVO> detail(CodePhaseAttr codePhaseattr) {
      CodePhaseAttr detail = CodePhaseattrService.getOne(Condition.getQueryWrapper(codePhaseattr));
      return R.data(CodePhaseAttrWrapper.build().entityVO(detail));
   }
   /**
    * 编码库定义-模板阶段-属性 分页
    */
   @GetMapping("/list")
   @ApiOperationSupport(order = 2)
   @ApiOperation(value = "分页", notes = "传入CodePhaseattr")
   public R<IPage<CodePhaseAttrVO>> list(CodePhaseAttr codePhaseattr, Query query) {
      IPage<CodePhaseAttr> pages = CodePhaseattrService.page(Condition.getPage(query), Condition.getQueryWrapper(codePhaseattr));
      return R.data(CodePhaseAttrWrapper.build().pageVO(pages));
   }
    /**
     * 删除阶段的属性
     * @param codePhaseAttrDTO 阶段的属性数据传输对象,oid和ts需要传输
     * @return 删除结果反馈::success:成功,fail:失败
     */
    @DeleteMapping( "/deleteData")
    public BaseResult delCodePhaseAttr( CodePhaseAttrDTO codePhaseAttrDTO) {
        return codePhaseAttrService.deleteCodePhaseAttr(codePhaseAttrDTO);
    }
   /**
    * 编码库定义-模板阶段-属性 自定义分页
    */
   @GetMapping("/page")
   @ApiOperationSupport(order = 3)
   @ApiOperation(value = "分页", notes = "传入CodePhaseattr")
   public R<IPage<CodePhaseAttrVO>> page(CodePhaseAttrVO CodePhaseattr, Query query) {
      IPage<CodePhaseAttrVO> pages = CodePhaseattrService.selectCodePhaseattrPage(Condition.getPage(query), CodePhaseattr);
      return R.data(pages);
   }
    /**
    * 主键获取阶段的属性
    * @param oid 主键
    * @return 阶段的属性显示对象
    */
    @GetMapping("/getObjectByOid")
    public BaseResult<CodePhaseAttrVO> getObjectByOid(String oid){
        CodePhaseAttrVO codePhaseAttrVO = codePhaseAttrService.getObjectByOid(oid);
        return BaseResult.success(codePhaseAttrVO);
    }
   /**
    * 编码库定义-模板阶段-属性 新增
    */
   @PostMapping("/save")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入CodePhaseattr")
   public R save(@Valid @RequestBody CodePhaseAttr codePhaseattr) {
      return R.status(CodePhaseattrService.save(codePhaseattr));
   }
    /**
     * 主键批量获取阶段的属性
     * @param oids 主键,多个以逗号分隔,但是受性能影响,建议一次查询不超过10000个
     * @return 阶段的属性显示对象
     */
    @GetMapping("/listDataByOids")
    public BaseResult<CodePhaseAttrVO> listCodePhaseAttrByOids(String oids){
        Collection<CodePhaseAttrVO> voCollection =  codePhaseAttrService.listCodePhaseAttrByOids(VciBaseUtil.str2List(oids));
        BaseResult baseResult = BaseResult.success();
        baseResult.setData(voCollection);
        return  baseResult;
    }
   /**
    * 编码库定义-模板阶段-属性 修改
    */
   @PostMapping("/update")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "修改", notes = "传入CodePhaseattr")
   public R update(@Valid @RequestBody CodePhaseAttr codePhaseattr) {
      return R.status(CodePhaseattrService.updateById(codePhaseattr));
   }
   /**
    * 编码库定义-模板阶段-属性 新增或修改
    */
   @PostMapping("/submit")
   @ApiOperationSupport(order = 6)
   @ApiOperation(value = "新增或修改", notes = "传入CodePhaseattr")
   public R submit(@Valid @RequestBody CodePhaseAttr codePhaseattr) {
      return R.status(CodePhaseattrService.saveOrUpdate(codePhaseattr));
   }
   /**
    * 编码库定义-模板阶段-属性 删除
    */
   @PostMapping("/remove")
   @ApiOperationSupport(order = 7)
   @ApiOperation(value = "逻辑删除", notes = "传入ids")
   public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
      return R.status(SqlHelper.retBool(codePhaseAttrMapper.deleteBatchIds(Func.toLongList(ids))));
   }
    /**
     * 参照阶段的属性列表
     * @param baseQueryObject 基础查询对象,包含查询条件,分页,排序等
     * @return 阶段的属性显示对象列表,生效的内容
     */
    @GetMapping("/refDataGrid")
    public DataGrid<CodePhaseAttrVO> refDataGridCodePhaseAttr(BaseQueryObject baseQueryObject){
        if(baseQueryObject == null){
            baseQueryObject = new BaseQueryObject();
        }
        return codePhaseAttrService.refDataGridCodePhaseAttr(baseQueryObject.getConditionMap(),baseQueryObject.getPageHelper());
    }
}