|
@@ -7,11 +7,16 @@ import cn.rankin.common.utils.api.page.Page;
|
|
|
import cn.rankin.common.utils.dto.product.WareDTO;
|
|
|
import cn.rankin.productservice.entity.Ware;
|
|
|
import cn.rankin.common.utils.enums.WareTypeEnum;
|
|
|
+import cn.rankin.productservice.service.LessonService;
|
|
|
+import cn.rankin.productservice.service.LessonWareRelationService;
|
|
|
import cn.rankin.productservice.service.WareService;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping(value = "ware")
|
|
|
public class WareController {
|
|
@@ -19,16 +24,16 @@ public class WareController {
|
|
|
@Autowired
|
|
|
private WareService wareService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LessonWareRelationService relationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LessonService lessonService;
|
|
|
+
|
|
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
|
|
public APIResult<Page<Ware>> getWareList(SearchDTO searchDTO) {
|
|
|
Ware ware = new Ware();
|
|
|
|
|
|
- WareTypeEnum type = searchDTO.getType();
|
|
|
- if (type == null) {
|
|
|
- return APIResult.error(APICodeManager.PARAMETER_ERROR);
|
|
|
- }
|
|
|
- ware.setType(type);
|
|
|
-
|
|
|
String code = searchDTO.getCode();
|
|
|
if (!StringUtils.isEmpty(code)) {
|
|
|
ware.setCode("%" + code + "%");
|
|
@@ -39,12 +44,14 @@ public class WareController {
|
|
|
ware.setName("%" + name + "%");
|
|
|
}
|
|
|
|
|
|
+ ware.setType(searchDTO.getType());
|
|
|
+
|
|
|
return wareService.search(ware, searchDTO.getPageNo(), searchDTO.getPageSize());
|
|
|
}
|
|
|
|
|
|
// 创建资源
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
- public APIResult<Ware> create(@RequestBody WareDTO wareDTO) {
|
|
|
+ public APIResult<Ware> create(@Valid @RequestBody WareDTO wareDTO) {
|
|
|
String code = wareDTO.getCode();
|
|
|
WareTypeEnum type = wareDTO.getType();
|
|
|
if (StringUtils.isEmpty(code) || type == null) {
|
|
@@ -56,7 +63,7 @@ public class WareController {
|
|
|
|
|
|
// 修改资源
|
|
|
@RequestMapping(method = RequestMethod.PUT)
|
|
|
- public APIResult<Ware> update(@RequestBody WareDTO wareDTO) {
|
|
|
+ public APIResult<Ware> update(@Valid @RequestBody WareDTO wareDTO) {
|
|
|
if (wareDTO.getId() == null) {
|
|
|
return APIResult.error(APICodeManager.PARAMETER_ERROR);
|
|
|
}
|
|
@@ -66,7 +73,7 @@ public class WareController {
|
|
|
|
|
|
// 删除资源
|
|
|
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
|
|
- public APIResult<Boolean> delete(@PathVariable("id") String id) {
|
|
|
+ public APIResult<Boolean> delete(@NotNull @PathVariable("id") String id) {
|
|
|
return wareService.delete(id);
|
|
|
}
|
|
|
|