| | |
| | | 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; |
| | | |
| | | |
| | |
| | | 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 { |
| | | BusinessRecords model = businessRecordsService.getById(businessRecords.getId()); |
| | | if (model == null) { |
| | | boolean v = businessRecordsService.saveOrUpdate(businessRecords); |
| | | boolean v = businessRecordsService.recordBusinessData(recordTitle,recordNote); |
| | | if (v) { |
| | | return ResultBody.ok().data(businessRecords).msg("保存成功"); |
| | | return ResultBody.ok().msg("保存成功"); |
| | | } else { |
| | | return ResultBody.failed().msg("保存失败"); |
| | | } |
| | | } else { |
| | | return ResultBody.failed().msg("业务日志不允许更新!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除 |