From 54868de8c28ac382eaeeeda096423e6d31acf308 Mon Sep 17 00:00:00 2001 From: xiazengbin Date: Tue, 16 Aug 2022 16:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=AE=9E=E8=AE=AD=E8=8D=89?= =?UTF-8?q?=E7=A8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../training2/TrainingDraftV2Controller.java | 8 ++++-- .../training2/Training2DraftService.java | 10 +++++-- .../training2/draft/CreateTraining2RspVo.java | 27 +++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/vo/training2/draft/CreateTraining2RspVo.java diff --git a/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java b/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java index d998a368f..f624dfe16 100644 --- a/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java +++ b/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java @@ -9,10 +9,13 @@ import org.springframework.web.bind.annotation.RestController; import club.joylink.rtss.services.training2.Training2DraftService; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.training2.draft.CreateTraining2ReqVo; +import club.joylink.rtss.vo.training2.draft.CreateTraining2RspVo; +import lombok.extern.slf4j.Slf4j; /** *实训草稿管理接口 */ +@Slf4j @RestController @RequestMapping("/api/v2/draft/training") public class TrainingDraftV2Controller { @@ -22,7 +25,8 @@ public class TrainingDraftV2Controller { * 创建实训草稿 */ @PostMapping("/create") - public void create(@RequestBody CreateTraining2ReqVo req,@RequestAttribute AccountVO user) { - + public CreateTraining2RspVo create(@RequestBody CreateTraining2ReqVo req,@RequestAttribute AccountVO user) { + log.debug("==>>创建实训草稿: mapId = {} , name = {} type = {} des = {}",req.getMapId(),req.getName(),req.getType(),req.getDescription()); + return this.training2DraftService.createTraining(req, user); } } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java index 5542d76ee..f1501c25d 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java @@ -12,6 +12,7 @@ import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.training2.draft.CreateTraining2ReqVo; +import club.joylink.rtss.vo.training2.draft.CreateTraining2RspVo; import lombok.extern.slf4j.Slf4j; @Service @@ -25,7 +26,7 @@ public class Training2DraftService { * @return 返回创建的实训的id */ @Transactional(rollbackFor = Exception.class) - public Long createTraining(CreateTraining2ReqVo req,AccountVO user) { + public CreateTraining2RspVo createTraining(CreateTraining2ReqVo req,AccountVO user) { //校验是否已经有同名的实训 DraftTraining2Example example=new DraftTraining2Example(); example.createCriteria().andNameEqualTo(req.getName()); @@ -44,6 +45,11 @@ public class Training2DraftService { // List created= this.trainingDao.selectByExample(example); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=created&&created.size()==1,"创建实训异常"); - return created.get(0).getId(); + // + DraftTraining2 tn=created.get(0); + CreateTraining2RspVo rsp=new CreateTraining2RspVo(); + rsp.setId(tn.getId()); + rsp.setName(tn.getName()); + return rsp; } } diff --git a/src/main/java/club/joylink/rtss/vo/training2/draft/CreateTraining2RspVo.java b/src/main/java/club/joylink/rtss/vo/training2/draft/CreateTraining2RspVo.java new file mode 100644 index 000000000..146f69707 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/training2/draft/CreateTraining2RspVo.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.vo.training2.draft; + +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class CreateTraining2RspVo { + /** + * 实训的id + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + /** + * 名称 + */ + @NotBlank(message = "名称不能为空") + private String name; + +}