|
@@ -1,19 +1,24 @@
|
|
|
package com.zhiqiyun.open.mvc.controller;
|
|
package com.zhiqiyun.open.mvc.controller;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.zhiqiyun.open.annotation.Permission;
|
|
import com.zhiqiyun.open.annotation.Permission;
|
|
|
import com.zhiqiyun.open.core.models.base.BzDataBaseInfo;
|
|
import com.zhiqiyun.open.core.models.base.BzDataBaseInfo;
|
|
|
|
|
+import com.zhiqiyun.open.core.models.base.BzDataBaseInfoExtend;
|
|
|
import com.zhiqiyun.open.core.models.base.BzDataType;
|
|
import com.zhiqiyun.open.core.models.base.BzDataType;
|
|
|
import com.zhiqiyun.open.core.models.base.BzDataTypeExtendColumn;
|
|
import com.zhiqiyun.open.core.models.base.BzDataTypeExtendColumn;
|
|
|
import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
import com.zhiqiyun.open.core.models.user.OauthInfo;
|
|
|
import com.zhiqiyun.open.core.service.*;
|
|
import com.zhiqiyun.open.core.service.*;
|
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
import com.zhiqiyun.open.mvc.Result;
|
|
|
import com.zhiqiyun.open.mvc.params.base.QueryBzDataBaseInfoParam;
|
|
import com.zhiqiyun.open.mvc.params.base.QueryBzDataBaseInfoParam;
|
|
|
|
|
+import com.zhiqiyun.open.mvc.params.base.SaveBzDataBaseInfoExtendParam;
|
|
|
import com.zhiqiyun.open.mvc.params.base.SaveBzDataBaseInfoParam;
|
|
import com.zhiqiyun.open.mvc.params.base.SaveBzDataBaseInfoParam;
|
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
import com.zhiqiyun.open.utils.DateUtil;
|
|
|
import com.zhiqiyun.open.utils.ServletContext;
|
|
import com.zhiqiyun.open.utils.ServletContext;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -23,105 +28,146 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/bz/data/info")
|
|
@RequestMapping("/bz/data/info")
|
|
|
public class BzDataBaseInfoController {
|
|
public class BzDataBaseInfoController {
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private BzDataTypeService bzDataTypeService;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BzDataTypeService bzDataTypeService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private BzDataTypeExtendColumnService bzDataTypeExtendColumnService;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BzDataTypeExtendColumnService bzDataTypeExtendColumnService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private BzDataBaseInfoService bzDataBaseInfoService;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BzDataBaseInfoService bzDataBaseInfoService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private SequenceService sequenceService;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private BzDataBaseInfoExtendService bzDataBaseInfoExtendService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private OauthService oauthService;
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SequenceService sequenceService;
|
|
|
|
|
|
|
|
- @Permission(value = "bz.data.type.find", tags = "查询基础数据分类")
|
|
|
|
|
- @PostMapping("/findPage")
|
|
|
|
|
- public Result findPage(@RequestBody QueryBzDataBaseInfoParam param) {
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OauthService oauthService;
|
|
|
|
|
|
|
|
- QueryWrapper<BzDataBaseInfo> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
+ @Permission(value = "bz.data.type.find", tags = "查询基础数据分类")
|
|
|
|
|
+ @PostMapping("/findPage")
|
|
|
|
|
+ public Result findPage(@RequestBody QueryBzDataBaseInfoParam param) {
|
|
|
|
|
|
|
|
- if (StringUtils.isNotBlank(param.getName())) {
|
|
|
|
|
- wrapper.like("name", param.getName());
|
|
|
|
|
- }
|
|
|
|
|
- Page<BzDataBaseInfo> page = param.getPage();
|
|
|
|
|
- page.addOrder(OrderItem.asc("sort_number"));
|
|
|
|
|
- page.addOrder(OrderItem.desc("id"));
|
|
|
|
|
|
|
+ QueryWrapper<BzDataBaseInfo> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
- Page<BzDataBaseInfo> resultData = this.bzDataBaseInfoService.page(page, wrapper);
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(param.getName())) {
|
|
|
|
|
+ wrapper.like("name", param.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ Page<BzDataBaseInfo> page = param.getPage();
|
|
|
|
|
+ page.addOrder(OrderItem.desc("id"));
|
|
|
|
|
|
|
|
- return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Page<BzDataBaseInfo> resultData = this.bzDataBaseInfoService.page(page, wrapper);
|
|
|
|
|
|
|
|
- @Permission(value = "bz.data.type.add", tags = "新建基础数据分类")
|
|
|
|
|
- @PostMapping("/save")
|
|
|
|
|
- public Result save(@Valid @RequestBody SaveBzDataBaseInfoParam param) throws Exception {
|
|
|
|
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(resultData);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- BzDataBaseInfo entity = new BzDataBaseInfo();
|
|
|
|
|
- BeanUtils.copyProperties(param, entity);
|
|
|
|
|
|
|
+ @Permission(value = "bz.data.type.add", tags = "新建基础数据分类")
|
|
|
|
|
+ @PostMapping("/save")
|
|
|
|
|
+ public Result save(@Valid @RequestBody SaveBzDataBaseInfoParam param) throws Exception {
|
|
|
|
|
|
|
|
- OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
|
|
|
|
+ BzDataBaseInfo entity = new BzDataBaseInfo();
|
|
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
|
|
|
|
|
- entity.setCreatedTime(DateUtil.current());
|
|
|
|
|
- entity.setCreatedBy(oauthInfo.getId());
|
|
|
|
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
|
|
|
|
|
- entity.setUpdatedTime(DateUtil.current());
|
|
|
|
|
- entity.setUpdatedBy(oauthInfo.getId());
|
|
|
|
|
- entity.setId(this.sequenceService.nextId());
|
|
|
|
|
|
|
+ entity.setCreatedTime(DateUtil.current());
|
|
|
|
|
+ entity.setCreatedBy(oauthInfo.getId());
|
|
|
|
|
|
|
|
- this.bzDataBaseInfoService.save(entity);
|
|
|
|
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
|
|
+ entity.setId(this.sequenceService.nextId());
|
|
|
|
|
|
|
|
- return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<BzDataBaseInfoExtend> listExtends = new ArrayList<>();
|
|
|
|
|
+ if (param.getListExtends() != null) {
|
|
|
|
|
+ for (SaveBzDataBaseInfoExtendParam extendParam : param.getListExtends()) {
|
|
|
|
|
+ BzDataBaseInfoExtend extend = new BzDataBaseInfoExtend();
|
|
|
|
|
+ BeanUtils.copyProperties(extendParam, extend);
|
|
|
|
|
+ listExtends.add(extend);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- @Permission(value = "bz.data.type.edit", tags = "更新基础数据分类")
|
|
|
|
|
- @PostMapping("/updateById")
|
|
|
|
|
- public Result updateById(Long id, @Valid @RequestBody SaveBzDataBaseInfoParam param) {
|
|
|
|
|
- BzDataBaseInfo entity = new BzDataBaseInfo();
|
|
|
|
|
- BeanUtils.copyProperties(param, entity);
|
|
|
|
|
|
|
+ this.bzDataBaseInfoService.save(entity, listExtends);
|
|
|
|
|
|
|
|
- OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
|
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- entity.setUpdatedBy(oauthInfo.getId());
|
|
|
|
|
- entity.setUpdatedTime(DateUtil.current());
|
|
|
|
|
- entity.setId(id);
|
|
|
|
|
|
|
+ @Permission(value = "bz.data.type.edit", tags = "更新基础数据分类")
|
|
|
|
|
+ @PostMapping("/updateById")
|
|
|
|
|
+ public Result updateById(Long id, @Valid @RequestBody SaveBzDataBaseInfoParam param) {
|
|
|
|
|
+ BzDataBaseInfo entity = new BzDataBaseInfo();
|
|
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
|
|
|
|
|
- this.bzDataBaseInfoService.updateById(entity);
|
|
|
|
|
|
|
+ OauthInfo oauthInfo = this.oauthService.getAuth(ServletContext.getAccessToken());
|
|
|
|
|
|
|
|
- return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ entity.setUpdatedBy(oauthInfo.getId());
|
|
|
|
|
+ entity.setUpdatedTime(DateUtil.current());
|
|
|
|
|
+ entity.setId(id);
|
|
|
|
|
|
|
|
- @Permission(value = "bz.data.type.delete", tags = "删除基础数据分类")
|
|
|
|
|
- @PostMapping("/deleteByIds")
|
|
|
|
|
- public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
|
|
- this.bzDataBaseInfoService.removeByIds(ids);
|
|
|
|
|
- return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<BzDataBaseInfoExtend> listExtends = new ArrayList<>();
|
|
|
|
|
+ if (param.getListExtends() != null) {
|
|
|
|
|
+ for (SaveBzDataBaseInfoExtendParam extendParam : param.getListExtends()) {
|
|
|
|
|
+ BzDataBaseInfoExtend extend = new BzDataBaseInfoExtend();
|
|
|
|
|
+ BeanUtils.copyProperties(extendParam, extend);
|
|
|
|
|
+ listExtends.add(extend);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- @PostMapping("/findAllDataType")
|
|
|
|
|
- @Permission(value = {"bz.data.type.edit", "bz.data.type.add"}, tags = "获取所有场所类型", writeLog = false)
|
|
|
|
|
- public Result findAllDataType() {
|
|
|
|
|
- List<BzDataType> listData = this.bzDataTypeService.list();
|
|
|
|
|
- return Result.instance(Result.Code.SUCCESS).setData(listData);
|
|
|
|
|
|
|
+ log.info(JSON.toJSONString(listExtends));
|
|
|
|
|
+ this.bzDataBaseInfoService.updateById(entity, listExtends);
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- @PostMapping("/findDataTypeExtendColumn")
|
|
|
|
|
- @Permission(value = {"bz.data.type.edit", "bz.data.type.add"}, tags = "获取所有场所类型扩展字段", writeLog = false)
|
|
|
|
|
- public Result findDataTypeExtendColumn(Long dataTypeId) {
|
|
|
|
|
- QueryWrapper<BzDataTypeExtendColumn> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
- queryWrapper.eq("data_type_id", dataTypeId);
|
|
|
|
|
- List<BzDataTypeExtendColumn> listData = this.bzDataTypeExtendColumnService.list(queryWrapper);
|
|
|
|
|
- return Result.instance(Result.Code.SUCCESS).setData(listData);
|
|
|
|
|
|
|
+ @Permission(value = "bz.data.type.delete", tags = "删除基础数据分类")
|
|
|
|
|
+ @PostMapping("/deleteByIds")
|
|
|
|
|
+ public Result deleteByIds(@RequestBody List<Long> ids) {
|
|
|
|
|
+ this.bzDataBaseInfoService.removeByIds(ids);
|
|
|
|
|
+ return Result.instance(Result.Code.MESSAGE_SUCCESS);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ @PostMapping("/findAllDataType")
|
|
|
|
|
+ @Permission(value = {"bz.data.type.edit", "bz.data.type.add"}, tags = "获取所有场所类型", writeLog = false)
|
|
|
|
|
+ public Result findAllDataType() {
|
|
|
|
|
+ List<BzDataType> listData = this.bzDataTypeService.list();
|
|
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(listData);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/findDataBaseInfoExtends")
|
|
|
|
|
+ @Permission(value = {"bz.data.type.edit", "bz.data.type.add"}, tags = "获取所有场所类型", writeLog = false)
|
|
|
|
|
+ public Result findDataBaseInfoExtends(Long baseInfoId, Long dataTypeId) {
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<BzDataTypeExtendColumn> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("data_type_id", dataTypeId);
|
|
|
|
|
+ List<BzDataTypeExtendColumn> listData = this.bzDataTypeExtendColumnService.list(queryWrapper);
|
|
|
|
|
+ for (BzDataTypeExtendColumn extendColumn : listData) {
|
|
|
|
|
+ String id = DigestUtils.md5Hex(String.format("%s@%s", baseInfoId, extendColumn.getId()));
|
|
|
|
|
+ BzDataBaseInfoExtend extend = this.bzDataBaseInfoExtendService.getById(id);
|
|
|
|
|
+ extendColumn.setFieldValue(extend.getFieldValue());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(listData);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/findDataTypeExtendColumn")
|
|
|
|
|
+ @Permission(value = {"bz.data.type.edit", "bz.data.type.add"}, tags = "获取所有场所类型扩展字段", writeLog = false)
|
|
|
|
|
+ public Result findDataTypeExtendColumn(Long dataTypeId) {
|
|
|
|
|
+ QueryWrapper<BzDataTypeExtendColumn> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
+ queryWrapper.eq("data_type_id", dataTypeId);
|
|
|
|
|
+ List<BzDataTypeExtendColumn> listData = this.bzDataTypeExtendColumnService.list(queryWrapper);
|
|
|
|
|
+ return Result.instance(Result.Code.SUCCESS).setData(listData);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|