|
@@ -0,0 +1,66 @@
|
|
|
+package com.persagy.dc.define.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.persagy.common.exception.BusinessException;
|
|
|
+import com.persagy.dc.common.constant.CommonConstant;
|
|
|
+import com.persagy.dc.common.constant.ResponseCode;
|
|
|
+import com.persagy.dc.common.context.AppContext;
|
|
|
+import com.persagy.dc.common.model.QueryCriteria;
|
|
|
+import com.persagy.dc.common.model.response.CommonResult;
|
|
|
+import com.persagy.dc.common.model.response.PageList;
|
|
|
+import com.persagy.dc.common.utils.ResultHelper;
|
|
|
+import com.persagy.dc.define.entity.ObjectType;
|
|
|
+import com.persagy.dc.define.service.IObjectTypeService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+
|
|
|
+ * 对象类型 Controller
|
|
|
+ * @author Charlie Yu
|
|
|
+ * @date 2021-06-25
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rwd/def/class")
|
|
|
+public class ObjectTypeController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IObjectTypeService typeService;
|
|
|
+
|
|
|
+ @PostMapping("")
|
|
|
+ public CommonResult<PageList<ObjectType>> queryClass(@RequestBody QueryCriteria criteria) {
|
|
|
+ if(criteria == null) {
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
+ }
|
|
|
+ QueryWrapper<ObjectType> wrapper = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if(StrUtil.isNotBlank(AppContext.getContext().getProjectId())) {
|
|
|
+ wrapper.in(AppContext.PROJECT_ID, CommonConstant.DEFAULT_ID, AppContext.getContext().getProjectId());
|
|
|
+ }
|
|
|
+
|
|
|
+ criteria.toWrapper(wrapper);
|
|
|
+ Page page = typeService.queryByCondition(criteria.toPage(), wrapper);
|
|
|
+ return ResultHelper.multi(page.getRecords());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ public CommonResult<ObjectType> create(@RequestBody ObjectType vo){
|
|
|
+ vo = typeService.insert(vo);
|
|
|
+ return ResultHelper.single(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/update")
|
|
|
+ public CommonResult<ObjectType> update(@RequestBody ObjectType vo){
|
|
|
+ vo = typeService.update(vo);
|
|
|
+ return ResultHelper.single(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public void delete(@RequestBody String id){
|
|
|
+ typeService.delete(id);
|
|
|
+ }
|
|
|
+}
|