|
@@ -1,8 +1,7 @@
|
|
|
package org.jeecg.modules.system.controller;
|
|
package org.jeecg.modules.system.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
|
-import java.util.Date;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
@@ -15,8 +14,11 @@ import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CacheConstant;
|
|
import org.jeecg.common.constant.CacheConstant;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
|
|
+import org.jeecg.modules.online.cgform.entity.OnlCgformField;
|
|
|
|
|
+import org.jeecg.modules.system.entity.SysDict;
|
|
|
import org.jeecg.modules.system.entity.SysDictItem;
|
|
import org.jeecg.modules.system.entity.SysDictItem;
|
|
|
import org.jeecg.modules.system.service.ISysDictItemService;
|
|
import org.jeecg.modules.system.service.ISysDictItemService;
|
|
|
|
|
+import org.jeecg.modules.system.service.ISysDictService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -45,8 +47,13 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
public class SysDictItemController {
|
|
public class SysDictItemController {
|
|
|
|
|
|
|
|
|
|
+ private String postConfig = "post_config_dict";
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ISysDictItemService sysDictItemService;
|
|
private ISysDictItemService sysDictItemService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ISysDictService iSysDictService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @功能:查询字典数据
|
|
* @功能:查询字典数据
|
|
@@ -68,7 +75,82 @@ public class SysDictItemController {
|
|
|
result.setResult(pageList);
|
|
result.setResult(pageList);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @功能:查询字典数据(岗位配置的功能)
|
|
|
|
|
+ * @param sysDictItem
|
|
|
|
|
+ * @param pageNo
|
|
|
|
|
+ * @param pageSize
|
|
|
|
|
+ * @param req
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/listPost", method = RequestMethod.GET)
|
|
|
|
|
+ public Result<IPage<SysDictItem>> listPost(SysDictItem sysDictItem,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
|
|
|
|
|
+ Result<IPage<SysDictItem>> result = new Result<IPage<SysDictItem>>();
|
|
|
|
|
+ LambdaQueryWrapper<SysDict> var64 = new LambdaQueryWrapper<SysDict>()
|
|
|
|
|
+ .eq(SysDict::getDictCode, postConfig);
|
|
|
|
|
+
|
|
|
|
|
+ List<SysDict> list = iSysDictService.list(var64);
|
|
|
|
|
+ if (!list.isEmpty()){
|
|
|
|
|
+ SysDict sysDict = list.get(0);
|
|
|
|
|
+ sysDictItem.setDictId(sysDict.getId());
|
|
|
|
|
+ QueryWrapper<SysDictItem> queryWrapper = QueryGenerator.initQueryWrapper(sysDictItem, req.getParameterMap());
|
|
|
|
|
+ queryWrapper.orderByAsc("sort_order");
|
|
|
|
|
+ Page<SysDictItem> page = new Page<SysDictItem>(pageNo, pageSize);
|
|
|
|
|
+ IPage<SysDictItem> pageList = sysDictItemService.page(page, queryWrapper);
|
|
|
|
|
+ result.setSuccess(true);
|
|
|
|
|
+ result.setResult(pageList);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setSuccess(false);
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @功能:新增(岗位配置的功能)
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ //@RequiresRoles({"admin"})
|
|
|
|
|
+ @RequestMapping(value = "/addPost", method = RequestMethod.POST)
|
|
|
|
|
+ @CacheEvict(value= {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
|
|
|
|
+ public Result<SysDictItem> addPost(@RequestBody SysDictItem sysDictItem) {
|
|
|
|
|
+ Result<SysDictItem> result = new Result<SysDictItem>();
|
|
|
|
|
+ LambdaQueryWrapper<SysDict> var64 = new LambdaQueryWrapper<SysDict>()
|
|
|
|
|
+ .eq(SysDict::getDictCode, postConfig);
|
|
|
|
|
+ List<SysDict> list = iSysDictService.list(var64);
|
|
|
|
|
+ if (list.isEmpty()){
|
|
|
|
|
+ result.error500("请先配置字典 post_config_dict");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<SysDictItem>()
|
|
|
|
|
+ .eq(SysDictItem::getDictId, list.get(0).getId()).orderByDesc(SysDictItem::getCreateTime);
|
|
|
|
|
+
|
|
|
|
|
+ List<SysDictItem> list1 = sysDictItemService.list(sysDictItemLambdaQueryWrapper);
|
|
|
|
|
+ Integer i = 1;
|
|
|
|
|
+ if (!list1.isEmpty()){
|
|
|
|
|
+ for (SysDictItem dictItem : list1) {
|
|
|
|
|
+ if (dictItem.getItemText().equals(sysDictItem.getItemText())){
|
|
|
|
|
+ result.error500("重复的名称");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ sysDictItem.setStatus(1);
|
|
|
|
|
+ sysDictItem.setItemValue(sysDictItem.getItemText());
|
|
|
|
|
+ sysDictItem.setDictId(list.get(0).getId());
|
|
|
|
|
+ sysDictItem.setCreateTime(new Date());
|
|
|
|
|
+ sysDictItemService.save(sysDictItem);
|
|
|
|
|
+ result.success("保存成功!");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
|
|
+ result.error500("操作失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* @功能:新增
|
|
* @功能:新增
|
|
|
* @return
|
|
* @return
|
|
@@ -112,7 +194,37 @@ public class SysDictItemController {
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping(value = "/editPost", method = { RequestMethod.PUT,RequestMethod.POST })
|
|
|
|
|
+ @CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
|
|
|
|
+ public Result<SysDictItem> editPost(@RequestBody SysDictItem sysDictItem) {
|
|
|
|
|
+
|
|
|
|
|
+ Result<SysDictItem> result = new Result<SysDictItem>();
|
|
|
|
|
+ SysDictItem sysdict = sysDictItemService.getById(sysDictItem.getId());
|
|
|
|
|
+ //名称在变
|
|
|
|
|
+ if (!sysdict.getItemText().equals(sysDictItem.getItemText())){
|
|
|
|
|
+ LambdaQueryWrapper<SysDictItem> sysDictItemLambdaQueryWrapper = new LambdaQueryWrapper<SysDictItem>()
|
|
|
|
|
+ .eq(SysDictItem::getItemText, sysDictItem.getItemText()).orderByDesc(SysDictItem::getCreateTime)
|
|
|
|
|
+ .eq(SysDictItem::getDictId,sysDictItem.getDictId());
|
|
|
|
|
+ List<SysDictItem> list = sysDictItemService.list(sysDictItemLambdaQueryWrapper);
|
|
|
|
|
+ if (!list.isEmpty()){
|
|
|
|
|
+ result.error500("重复的名称");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if(sysdict==null) {
|
|
|
|
|
+ result.error500("未找到对应实体");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ sysDictItem.setUpdateTime(new Date());
|
|
|
|
|
+ boolean ok = sysDictItemService.updateById(sysDictItem);
|
|
|
|
|
+ //TODO 返回false说明什么?
|
|
|
|
|
+ if(ok) {
|
|
|
|
|
+ result.success("编辑成功!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
/**
|
|
/**
|
|
|
* @功能:删除字典数据
|
|
* @功能:删除字典数据
|
|
|
* @param id
|
|
* @param id
|