| | |
| | | import com.zt.common.validator.group.AddGroup; |
| | | import com.zt.common.validator.group.DefaultGroup; |
| | | import com.zt.common.validator.group.UpdateGroup; |
| | | import com.zt.life.modules.mainPart.async.PythonLib; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.ModelLine; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.ModelRbd; |
| | | import com.zt.life.modules.mainPart.taskReliability.service.ModelLineService; |
| | | import com.zt.life.modules.mainPart.taskReliability.service.ModelRbdNodeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | /** |
| | | * model_line |
| | | * |
| | | * @author zt generator |
| | | * @author zt generator |
| | | * @since 1.0.0 2024-02-28 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/taskReliability/ModelLine/") |
| | | @Api(tags="model_line") |
| | | @Api(tags = "model_line") |
| | | public class ModelLineController { |
| | | |
| | | private static final String URL_REPLACE_STR = "URL_PREFIX_URL"; |
| | | private static final String TOKEN_REPLACE_STR = "MY_TOKEN_MY"; |
| | | private static final String TOKEN_REPLACE_REGEX = "token=[0-9a-zA-Z]+&"; |
| | | |
| | | @Autowired |
| | | private ModelLineService modelLineService; |
| | | |
| | | @Autowired |
| | | private ModelRbdNodeService modelRbdNodeService; |
| | | |
| | | |
| | | @GetMapping("page") |
| | | @ApiOperation("分页") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = Constant.Q.PAGE, value = Constant.QV.PAGE, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.LIMIT, value = Constant.QV.LIMIT, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = Constant.Q.PAGE, value = Constant.QV.PAGE, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.LIMIT, value = Constant.QV.LIMIT, required = true, dataType = Constant.QT.INT), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER_FIELD, value = Constant.QV.ORDER_FIELD, dataType = Constant.QT.STRING), |
| | | @ApiImplicitParam(name = Constant.Q.ORDER, value = Constant.QV.ORDER, dataType = Constant.QT.STRING), |
| | | }) |
| | | public PageResult<ModelLine> page(@ApiIgnore @QueryParam QueryFilter queryFilter){ |
| | | public PageResult<ModelLine> page(@ApiIgnore @QueryParam QueryFilter queryFilter) { |
| | | |
| | | return PageResult.ok(modelLineService.page(queryFilter)); |
| | | } |
| | | |
| | | @GetMapping("{id}") |
| | | @ApiOperation("信息") |
| | | public Result<ModelLine> get(@PathVariable("id") Long id){ |
| | | public Result<ModelLine> get(@PathVariable("id") Long id) { |
| | | ModelLine data = modelLineService.get(id); |
| | | |
| | | return Result.ok(data); |
| | |
| | | |
| | | @GetMapping("getDiagram") |
| | | @ApiOperation("信息") |
| | | public Result<ModelRbd> getDiagram(Long modelId){ |
| | | public Result<ModelRbd> getDiagram(Long modelId, String urlPref, String token) { |
| | | ModelRbd data = modelLineService.getDiagram(modelId); |
| | | |
| | | if (data.getContent() != null) { |
| | | data.setContent(data.getContent().replace(URL_REPLACE_STR, urlPref)); |
| | | data.setContent(data.getContent().replace(TOKEN_REPLACE_STR, "token="+token+"&")); |
| | | } |
| | | return Result.ok(data); |
| | | } |
| | | |
| | | @PostMapping |
| | | @ApiOperation("新增") |
| | | @LogOperation("新增") |
| | | public Result insert(@RequestBody ModelRbd modelRbd){ |
| | | public Result insert(@RequestBody ModelRbd modelRbd) { |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(modelRbd, AddGroup.class, DefaultGroup.class); |
| | | modelRbd.setContent(modelRbd.getContent().replace(modelRbd.getUrlPref(), URL_REPLACE_STR)); |
| | | modelRbd.setContent(modelRbd.getContent().replaceAll(TOKEN_REPLACE_REGEX, TOKEN_REPLACE_STR)); |
| | | modelRbdNodeService.saveNodeArr(modelRbd); |
| | | modelLineService.insert(modelRbd); |
| | | |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation("修改") |
| | | @LogOperation("修改") |
| | | public Result update(@RequestBody ModelRbd modelRbd){ |
| | | public Result update(@RequestBody ModelRbd modelRbd) { |
| | | //效验数据 |
| | | ValidatorUtils.validateEntity(modelRbd, UpdateGroup.class, DefaultGroup.class); |
| | | modelRbd.setContent(modelRbd.getContent().replace(modelRbd.getUrlPref(), URL_REPLACE_STR)); |
| | | modelRbd.setContent(modelRbd.getContent().replaceAll(TOKEN_REPLACE_REGEX, TOKEN_REPLACE_STR)); |
| | | modelRbdNodeService.saveNodeArr(modelRbd); |
| | | modelLineService.update(modelRbd); |
| | | |
| | | return Result.ok(); |
| | |
| | | @DeleteMapping |
| | | @ApiOperation("删除") |
| | | @LogOperation("删除") |
| | | public Result delete(@RequestBody Long[] ids){ |
| | | public Result delete(@RequestBody Long[] ids) { |
| | | //效验数据 |
| | | AssertUtils.isArrayEmpty(ids, "id"); |
| | | modelLineService.delete(ids); |
| | |
| | | @PostMapping("analyze") |
| | | @ApiOperation("解析") |
| | | @LogOperation("解析") |
| | | public Result analyze(@RequestBody ModelRbd modelRbd){ |
| | | modelLineService.update(modelRbd); |
| | | public Result analyze(@RequestBody ModelRbd modelRbd) { |
| | | update(modelRbd); |
| | | boolean result = modelLineService.analyze(modelRbd); |
| | | return result ? Result.ok() : Result.error("解析失败"); |
| | | } |
| | | |
| | | @PostMapping("layout") |
| | | @ApiOperation("自动排版") |
| | | @LogOperation("自动排版") |
| | | public Result<ModelRbd> layout(@RequestBody ModelRbd modelRbd) { |
| | | boolean result = modelLineService.layout(modelRbd); |
| | | return result ? Result.ok(modelRbd) : Result.error("自动排版失败"); |
| | | } |
| | | |
| | | } |