Merge remote-tracking branch 'origin/fix-bug-202303' into fix-bug-202303
This commit is contained in:
+41
-32
@@ -8,8 +8,10 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
@@ -69,7 +71,8 @@ public class SysDepartController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET)
|
||||
@GetMapping("/queryMyDeptTreeList")
|
||||
public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<>();
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
@@ -99,7 +102,8 @@ public class SysDepartController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
@GetMapping("/queryTreeList")
|
||||
public Result<List<SysDepartTreeModel>> queryTreeList() {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<>();
|
||||
try {
|
||||
@@ -122,7 +126,8 @@ public class SysDepartController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryDepartTreeSync", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryDepartTreeSync", method = RequestMethod.GET)
|
||||
@GetMapping("/queryDepartTreeSync")
|
||||
public Result<List<SysDepartTreeModel>> queryDepartTreeSync(@RequestParam(name = "pid", required = false) String parentId) {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<>();
|
||||
try {
|
||||
@@ -142,7 +147,7 @@ public class SysDepartController {
|
||||
* @param orgCode 根据orgCode查,departId和orgCode必须有一个不为空
|
||||
*/
|
||||
@GetMapping("/queryAllParentId")
|
||||
public Result queryParentIds(
|
||||
public Result<JSONObject> queryParentIds(
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name = "orgCode", required = false) String orgCode
|
||||
) {
|
||||
@@ -170,7 +175,8 @@ public class SysDepartController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("sys:depart:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
// @RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@PostMapping("/add")
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<Object> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
@@ -192,7 +198,8 @@ public class SysDepartController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("sys:depart:edit")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
// @RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
@PutMapping("/edit")
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<Object> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
@@ -216,7 +223,8 @@ public class SysDepartController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("sys:depart:del")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
// @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<Object> delete(@RequestParam(name="id",required=true) String id) {
|
||||
SysDepart sysDepart = sysDepartService.getById(id);
|
||||
@@ -240,7 +248,8 @@ public class SysDepartController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("sys:depart:del")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
// @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@DeleteMapping("/deleteBatch")
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<Object> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
@@ -256,7 +265,8 @@ public class SysDepartController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryIdTree", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryIdTree", method = RequestMethod.GET)
|
||||
@GetMapping("/queryIdTree")
|
||||
public Result<List<DepartIdModel>> queryIdTree() {
|
||||
try {
|
||||
List<DepartIdModel> list = sysDepartService.queryDepartIdTreeList();
|
||||
@@ -275,7 +285,8 @@ public class SysDepartController {
|
||||
* @param keyWord
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/searchBy", method = RequestMethod.GET)
|
||||
@GetMapping("/searchBy")
|
||||
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord,@RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) {
|
||||
//部门查询,myDeptSearch为1时为我的部门查询,登录用户为上级时查只查负责部门下数据
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
@@ -284,7 +295,7 @@ public class SysDepartController {
|
||||
departIds = user.getDepartIds();
|
||||
}
|
||||
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord,myDeptSearch,departIds);
|
||||
if (treeList == null || treeList.size() == 0) {
|
||||
if (treeList == null || treeList.isEmpty()) {
|
||||
return Result.error("未查询匹配数据!");
|
||||
}
|
||||
return Result.OK(treeList);
|
||||
@@ -305,17 +316,12 @@ public class SysDepartController {
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SysDepart> pageList = sysDepartService.list(queryWrapper);
|
||||
//按字典排序
|
||||
Collections.sort(pageList, new Comparator<SysDepart>() {
|
||||
@Override
|
||||
public int compare(SysDepart arg0, SysDepart arg1) {
|
||||
return arg0.getOrgCode().compareTo(arg1.getOrgCode());
|
||||
}
|
||||
});
|
||||
Collections.sort(pageList,(SysDepart arg0, SysDepart arg1)-> arg0.getOrgCode().compareTo(arg1.getOrgCode()));
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
|
||||
mv.addObject(JeroController.FILE_NAME, "部门列表");
|
||||
mv.addObject(JeroController.CLASS, SysDepart.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(JeroController.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
@@ -329,9 +335,10 @@ public class SysDepartController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("sys:depart:import")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
@PostMapping("/importExcel")
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
public Result<T> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
List<String> errorMessageList = new ArrayList<>();
|
||||
List<SysDepart> listSysDeparts = null;
|
||||
@@ -346,24 +353,25 @@ public class SysDepartController {
|
||||
// orgCode编码长度
|
||||
int codeLength = YouBianCodeUtil.ZHANWEI_LENGTH;
|
||||
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepart.class, params);
|
||||
//按长度排序
|
||||
Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
|
||||
//按长度排序 todo 当比较到最后一个元素时会出现空指针 导入需要做orgCode必填效验
|
||||
/*Collections.sort(listSysDeparts, new Comparator<SysDepart>() {
|
||||
@Override
|
||||
public int compare(SysDepart arg0, SysDepart arg1) {
|
||||
return arg0.getOrgCode().length() - arg1.getOrgCode().length();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
Collections.sort(listSysDeparts, (SysDepart arg0, SysDepart arg1) -> arg0.getOrgCode().length() - arg1.getOrgCode().length());
|
||||
|
||||
int num = 0;
|
||||
for (SysDepart sysDepart : listSysDeparts) {
|
||||
String orgCode = sysDepart.getOrgCode();
|
||||
if(orgCode.length() > codeLength) {
|
||||
String parentCode = orgCode.substring(0, orgCode.length()-codeLength);
|
||||
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<SysDepart>();
|
||||
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("org_code", parentCode);
|
||||
try {
|
||||
SysDepart parentDept = sysDepartService.getOne(queryWrapper);
|
||||
if(!parentDept.equals(null)) {
|
||||
if(parentDept != null) {
|
||||
sysDepart.setParentId(parentDept.getId());
|
||||
} else {
|
||||
sysDepart.setParentId("");
|
||||
@@ -408,10 +416,10 @@ public class SysDepartController {
|
||||
*/
|
||||
@GetMapping("listAll")
|
||||
public Result<List<SysDepart>> listAll(@RequestParam(name = "id", required = false) String id) {
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<>();
|
||||
query.orderByAsc(SysDepart::getOrgCode);
|
||||
if(oConvertUtils.isNotEmpty(id)){
|
||||
String arr[] = id.split(",");
|
||||
String[] arr = id.split(",");
|
||||
query.in(SysDepart::getId,arr);
|
||||
}
|
||||
List<SysDepart> ls = this.sysDepartService.list(query);
|
||||
@@ -422,14 +430,15 @@ public class SysDepartController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeByKeyWord", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryTreeByKeyWord", method = RequestMethod.GET)
|
||||
@GetMapping("/queryTreeByKeyWord")
|
||||
public Result<Map<String,Object>> queryTreeByKeyWord(@RequestParam(name = "keyWord", required = false) String keyWord) {
|
||||
Result<Map<String,Object>> result = new Result<>();
|
||||
try {
|
||||
Map<String,Object> map=new HashMap<String,Object>();
|
||||
Map<String,Object> map=new HashMap<>();
|
||||
List<SysDepartTreeModel> list = sysDepartService.queryTreeByKeyWord(keyWord);
|
||||
//根据keyWord获取用户信息
|
||||
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<SysUser>();
|
||||
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<>();
|
||||
queryUser.eq(SysUser::getDelFlag,CommonConstant.DEL_FLAG_0);
|
||||
queryUser.and(i -> i.like(SysUser::getUsername, keyWord).or().like(SysUser::getRealname, keyWord));
|
||||
List<SysUser> sysUsers = this.sysUserService.list(queryUser);
|
||||
|
||||
+22
-19
@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.modules.system.service.ISysPermissionDataRuleService;
|
||||
import com.jero.modules.system.service.ISysPermissionService;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -61,16 +62,16 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
*/
|
||||
@ApiOperation(value="部门权限表-分页列表查询", notes="部门权限表-分页列表查询")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<?> queryPageList(SysDepartPermission sysDepartPermission,
|
||||
public Result<IPage<SysDepartPermission>> queryPageList(SysDepartPermission sysDepartPermission,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDepartPermission> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartPermission, req.getParameterMap());
|
||||
Page<SysDepartPermission> page = new Page<SysDepartPermission>(pageNo, pageSize);
|
||||
Page<SysDepartPermission> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDepartPermission> pageList = sysDepartPermissionService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
@@ -79,11 +80,11 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
*/
|
||||
@ApiOperation(value="部门权限表-添加", notes="部门权限表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
public Result<T> add(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
sysDepartPermissionService.save(sysDepartPermission);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
@@ -92,11 +93,11 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
*/
|
||||
@ApiOperation(value="部门权限表-编辑", notes="部门权限表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
public Result<T> edit(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
sysDepartPermissionService.updateById(sysDepartPermission);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
@@ -105,11 +106,11 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
*/
|
||||
@ApiOperation(value="部门权限表-通过id删除", notes="部门权限表-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<T> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysDepartPermissionService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
@@ -118,11 +119,11 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
*/
|
||||
@ApiOperation(value="部门权限表-批量删除", notes="部门权限表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
public Result<T> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysDepartPermissionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
@@ -131,7 +132,7 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
*/
|
||||
@ApiOperation(value="部门权限表-通过id查询", notes="部门权限表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
public Result<SysDepartPermission> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getById(id);
|
||||
return Result.OK(sysDepartPermission);
|
||||
}
|
||||
@@ -154,8 +155,9 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
@PostMapping("/importExcel")
|
||||
public Result<SysDepartPermission> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDepartPermission.class);
|
||||
}
|
||||
|
||||
@@ -163,9 +165,9 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
* 部门管理授权查询数据规则数据
|
||||
*/
|
||||
@GetMapping(value = "/datarule/{permissionId}/{departId}")
|
||||
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
|
||||
public Result<Map<String, Object>> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
|
||||
List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
|
||||
if(list==null || list.size()==0) {
|
||||
if(list==null || list.isEmpty()) {
|
||||
return Result.error("未找到权限配置信息");
|
||||
}else {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
@@ -192,13 +194,14 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
|
||||
@GetMapping("/queryTreeListForDeptRole")
|
||||
public Result<Map<String,Object>> queryTreeListForDeptRole(@RequestParam(name="departId",required=true) String departId,HttpServletRequest request) {
|
||||
Result<Map<String,Object>> result = new Result<>();
|
||||
//全部权限ids
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
query.inSql(SysPermission::getId,"select permission_id from sys_depart_permission where depart_id='"+departId+"'");
|
||||
@@ -208,7 +211,7 @@ public class SysDepartPermissionController extends JeroController<SysDepartPermi
|
||||
}
|
||||
List<TreeModel> treeList = new ArrayList<>();
|
||||
getTreeModelList(treeList, list, null);
|
||||
Map<String,Object> resMap = new HashMap<String,Object>();
|
||||
Map<String,Object> resMap = new HashMap<>();
|
||||
resMap.put("treeList", treeList); //全部树节点数据
|
||||
resMap.put("ids", ids);//全部树ids
|
||||
result.setResult(resMap);
|
||||
|
||||
+60
-41
@@ -6,9 +6,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
@@ -69,13 +71,18 @@ public class SysDictController {
|
||||
@Autowired
|
||||
public RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||
private String DICT_CODE_ERROE = "字典Code格式不正确!";
|
||||
private String OPTION_SUCCESS = "操作成功!";
|
||||
private String DEL_SUCCESS = "删除成功!";
|
||||
|
||||
// @RequestMapping(value = "/page", method = RequestMethod.GET)
|
||||
@GetMapping("/page")
|
||||
@ApiOperation(value = "字典控制器-分页列表查询", notes = "字典控制器-分页列表查询")
|
||||
public Result<IPage<SysDict>> queryPageList(SysDict sysDict, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
|
||||
Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
|
||||
Result<IPage<SysDict>> result = new Result<>();
|
||||
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
|
||||
Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
|
||||
Page<SysDict> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
|
||||
log.debug("查询当前页:"+pageList.getCurrent());
|
||||
log.debug("查询当前页数量:"+pageList.getSize());
|
||||
@@ -95,7 +102,8 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-树形字典数据", notes = "字典控制器-树形字典数据")
|
||||
@RequestMapping(value = "/treeList", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/treeList", method = RequestMethod.GET)
|
||||
@GetMapping("/treeList")
|
||||
public Result<List<SysDictTree>> treeList(SysDict sysDict, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
|
||||
Result<List<SysDictTree>> result = new Result<>();
|
||||
@@ -122,9 +130,10 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-获取全部字典数据", notes = "字典控制器-获取全部字典数据")
|
||||
@RequestMapping(value = "/queryAllDictItems", method = RequestMethod.GET)
|
||||
public Result<?> queryAllDictItems(HttpServletRequest request) {
|
||||
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
|
||||
// @RequestMapping(value = "/queryAllDictItems", method = RequestMethod.GET)
|
||||
@GetMapping("/queryAllDictItems")
|
||||
public Result<Map<String, List<DictModel>>> queryAllDictItems(HttpServletRequest request) {
|
||||
Map<String, List<DictModel>> res ;
|
||||
res = sysDictService.queryAllDictItems();
|
||||
return Result.OK(res);
|
||||
}
|
||||
@@ -135,10 +144,11 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-通过字典code和字典值key获取字典数据", notes = "字典控制器-通过字典code和字典值key获取字典数据")
|
||||
@RequestMapping(value = "/getDictText/{dictCode}/{key}", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/getDictText/{dictCode}/{key}", method = RequestMethod.GET)
|
||||
@GetMapping("/getDictText/{dictCode}/{key}")
|
||||
public Result<String> getDictText(@PathVariable("dictCode") String dictCode, @PathVariable("key") String key) {
|
||||
log.info(" dictCode : "+ dictCode);
|
||||
Result<String> result = new Result<String>();
|
||||
Result<String> result = new Result<>();
|
||||
String text = null;
|
||||
try {
|
||||
text = sysDictService.queryDictTextByKey(dictCode, key);
|
||||
@@ -157,14 +167,15 @@ public class SysDictController {
|
||||
* @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
@GetMapping("/getDictItems/{dictCode}")
|
||||
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
|
||||
log.info(" dictCode : "+ dictCode);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
Result<List<DictModel>> result = new Result<>();
|
||||
try {
|
||||
List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
if (ls == null) {
|
||||
return Result.error("字典Code格式不正确!");
|
||||
return Result.error(DICT_CODE_ERROE);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
@@ -183,17 +194,18 @@ public class SysDictController {
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
|
||||
@GetMapping("/loadDict/{dictCode}")
|
||||
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,
|
||||
@RequestParam(name="keyword") String keyword,
|
||||
@RequestParam(value = "sign",required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
log.info(" 加载字典表数据,加载关键字: "+ keyword);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
Result<List<DictModel>> result = new Result<>();
|
||||
try {
|
||||
List<DictModel> ls = sysDictService.loadDict(dictCode, keyword, pageSize);
|
||||
if (ls == null) {
|
||||
return Result.error("字典Code格式不正确!");
|
||||
return Result.error(DICT_CODE_ERROE);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
@@ -213,7 +225,8 @@ public class SysDictController {
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictOrderByValue/{dictCode}", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadDictOrderByValue/{dictCode}", method = RequestMethod.GET)
|
||||
@GetMapping("/loadDictOrderByValue/{dictCode}")
|
||||
public Result<List<DictModel>> loadDictOrderByValue(
|
||||
@PathVariable String dictCode,
|
||||
@RequestParam(name = "keyword") String keyword,
|
||||
@@ -255,14 +268,15 @@ public class SysDictController {
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
|
||||
@GetMapping("/loadDictItem/{dictCode}")
|
||||
public Result<List<String>> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String keys, @RequestParam(value = "sign",required = false) String sign,@RequestParam(value = "delNotExist",required = false,defaultValue = "true") boolean delNotExist,HttpServletRequest request) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
String[] params = dictCode.split(",");
|
||||
if(params.length!=3) {
|
||||
return Result.error("字典Code格式不正确!");
|
||||
return Result.error(DICT_CODE_ERROE);
|
||||
}
|
||||
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys, delNotExist);
|
||||
|
||||
@@ -270,7 +284,7 @@ public class SysDictController {
|
||||
result.setResult(texts);
|
||||
log.info(result.toString());
|
||||
}else {
|
||||
return Result.error("字典Code格式不正确!");
|
||||
return Result.error(DICT_CODE_ERROE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
@@ -285,14 +299,15 @@ public class SysDictController {
|
||||
* 根据表名——显示字段-存储字段 pid 加载树形数据
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-根据表名—显示字段-存储字段 pid 加载树形数据", notes = "字典控制器-根据表名—显示字段-存储字段 pid 加载树形数据")
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
@GetMapping("/loadTreeData")
|
||||
public Result<List<TreeSelectModel>> loadTreeData(@RequestParam(name="pid") String pid, @RequestParam(name="pidField") String pidField,
|
||||
@RequestParam(name="tableName") String tbname,
|
||||
@RequestParam(name="text") String text,
|
||||
@RequestParam(name="code") String code,
|
||||
@RequestParam(name="hasChildField", required = false) String hasChildField,
|
||||
@RequestParam(value = "sign", required = false) String sign, HttpServletRequest request) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
Result<List<TreeSelectModel>> result = new Result<>();
|
||||
|
||||
// SQL注入漏洞 sign签名校验(表名,label字段,val字段,条件)
|
||||
String dictCode = tbname +","+ text +","+ code;
|
||||
@@ -307,13 +322,14 @@ public class SysDictController {
|
||||
* 查询后返回树型数据
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-根据表名—显示字段-存储字段 加载树形数据", notes = "字典控制器-根据表名—显示字段-存储字段 加载树形数据")
|
||||
@RequestMapping(value = "/queryAllTreeData", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/queryAllTreeData", method = RequestMethod.GET)
|
||||
@GetMapping("/queryAllTreeData")
|
||||
public Result<List<TreeSelectModel>> queryAllTreeData(@RequestParam(name="pidField") String pidField,
|
||||
@RequestParam(name="tableName") String tbname,
|
||||
@RequestParam(name="text") String text,
|
||||
@RequestParam(name="code") String code,
|
||||
HttpServletRequest request) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
Result<List<TreeSelectModel>> result = new Result<>();
|
||||
|
||||
// SQL注入漏洞 sign签名校验(表名,label字段,val字段,条件)
|
||||
String dictCode = tbname +","+ text +","+ code;
|
||||
@@ -330,7 +346,8 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-新增字典", notes = "字典控制器-新增字典")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
// @RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@PostMapping("/add")
|
||||
public Result<Object> add(@RequestBody SysDict sysDict) {
|
||||
try {
|
||||
sysDict.setCreateTime(new Date());
|
||||
@@ -338,7 +355,7 @@ public class SysDictController {
|
||||
sysDictService.save(sysDict);
|
||||
//添加成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
return Result.OK("操作成功!");
|
||||
return Result.OK(OPTION_SUCCESS);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return Result.error("操作失败");
|
||||
@@ -351,7 +368,8 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-编辑字典", notes = "字典控制器-编辑字典")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
// @RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
@PutMapping("/edit")
|
||||
public Result<Object> edit(@RequestBody SysDict sysDict) {
|
||||
SysDict sysdict = sysDictService.getById(sysDict.getId());
|
||||
if(sysdict==null) {
|
||||
@@ -362,7 +380,7 @@ public class SysDictController {
|
||||
if(ok) {
|
||||
//编辑成功后需要刷新缓存
|
||||
sysDictService.refreshCache();
|
||||
return Result.OK("操作成功!");
|
||||
return Result.OK(OPTION_SUCCESS);
|
||||
}
|
||||
}
|
||||
return Result.OK();
|
||||
@@ -379,7 +397,7 @@ public class SysDictController {
|
||||
public Result<Object> delete(@RequestParam(name="id",required=true) String id) {
|
||||
boolean ok = sysDictService.removeById(id);
|
||||
if(ok) {
|
||||
return Result.OK("删除成功!");
|
||||
return Result.OK(DEL_SUCCESS);
|
||||
}else{
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
@@ -398,7 +416,7 @@ public class SysDictController {
|
||||
return Result.error("参数不识别!");
|
||||
}else {
|
||||
sysDictService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("删除成功!");
|
||||
return Result.OK(DEL_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,8 +426,8 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/refleshCache")
|
||||
public Result<?> refleshCache() {
|
||||
Result<?> result = new Result<SysDict>();
|
||||
public Result<SysDict> refleshCache() {
|
||||
Result<SysDict> result = new Result<>();
|
||||
sysDictService.refreshCache();
|
||||
return result;
|
||||
}
|
||||
@@ -425,7 +443,7 @@ public class SysDictController {
|
||||
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
List<SysDictPage> pageList = new ArrayList<SysDictPage>();
|
||||
List<SysDictPage> pageList = new ArrayList<>();
|
||||
|
||||
List<SysDict> sysDictList = sysDictService.list(queryWrapper);
|
||||
for (SysDict dictMain : sysDictList) {
|
||||
@@ -438,12 +456,12 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
// 导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "数据字典");
|
||||
mv.addObject(JeroController.FILE_NAME, "数据字典");
|
||||
// 注解对象Class
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
|
||||
mv.addObject(JeroController.CLASS, SysDictPage.class);
|
||||
// 自定义表格参数
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:"+user.getRealname(), "数据字典"));
|
||||
mv.addObject(JeroController.PARAMS, new ExportParams("数据字典列表", "导出人:"+user.getRealname(), "数据字典"));
|
||||
// 导出数据列表
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
@@ -451,7 +469,7 @@ public class SysDictController {
|
||||
|
||||
|
||||
@PostMapping(value = "/importExcel")
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
public Result<T> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
@@ -469,7 +487,8 @@ public class SysDictController {
|
||||
List<SysDictPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SysDictPage.class, params);
|
||||
// 错误信息
|
||||
List<String> errorMessage = new ArrayList<>();
|
||||
int successLines = 0, errorLines = 0;
|
||||
int successLines = 0;
|
||||
int errorLines = 0;
|
||||
for (int i=0;i< list.size();i++) {
|
||||
SysDict po = new SysDict();
|
||||
BeanUtils.copyProperties(list.get(i), po);
|
||||
@@ -521,10 +540,10 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deletePhysic/{id}")
|
||||
public Result<?> deletePhysic(@PathVariable String id) {
|
||||
public Result<T> deletePhysic(@PathVariable String id) {
|
||||
try {
|
||||
sysDictService.deleteOneDictPhysically(id);
|
||||
return Result.OK("删除成功!");
|
||||
return Result.OK(DEL_SUCCESS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("删除失败!");
|
||||
@@ -537,10 +556,10 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/back/{id}")
|
||||
public Result<?> back(@PathVariable String id) {
|
||||
public Result<T> back(@PathVariable String id) {
|
||||
try {
|
||||
sysDictService.updateDictDelFlag(0,id);
|
||||
return Result.OK("操作成功!");
|
||||
return Result.OK(OPTION_SUCCESS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error("操作失败!");
|
||||
|
||||
Reference in New Issue
Block a user