forked from kidgrow-microservices-platform

luliqiang
2021-02-19 e613dc170308423742325db4a8bd9a3e01659add
kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-server/src/main/java/com/kidgrow/oprationcenter/controller/BusinessRecordsController.java
@@ -11,15 +11,14 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Map;
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
 *
 * @Description: 业务操作记录
 * @Project: 运营中心
 * @CreateDate: Created in 2020-04-02 18:25:34 <br>
@@ -30,7 +29,7 @@
@RestController
@RequestMapping("/businessrecords")
@Api(tags = "业务操作记录")
public class BusinessRecordsController  extends BaseController{
public class BusinessRecordsController extends BaseController {
    @Autowired
    private IBusinessRecordsService businessRecordsService;
@@ -43,12 +42,12 @@
            @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer")
    })
    @GetMapping
    public ResultBody<PageResult> list(@RequestParam Map<String, Object> params) {
        if(params.size()==0){
            params.put("page",1);
            params.put("limit",10);
    public PageResult list(@RequestParam Map<String, Object> params) {
        if (params.size() == 0) {
            params.put("page", 1);
            params.put("limit", 10);
        }
        return ResultBody.ok().data(businessRecordsService.findList(params));
        return businessRecordsService.findList(params);
    }
    /**
@@ -71,24 +70,45 @@
        return ResultBody.ok().data(model).msg("查询成功");
    }
//    /**
//     * 新增or更新
//     */
//    @ApiOperation(value = "保存")
//    @PostMapping
//    public ResultBody save(@Valid @RequestBody BusinessRecords businessRecords, BindingResult bindingResult) {
//        if (bindingResult.hasErrors()) {
//            return ResultBody.failed().msg(bindingResult.getFieldError().getDefaultMessage());
//        } else {
//            BusinessRecords model = businessRecordsService.getById(businessRecords.getId());
//            if (model == null) {
//                boolean v = businessRecordsService.saveOrUpdate(businessRecords);
//                if (v) {
//                    return ResultBody.ok().data(businessRecords).msg("保存成功");
//                } else {
//                    return ResultBody.failed().msg("保存失败");
//                }
//            } else {
//                return ResultBody.failed().msg("业务日志不允许更新!");
//            }
//        }
//    }
    /**
     * 新增or更新
     * 新增
     */
    @ApiOperation(value = "保存")
    @PostMapping
    public ResultBody save(@Valid @RequestBody BusinessRecords businessRecords, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return ResultBody.failed().msg(bindingResult.getFieldError().getDefaultMessage());
    public ResultBody save(String  recordTitle,String recordNote) {
        if (recordTitle.isEmpty()||recordNote.isEmpty()) {
            return ResultBody.failed().msg("业务日志参数有误!");
        } else {
            boolean v= businessRecordsService.saveOrUpdate(businessRecords);
            if(v) {
                return ResultBody.ok().data(businessRecords).msg("保存成功");
            }
            else {
                return ResultBody.failed().msg("保存失败");
                boolean v = businessRecordsService.recordBusinessData(recordTitle,recordNote);
                if (v) {
                    return ResultBody.ok().msg("保存成功");
                } else {
                    return ResultBody.failed().msg("保存失败");
                }
            }
        }
    }
    /**
     * 删除
@@ -96,11 +116,10 @@
    @ApiOperation(value = "删除")
    @DeleteMapping("/{id}")
    public ResultBody delete(@PathVariable Long id) {
        boolean v= businessRecordsService.removeById(id);
        if(v) {
        boolean v = businessRecordsService.removeById(id);
        if (v) {
            return ResultBody.ok().msg("删除成功");
        }
        else {
        } else {
            return ResultBody.failed().msg("删除失败");
        }
    }