| | |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.modules.directive.entity.Directive; |
| | | import org.springblade.modules.directive.entity.DirectiveFile; |
| | | import org.springblade.modules.directive.service.DirectiveService; |
| | | import org.springblade.modules.directive.vo.DirectiveVo; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | |
| | | /** |
| | | * 指令信息新增,同时新增到轨迹表中 |
| | | * 指令信息新增,同时新增图片到指令文件表中 |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/saveDirectiveAndLocus") |
| | | public R saveDirectiveAndLocus(@RequestBody Directive directive) { |
| | | //先查询是否已有指令信息,如果有,则更新,没有则插入 |
| | | DirectiveVo directiveVo = directiveService.selectDirectiveInfo(directive); |
| | | @PostMapping("/saveDirectiveAndFile") |
| | | public R saveDirectiveAndFile(@RequestBody DirectiveVo directive) { |
| | | //新增指令信息 |
| | | boolean save = directiveService.save(directive); |
| | | boolean status = false; |
| | | if (save){ |
| | | //新增图片 |
| | | if (null!=directive.getUrl() && directive.getUrl()!=""){ |
| | | String[] directiveUrl = directive.getUrl().split(","); |
| | | for (String url : directiveUrl) { |
| | | DirectiveFile directiveFile = new DirectiveFile(); |
| | | directiveFile.setType(1); |
| | | directiveFile.setDirectiveId(directive.getId()); |
| | | directiveFile.setUrl(url); |
| | | status = directiveService.saveDirectiveFile(directiveFile); |
| | | if (!status){ |
| | | R.status(false); |
| | | } |
| | | } |
| | | } |
| | | return R.status(status); |
| | | } |
| | | //返回数据 |
| | | return R.status(false); |
| | | return R.status(status); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 指令信息修改,同时新增图片到指令文件表中 |
| | | * @param directive 指令信息对象 |
| | | */ |
| | | @PostMapping("/updateDirectiveAndFile") |
| | | public R updateDirectiveAndFile(@RequestBody DirectiveVo directive) { |
| | | //新增指令信息 |
| | | boolean update = directiveService.updateById(directive); |
| | | boolean status = false; |
| | | if (update){ |
| | | //先删除图片 |
| | | int i = directiveService.deleleByDirectiveId(directive.getId()); |
| | | //新增图片 |
| | | if (null!=directive.getUrl() && directive.getUrl()!=""){ |
| | | String[] directiveUrl = directive.getUrl().split(","); |
| | | for (String url : directiveUrl) { |
| | | DirectiveFile directiveFile = new DirectiveFile(); |
| | | directiveFile.setType(1); |
| | | directiveFile.setDirectiveId(directive.getId()); |
| | | directiveFile.setUrl(url); |
| | | status = directiveService.saveDirectiveFile(directiveFile); |
| | | if (!status){ |
| | | R.status(false); |
| | | } |
| | | } |
| | | } |
| | | return R.status(status); |
| | | } |
| | | //返回数据 |
| | | return R.status(status); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/remove") |
| | | public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { |
| | | //图片也删除 |
| | | if (null!=ids && ids!=""){ |
| | | String[] directiveIds = ids.split(","); |
| | | for (String directiveId : directiveIds) { |
| | | directiveService.deleleByDirectiveId(Long.parseLong(directiveId)); |
| | | } |
| | | } |
| | | return R.status(directiveService.removeByIds(Func.toLongList(ids))); |
| | | } |
| | | |