|
@@ -1,9 +1,8 @@
|
|
|
package cn.iaun.it.controller;
|
|
package cn.iaun.it.controller;
|
|
|
|
|
|
|
|
-import cn.iaun.it.model.ItResourceAttribute;
|
|
|
|
|
-import cn.iaun.it.model.ItResourceGroup;
|
|
|
|
|
-import cn.iaun.it.model.ItResourceType;
|
|
|
|
|
|
|
+import cn.iaun.it.model.*;
|
|
|
import cn.iaun.it.service.ItResourceService;
|
|
import cn.iaun.it.service.ItResourceService;
|
|
|
|
|
+import cn.iaun.it.util.MyPage;
|
|
|
import cn.iaun.it.util.Result;
|
|
import cn.iaun.it.util.Result;
|
|
|
import cn.iaun.it.util.ResultCode;
|
|
import cn.iaun.it.util.ResultCode;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -22,7 +21,7 @@ public class ItResourceController {
|
|
|
this.itResourceService = itResourceService;
|
|
this.itResourceService = itResourceService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @GetMapping(value = "/type/get")
|
|
|
|
|
|
|
+ @PostMapping(value = "/type/get")
|
|
|
public Result<List<ItResourceType>> getItResourceTypes() {
|
|
public Result<List<ItResourceType>> getItResourceTypes() {
|
|
|
return new Result<>(ResultCode.SUCCESS, itResourceService.getResourceType());
|
|
return new Result<>(ResultCode.SUCCESS, itResourceService.getResourceType());
|
|
|
}
|
|
}
|
|
@@ -73,7 +72,7 @@ public class ItResourceController {
|
|
|
return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @GetMapping(value = "/group/get")
|
|
|
|
|
|
|
+ @PostMapping(value = "/group/get")
|
|
|
public Result<List<ItResourceGroup>> getItResourceGroups() {
|
|
public Result<List<ItResourceGroup>> getItResourceGroups() {
|
|
|
return new Result<>(ResultCode.SUCCESS, itResourceService.getResourceGroup());
|
|
return new Result<>(ResultCode.SUCCESS, itResourceService.getResourceGroup());
|
|
|
}
|
|
}
|
|
@@ -99,20 +98,96 @@ public class ItResourceController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping(value = "/attribute/get")
|
|
@PostMapping(value = "/attribute/get")
|
|
|
- public Result<IPage<ItResourceAttribute>> getItResourceAttribute(@Validated @RequestBody ItResourceAttributePageData page) {
|
|
|
|
|
|
|
+ public Result<MyPage<ItResourceAttribute>> getItResourceAttribute(@Validated @RequestBody ItResourceAttributeReqData page) {
|
|
|
if (page.pageNo == null) {
|
|
if (page.pageNo == null) {
|
|
|
page.pageNo = 1;
|
|
page.pageNo = 1;
|
|
|
}
|
|
}
|
|
|
if (page.pageSize == null) {
|
|
if (page.pageSize == null) {
|
|
|
page.pageSize = 20;
|
|
page.pageSize = 20;
|
|
|
}
|
|
}
|
|
|
|
|
+ IPage<ItResourceAttribute> pageData = itResourceService.getResourceAttribute(page.pageNo, page.pageSize, page.groupId);
|
|
|
|
|
+ MyPage<ItResourceAttribute> myPage = new MyPage<>(pageData);
|
|
|
|
|
+ return new Result<>(ResultCode.SUCCESS, myPage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/attribute/add")
|
|
|
|
|
+ public Result<?> addItResourceAttribute(@Validated @RequestBody ItResourceAttribute itResourceAttribute) {
|
|
|
|
|
+ int result = itResourceService.addResourceAttribute(itResourceAttribute);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping(value = "/attribute/del/{i}")
|
|
|
|
|
+ public Result<?> delItResourceAttribute(@PathVariable String i) {
|
|
|
|
|
+ long id = Long.parseLong(i);
|
|
|
|
|
+ int result = itResourceService.delResourceAttribute(id);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/attribute/set")
|
|
|
|
|
+ public Result<?> setItResourceAttribute(@Validated @RequestBody ItResourceAttribute itResourceAttribute) {
|
|
|
|
|
+ int result = itResourceService.setResourceAttribute(itResourceAttribute);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/get")
|
|
|
|
|
+ public Result<MyPage<ItResource>> getItResource(@Validated @RequestBody ItResourceReqData page) {
|
|
|
|
|
+ if (page.pageNo == null) {
|
|
|
|
|
+ page.pageNo = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (page.pageSize == null) {
|
|
|
|
|
+ page.pageSize = 20;
|
|
|
|
|
+ }
|
|
|
|
|
+ IPage<ItResource> iPage = itResourceService.getResource(page.getPageNo(), page.getPageSize(), page.getResourceTypeId());
|
|
|
|
|
+ MyPage<ItResource> myPage = new MyPage<>(iPage);
|
|
|
|
|
+ return new Result<>(ResultCode.SUCCESS, myPage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/add")
|
|
|
|
|
+ public Result<?> addItResource(@Validated @RequestBody ItResource itResource) {
|
|
|
|
|
+ int result = itResourceService.addResource(itResource);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/del/{i}")
|
|
|
|
|
+ public Result<?> delItResource(@PathVariable String i) {
|
|
|
|
|
+ long id = Long.parseLong(i);
|
|
|
|
|
+ int result = itResourceService.delResource(id);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/set")
|
|
|
|
|
+ public Result<?> setItResource(@Validated @RequestBody ItResource itResource) {
|
|
|
|
|
+ int result = itResourceService.setResource(itResource);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/value/get/{i}")
|
|
|
|
|
+ public Result<List<ItResourceValue>> getItResourceValue(@PathVariable String i) {
|
|
|
|
|
+ long id = Long.parseLong(i);
|
|
|
|
|
+ return new Result<>(ResultCode.SUCCESS, itResourceService.getResourceValues(id));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return new Result<>(ResultCode.SUCCESS, itResourceService.getResourceAttribute(page.pageNo, page.pageSize, page.groupId));
|
|
|
|
|
|
|
+ @PostMapping("/value/add")
|
|
|
|
|
+ public Result<?> addItResourceValue(@RequestBody List<ItResourceValue> itResourceValues) {
|
|
|
|
|
+ return new Result<>(ResultCode.SUCCESS, itResourceService.addResourceValues(itResourceValues));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/value/del/{i}")
|
|
|
|
|
+ public Result<?> delItResourceValue(@PathVariable String i) {
|
|
|
|
|
+ long id = Long.parseLong(i);
|
|
|
|
|
+ int result = itResourceService.delResourceValueByResourceId(id);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/value/set")
|
|
|
|
|
+ public Result<?> setItResourceValues(@RequestBody List<ItResourceValue> itResourceValues) {
|
|
|
|
|
+ int result = itResourceService.setResourceValueById(itResourceValues);
|
|
|
|
|
+ return new Result<>(result == 1 ? ResultCode.SUCCESS : ResultCode.FAILED, null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-class ItResourceAttributePageData {
|
|
|
|
|
|
|
+class ItResourceAttributeReqData {
|
|
|
Integer pageNo;
|
|
Integer pageNo;
|
|
|
Integer pageSize;
|
|
Integer pageSize;
|
|
|
@NotNull
|
|
@NotNull
|
|
@@ -141,4 +216,35 @@ class ItResourceAttributePageData {
|
|
|
public void setGroupId(Long groupId) {
|
|
public void setGroupId(Long groupId) {
|
|
|
this.groupId = groupId;
|
|
this.groupId = groupId;
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+class ItResourceReqData {
|
|
|
|
|
+ Integer pageNo;
|
|
|
|
|
+ Integer pageSize;
|
|
|
|
|
+ @NotNull
|
|
|
|
|
+ Long resourceTypeId;
|
|
|
|
|
+
|
|
|
|
|
+ public Integer getPageNo() {
|
|
|
|
|
+ return pageNo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setPageNo(Integer pageNo) {
|
|
|
|
|
+ this.pageNo = pageNo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Integer getPageSize() {
|
|
|
|
|
+ return pageSize;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setPageSize(Integer pageSize) {
|
|
|
|
|
+ this.pageSize = pageSize;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Long getResourceTypeId() {
|
|
|
|
|
+ return resourceTypeId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void setResourceTypeId(Long resourceTypeId) {
|
|
|
|
|
+ this.resourceTypeId = resourceTypeId;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|