|
@@ -0,0 +1,128 @@
|
|
|
+package org.springblade.manager.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+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.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.dto.FormulaBean;
|
|
|
+import org.springblade.manager.dto.WbsParamBean;
|
|
|
+import org.springblade.manager.entity.Formula;
|
|
|
+import org.springblade.manager.entity.WbsParam;
|
|
|
+import org.springblade.manager.service.IWbsParamService;
|
|
|
+import org.springblade.manager.wrapper.FormulaWrapper;
|
|
|
+import org.springblade.manager.wrapper.WbsParamWrapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author yangyj
|
|
|
+ * @Date 2022/6/17 17:06
|
|
|
+ * @description TODO
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/param")
|
|
|
+@Api(value = "节点参数", tags = "节点参数")
|
|
|
+public class WbsParamController {
|
|
|
+ private final IWbsParamService service;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存或修改
|
|
|
+ * @param wp
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("/saveOrUpdate")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "保存或修改参数", notes = "保存或修改参数")
|
|
|
+ public R saveOrUpdate(@RequestBody WbsParamBean wp) {
|
|
|
+ if(wp.getId()==null){
|
|
|
+ WbsParam e= new WbsParam();
|
|
|
+ BeanUtils.copyProperties(wp,e);
|
|
|
+ return R.status(this.service.save(e));
|
|
|
+ }else{
|
|
|
+ WbsParam old = this.service.getById(wp.getId());
|
|
|
+ if(old!=null){
|
|
|
+ BeanUtils.copyProperties(wp,old);
|
|
|
+ return R.status(service.updateById(old));
|
|
|
+ }
|
|
|
+ return R.status(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "删除", notes = "传入id集合")
|
|
|
+ public R remove(@ApiParam(value="需要删除的Id,多个用逗号逗号分开",required = true)@RequestParam String ids) {
|
|
|
+ return R.status(this.service.deleteLogic(Func.toLongList(ids)));
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查询单条
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order =3)
|
|
|
+ @ApiOperation(value = "查看详情", notes = "传入id")
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiIgnore
|
|
|
+ public R<WbsParamBean> detail(WbsParam wp) {
|
|
|
+ WbsParam detail = service.getOne(Condition.getQueryWrapper(wp));
|
|
|
+ if(detail!=null){
|
|
|
+ return R.data(BeanUtil.copy(detail,WbsParamBean.class));
|
|
|
+ }
|
|
|
+ return R.success("无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "节点参数列表(翻页)", notes = "节点参数列表(翻页)")
|
|
|
+ @GetMapping("/page")
|
|
|
+ public IPage<WbsParamBean> list( WbsParamBean param, Query query) {
|
|
|
+ LambdaQueryWrapper<WbsParam> queryWrapper = Wrappers.<WbsParam>query().lambda();
|
|
|
+ IPage<WbsParam> pages = this.service.page(Condition.getPage(query),queryWrapper);
|
|
|
+ return WbsParamWrapper.build().pageVO(pages);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "获取名称字典", notes = "获取名称字典")
|
|
|
+ @GetMapping("/keymap")
|
|
|
+ public R<List<WbsParamBean>> list2() {
|
|
|
+ LambdaQueryWrapper<WbsParam> queryWrapper = Wrappers.<WbsParam>query().lambda().eq(WbsParam::getType,0);
|
|
|
+ List<WbsParamBean> list = new ArrayList<>();
|
|
|
+ List<WbsParam> data = this.service.list(queryWrapper);
|
|
|
+ if(CollectionUtil.isNotEmpty(data)){
|
|
|
+ list = WbsParamWrapper.build().listVO(this.service.list(queryWrapper));
|
|
|
+ }
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @ApiOperation(value = "节点参数列表", notes = "节点参数列表")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public R<List<WbsParamBean>> list3(@ApiParam(value = "wbs节点id", required = true) Long wbsId) {
|
|
|
+ LambdaQueryWrapper<WbsParam> queryWrapper = Wrappers.<WbsParam>query().lambda().eq(WbsParam::getWbsId,wbsId).eq(WbsParam::getType,1);
|
|
|
+ List<WbsParamBean> list = new ArrayList<>();
|
|
|
+ List<WbsParam> data = this.service.list(queryWrapper);
|
|
|
+ if(CollectionUtil.isNotEmpty(data)){
|
|
|
+ list = WbsParamWrapper.build().listVO(this.service.list(queryWrapper));
|
|
|
+ }
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|