创建实训草稿
This commit is contained in:
parent
8440643eab
commit
54868de8c2
@ -9,10 +9,13 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import club.joylink.rtss.services.training2.Training2DraftService;
|
import club.joylink.rtss.services.training2.Training2DraftService;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.training2.draft.CreateTraining2ReqVo;
|
import club.joylink.rtss.vo.training2.draft.CreateTraining2ReqVo;
|
||||||
|
import club.joylink.rtss.vo.training2.draft.CreateTraining2RspVo;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*实训草稿管理接口
|
*实训草稿管理接口
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/v2/draft/training")
|
@RequestMapping("/api/v2/draft/training")
|
||||||
public class TrainingDraftV2Controller {
|
public class TrainingDraftV2Controller {
|
||||||
@ -22,7 +25,8 @@ public class TrainingDraftV2Controller {
|
|||||||
* 创建实训草稿
|
* 创建实训草稿
|
||||||
*/
|
*/
|
||||||
@PostMapping("/create")
|
@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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
|
|||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.vo.AccountVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.training2.draft.CreateTraining2ReqVo;
|
import club.joylink.rtss.vo.training2.draft.CreateTraining2ReqVo;
|
||||||
|
import club.joylink.rtss.vo.training2.draft.CreateTraining2RspVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -25,7 +26,7 @@ public class Training2DraftService {
|
|||||||
* @return 返回创建的实训的id
|
* @return 返回创建的实训的id
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createTraining(CreateTraining2ReqVo req,AccountVO user) {
|
public CreateTraining2RspVo createTraining(CreateTraining2ReqVo req,AccountVO user) {
|
||||||
//校验是否已经有同名的实训
|
//校验是否已经有同名的实训
|
||||||
DraftTraining2Example example=new DraftTraining2Example();
|
DraftTraining2Example example=new DraftTraining2Example();
|
||||||
example.createCriteria().andNameEqualTo(req.getName());
|
example.createCriteria().andNameEqualTo(req.getName());
|
||||||
@ -44,6 +45,11 @@ public class Training2DraftService {
|
|||||||
//
|
//
|
||||||
List<DraftTraining2> created= this.trainingDao.selectByExample(example);
|
List<DraftTraining2> created= this.trainingDao.selectByExample(example);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=created&&created.size()==1,"创建实训异常");
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user