关联教材指派范围

This commit is contained in:
王昊 2025-11-24 01:36:58 +08:00
parent 992d947759
commit 5ce697523a
2 changed files with 11 additions and 9 deletions

View File

@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import xyz.playedu.common.annotation.Log; import xyz.playedu.common.annotation.Log;
import xyz.playedu.common.constant.BusinessTypeConstant; import xyz.playedu.common.constant.BusinessTypeConstant;
@ -60,12 +62,12 @@ public class TextbookController {
return JsonResponse.data(one); return JsonResponse.data(one);
} }
// @Transactional
@PostMapping @PostMapping
public JsonResponse create(@RequestBody TextbookRequestDTO textbookReq) { public JsonResponse create(@RequestBody @Validated TextbookRequestDTO textbookReq) {
// textbookService.save(textbook); // textbookService.save(textbook);
Textbook textbook = new Textbook(); Textbook textbook = new Textbook();
BeanUtils.copyProperties(textbook, textbookReq); BeanUtils.copyProperties(textbookReq, textbook);
textbookService.save(textbook); textbookService.save(textbook);
Integer textbookId = textbook.getId(); Integer textbookId = textbook.getId();

View File

@ -82,11 +82,11 @@ public class TextbookRequestDTO {
@JsonProperty("group_ids") @JsonProperty("group_ids")
private Integer[] groupIds; private Integer[] groupIds;
@NotNull(message = "category_ids参数为空") // @NotNull(message = "category_ids参数为空")
@JsonProperty("category_ids") // @JsonProperty("category_ids")
private Integer[] categoryIds; // private Integer[] categoryIds;
//
@JsonProperty("teacher_ids") // @JsonProperty("teacher_ids")
private Integer[] teacherIds; // private Integer[] teacherIds;
} }