|
@@ -1,15 +1,28 @@
|
|
|
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 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.Func;
|
|
|
+import org.springblade.manager.dto.FormulaBean;
|
|
|
import org.springblade.manager.entity.Formula;
|
|
|
-import org.springblade.manager.service.impl.FormulaService;
|
|
|
+import org.springblade.manager.service.impl.FormulaServiceImpl;
|
|
|
+import org.springblade.manager.wrapper.FormulaWrapper;
|
|
|
+import org.springblade.system.user.entity.User;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import springfox.documentation.annotations.ApiIgnore;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @author yangyj
|
|
@@ -21,14 +34,14 @@ import org.springframework.web.bind.annotation.*;
|
|
|
@RequestMapping("/formula")
|
|
|
@Api(value = "公式脚本", tags = "公式脚本")
|
|
|
public class FormulaController {
|
|
|
- private final FormulaService service;
|
|
|
+ private final FormulaServiceImpl service;
|
|
|
/**
|
|
|
* 新增或修改
|
|
|
*/
|
|
|
@PostMapping("/save")
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入")
|
|
|
- public R save(Formula f) {
|
|
|
+ public R save(@RequestBody Formula f) {
|
|
|
return R.status(service.save(f));
|
|
|
}
|
|
|
|
|
@@ -38,8 +51,15 @@ public class FormulaController {
|
|
|
@PostMapping("/update")
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "修改", notes = "传入脚本")
|
|
|
- public R update( Formula f) {
|
|
|
- return R.status(service.updateById(f));
|
|
|
+ public R update( @RequestBody FormulaBean f) {
|
|
|
+ if(f.getId()!=null){
|
|
|
+ Formula old = this.service.getById(f.getId());
|
|
|
+ if(old!=null){
|
|
|
+ BeanUtils.copyProperties(f,old);
|
|
|
+ return R.status(service.updateById(old));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.status(false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -57,10 +77,33 @@ public class FormulaController {
|
|
|
@ApiOperationSupport(order =7)
|
|
|
@ApiOperation(value = "查看详情", notes = "传入id")
|
|
|
@GetMapping("/detail")
|
|
|
- public R<Formula> detail(Formula f) {
|
|
|
+ public R<FormulaBean> detail(Formula f) {
|
|
|
Formula detail = service.getOne(Condition.getQueryWrapper(f));
|
|
|
- return R.data(detail);
|
|
|
+ if(detail!=null){
|
|
|
+ return R.data(BeanUtil.copy(detail,FormulaBean.class));
|
|
|
+ }
|
|
|
+ return R.fail("无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "公式翻页查询", notes = "公式翻页查询")
|
|
|
+ @GetMapping("/page")
|
|
|
+ public IPage<FormulaBean> userSearch(@ApiIgnore FormulaBean param, @ApiIgnore Query query) {
|
|
|
+ LambdaQueryWrapper<Formula> queryWrapper = Wrappers.<Formula>query().lambda();
|
|
|
+ if(Func.isNotEmpty(param.getWbsId())){
|
|
|
+ queryWrapper.eq(Formula::getWbsId,param.getWbsId());
|
|
|
+ }
|
|
|
+ if(Func.isNotEmpty(param.getFormula())){
|
|
|
+ queryWrapper.like(Formula::getFormula,param.getFormula());
|
|
|
+ }
|
|
|
+ if(Func.isNotEmpty(param.getRemark())){
|
|
|
+ queryWrapper.like(Formula::getRemark,param.getRemark());
|
|
|
+ }
|
|
|
+ IPage<Formula> pages = this.service.page(Condition.getPage(query),queryWrapper);
|
|
|
+ return FormulaWrapper.build().pageVO(pages);
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
}
|