标签-树形+搜索%修改

This commit is contained in:
xiejunyu
2022-03-18 11:36:10 +08:00
parent a05e3da88e
commit 065ffeb83c
11 changed files with 174 additions and 129 deletions
@@ -95,37 +95,20 @@ public class SysCategoryController {
return result;
}
/**通过字典id查询
/**标签内容-树形结构列表
*
* @param sysDictId
* @param params
* @return
*/
@AutoLog(value = "标签内容-树形结构-通过sysDictId查询")
@ApiOperation(value="标签内容-树形结构-通过sysDictId查询", notes="标签内容-树形结构-通过sysDictId查询")
@GetMapping(value = "/queryBySysDictId")
// @RequiresPermissions("sys:category:queryBySysDictId")
public Result<?> queryBySysDictId(@RequestParam(name="id",required=true) String sysDictId) {
List<SysCategory> sysCategory = sysCategoryService.queryBySysDictId(sysDictId);
if(sysCategory==null) {
return Result.error("未找到对应数据");
}
return Result.OK(sysCategory);
@AutoLog(value = "标签内容-树形结构列表")
@ApiOperation(value="标签内容-树形结构列表", notes="标签内容-树形结构列表")
@PostMapping(value = "/queryPageList")
// @RequiresPermissions("sys:category:queryPageList")
public Result<?> queryPageList(@RequestBody Map<String,Object> params) {
IPage<SysCategory> pageList= sysCategoryService.queryPageList(params);
return Result.OK(pageList);
}
/**树形结构搜索条件-名称
*
* @param
* @return
*/
@AutoLog(value = "标签内容-树形结构-通过名称查询")
@ApiOperation(value="标签内容-树形结构-通过名称查询", notes="标签内容-树形结构-通过名称查询")
@GetMapping(value = "/queryBySysName")
public Result<?> queryBySysName(@RequestParam(name="name",required=true) String sysName) {
List<SysCategory> sysCategory = sysCategoryService.queryBySysName(sysName);
if(sysCategory==null) {
return Result.error("未找到对应数据");
}
return Result.OK(sysCategory);
}
/**
* 添加
* @param sysCategory
@@ -1,6 +1,7 @@
package com.jero.modules.system.controller;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -18,6 +19,7 @@ import com.jero.common.util.oConvertUtils;
import com.jero.modules.enums.FixedFieldEnum;
import com.jero.modules.system.entity.SysDict;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.model.SysDictTree;
import com.jero.modules.system.model.TreeSelectModel;
import com.jero.modules.system.service.ISysDictItemService;
@@ -193,6 +195,8 @@ public class SysDictController {
public Result<?> queryAllDictItems(HttpServletRequest request) {
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
res = sysDictService.queryAllDictItems();
//添加成功后需要刷新缓存
sysDictService.refreshCache();
return Result.OK(res);
}
@@ -208,6 +212,15 @@ public class SysDictController {
res = sysDictService.queryAllDictItemsByCut(cut);
return Result.OK(res);
}
@ApiOperation(value = "更新浏览器内保存的数据字典数据", notes = "更新浏览器内保存的数据字典数据")
@RequestMapping(value = "/login", method = RequestMethod.POST)
private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
// 获取数据字典
JSONObject obj = new JSONObject();
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
result.setResult(obj);
return result;
}
/**
* 获取字典数据
@@ -1,6 +1,7 @@
package com.jero.modules.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.system.entity.SysCategory;
import com.jero.modules.system.model.TreeSelectModel;
import org.apache.ibatis.annotations.Param;
@@ -17,7 +18,9 @@ import java.util.Map;
* @Version: V1.0
*/
public interface SysCategoryMapper extends BaseMapper<SysCategory> {
IPage<SysCategory> queryPageList(IPage page, @Param("params") Map<String,Object> params);
/**
* 根据父级ID查询树节点数据
* @param pid
@@ -4,18 +4,35 @@
<select id="queryListByPid" parameterType="Object" resultType="com.jero.modules.system.model.TreeSelectModel">
select code,
name as "title",
id as "key",
(case when has_child = '1' then 0 else 1 end) as isLeaf,
pid as parentId
from sys_category
where pid = #{pid}
<if test="query!= null">
<foreach collection="query.entrySet()" item="value" index="key" >
and ${key} = #{value}
</foreach>
</if>
name as "title",
id as "key",
(case when has_child = '1' then 0 else 1 end) as isLeaf,
pid as parentId
from sys_category
where pid = #{pid}
<if test="query!= null">
<foreach collection="query.entrySet()" item="value" index="key" >
and ${key} = #{value}
</foreach>
</if>
</select>
<select id="queryPageList" resultType="com.jero.modules.system.entity.SysCategory">
select create_by,create_time,sys_org_code,update_by,update_time,attribute_type,code,
del_flag,description,en_name,has_child,id,is_read_only,is_tag_dict,item_value,name,pid,sys_dict_id
from sys_category
where is_tag_dict=1 and sys_dict_id=#{params.sys_dict_id}
<!--搜索条件:标签名称包含%,单独搜索-->
<choose>
<when test='params.name != null and params.name != "" and params.name.contains("%")'>
and name like '%1%%' escape '1'
</when>
<otherwise>
and name like concat('%',#{params.name},'%')
</otherwise>
</choose>
order by create_time desc
</select>
</mapper>
@@ -4,16 +4,16 @@
<!-- 通过字典code获取字典数据 -->
<select id="queryDictItemsByCode" parameterType="String" resultType="com.jero.common.system.vo.DictModel">
select s.item_value as "value",s.item_text as "text" from sys_dict_item s
where dict_id = (select id from sys_dict where dict_code = #{code})
order by s.sort_order asc
select s.item_value as "value",s.item_text as "text" from sys_dict_item s
where dict_id = (select id from sys_dict where dict_code = #{code})
order by s.sort_order asc
</select>
<!-- 通过字典code获取字典数据 -->
<select id="queryDictTextByKey" parameterType="String" resultType="String">
select s.item_text from sys_dict_item s
where s.dict_id = (select id from sys_dict where dict_code = #{code})
and s.item_value = #{key}
select s.item_text from sys_dict_item s
where s.dict_id = (select id from sys_dict where dict_code = #{code})
and s.item_value = #{key}
</select>
<!-- 通过字典code获取字典数据 -->
@@ -25,20 +25,20 @@
<!--通过查询指定table的 text code 获取字典-->
<select id="queryTableDictItemsByCode" parameterType="String" resultType="com.jero.common.system.vo.DictModel">
select ${text} as "text",${code} as "value" from ${table}
select ${text} as "text",${code} as "value" from ${table}
</select>
<!--通过查询指定table的 text code 获取字典(指定查询条件)-->
<select id="queryTableDictItemsByCodeAndFilter" parameterType="String" resultType="com.jero.common.system.vo.DictModel">
select ${text} as "text",${code} as "value" from ${table}
select ${text} as "text",${code} as "value" from ${table}
<if test="filterSql != null and filterSql != ''">
where ${filterSql}
</if>
</select>
<!--通过查询指定table的 text code key 获取字典值-->
<select id="queryTableDictTextByKey" parameterType="String" resultType="String">
select distinct ${text} as "text" from ${table} where ${code}= #{key}
select distinct ${text} as "text" from ${table} where ${code}= #{key}
</select>
<!--通过查询指定table的 text code key 获取字典值,包含value-->
@@ -53,66 +53,66 @@
<select id="duplicateCheckCountSql" resultType="Long" parameterType="com.jero.modules.system.model.DuplicateCheckVo">
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} and id &lt;&gt; #{dataId}
</select>
<!-- 重复校验 sql语句 -->
<select id="duplicateCheckCountSqlNoDataId" resultType="Long" parameterType="com.jero.modules.system.model.DuplicateCheckVo">
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal}
</select>
<!-- 查询部门信息 作为字典数据 -->
<select id="queryAllDepartBackDictModel" resultType="com.jero.common.system.vo.DictModel">
select id as "value",depart_name as "text" from sys_depart where del_flag = '0'
</select>
<!-- 查询用户信息 作为字典数据 -->
<!-- 查询用户信息 作为字典数据 -->
<select id="queryAllUserBackDictModel" resultType="com.jero.common.system.vo.DictModel">
select username as "value",realname as "text" from sys_user where del_flag = '0'
</select>
<!--通过查询指定table的 text code 获取字典数据,且支持关键字查询 -->
<select id="queryTableDictItems" parameterType="String" resultType="com.jero.common.system.vo.DictModel">
select ${text} as "text",${code} as "value" from ${table} where ${text} like #{keyword}
</select>
<!-- 根据表名、显示字段名、存储字段名、父ID查询树 -->
<select id="queryTreeList" parameterType="Object" resultType="com.jero.modules.system.model.TreeSelectModel">
select ${text} as "title",
${code} as "key",
<if test="hasChildField != null and hasChildField != ''">
(case when ${hasChildField} = '1' then 0 else 1 end) as isLeaf,
</if>
${pidField} as parentId
from ${table}
where
<choose>
<when test="pid != null and pid != ''">
${pidField} = #{pid}
</when>
<otherwise>
(${pidField} = '' OR ${pidField} IS NULL)
</otherwise>
</choose>
<if test="query!= null">
and ${text} like concat(concat('%',#{query}),'%')
</if>
${code} as "key",
<if test="hasChildField != null and hasChildField != ''">
(case when ${hasChildField} = '1' then 0 else 1 end) as isLeaf,
</if>
${pidField} as parentId
from ${table}
where
<choose>
<when test="pid != null and pid != ''">
${pidField} = #{pid}
</when>
<otherwise>
(${pidField} = '' OR ${pidField} IS NULL)
</otherwise>
</choose>
<if test="query!= null">
and ${text} like concat(concat('%',#{query}),'%')
</if>
</select>
<!-- 根据表名、显示字段名、存储字段名、父ID查询树 -->
<select id="queryTreeDataByKeyword" parameterType="Object" resultType="com.jero.modules.system.model.TreeSelectModel">
select ${text} as "title",
${code} as "key",
${pidField} as parentId
${code} as "key",
${pidField} as parentId
from ${table}
</select>
<!-- 根据表名、显示字段名、存储字段名、自身ID查询 -->
<select id="queryTreeDataItemById" parameterType="Object" resultType="com.jero.modules.system.model.TreeSelectModel">
select ${text} as "title",
${code} as "key",
${pidField} as parentId
${code} as "key",
${pidField} as parentId
from ${table}
where
id = #{id}
id = #{id}
</select>
<!-- 分页查询字典表数据 -->
@@ -136,7 +136,8 @@
from sys_dict as d
left join sys_dict_item as i on d.attribute_type=i.item_value
where i.dict_id="1494570247913512962" and d.del_flag=0 and d.is_tag_dict=1
<choose>
<!--切换数据成英文-->
<!--<choose>
<when test="params.dictName != null and params.dictName != ''">
<if test='params.cut="cn"'>
and d.dict_name like concat('%',#{params.dictName},'%')
@@ -146,7 +147,19 @@
and d.dict_en_name like concat('%',#{params.dictName},'%')
</if>
</when>
</choose>-->
<!--搜索条件:标签名称包含%,单独搜索-->
<choose>
<when test='params.dictName != null and params.dictName != "" and params.dictName.contains("%")'>
and dict_name like '%1%%' escape '1'
</when>
<otherwise>
and dict_name like concat('%',#{params.dictName},'%')
</otherwise>
</choose>
order by d.create_time desc
</select>
</mapper>
@@ -1,5 +1,6 @@
package com.jero.modules.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.system.entity.SysCategory;
@@ -59,12 +60,8 @@ public interface ISysCategoryService extends IService<SysCategory> {
*/
void deleteSysCategory(String ids);
/**通过字典id查询
*
* @param sysDictId
* @return
*/
List<SysCategory> queryBySysDictId(String sysDictId);
IPage<SysCategory> queryPageList(Map<String, Object> params);
/**
* 获取树形结构
@@ -72,8 +69,6 @@ public interface ISysCategoryService extends IService<SysCategory> {
*/
List<SysCategoryTreeVO> getSysCategoryTree();
List<SysCategory> queryBySysName(String sysDictId);
/**
* 修改delFlag
* @param delFlag
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.FillRuleConstant;
@@ -18,6 +20,7 @@ import com.jero.modules.system.model.TreeSelectModel;
import com.jero.modules.system.service.ISysCategoryService;
import com.jero.modules.system.util.TreeUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -34,6 +37,8 @@ import java.util.Map;
*/
@Service
public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCategory> implements ISysCategoryService {
@Autowired
SysCategoryMapper sysCategoryMapper;
@Override
public void addSysCategory(SysCategory sysCategory) {
@@ -211,22 +216,25 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
/**通过字典id查询
*
* @param sysDictId
* @param params
* @return
*/
@Override
public List<SysCategory> queryBySysDictId(String sysDictId) {
QueryWrapper<SysCategory> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("sys_dict_id",sysDictId).eq("del_flag", CommonConstant.DEL_FLAG_0);
return list(queryWrapper);
public IPage<SysCategory> queryPageList(Map<String, Object> params) {
Integer pageNo = Integer.parseInt(params.get("pageNo").toString());
Integer pageSize = Integer.parseInt(params.get("pageSize").toString());
IPage page = new Page(pageNo, pageSize);
IPage<SysCategory> result = sysCategoryMapper.queryPageList(page, params);
return result;
}
/**搜索条件*/
/**搜索条件*//*
@Override
public List<SysCategory> queryBySysName(String sysName) {
QueryWrapper<SysCategory> queryWrapper=new QueryWrapper<>();
queryWrapper.like("name",sysName).eq("del_flag", CommonConstant.DEL_FLAG_0);
return list(queryWrapper);
}
}*/
@Override
public List<SysCategoryTreeVO> getSysCategoryTree() {
try {
@@ -210,21 +210,21 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
}
}
/**
* 根据字典类型id删除关联表中其对应的数据
*/
@Override
public boolean deleteByDictId(SysDict sysDict) {
sysDict.setDelFlag(CommonConstant.DEL_FLAG_1);
return this.updateById(sysDict);
}
/**
* 根据字典类型id删除关联表中其对应的数据
*/
@Override
public boolean deleteByDictId(SysDict sysDict) {
sysDict.setDelFlag(CommonConstant.DEL_FLAG_1);
return this.updateById(sysDict);
}
@Override
@Transactional
public Integer saveMain(SysDict sysDict, List<SysDictItem> sysDictItemList) {
@Override
@Transactional
public Integer saveMain(SysDict sysDict, List<SysDictItem> sysDictItemList) {
int insert=0;
try{
insert = sysDictMapper.insert(sysDict);
try{
insert = sysDictMapper.insert(sysDict);
if (sysDictItemList != null) {
for (SysDictItem entity : sysDictItemList) {
entity.setDictId(sysDict.getId());
@@ -236,7 +236,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
return insert;
}
return insert;
}
}
@Override
public List<DictModel> queryAllDepartBackDictModel() {
@@ -255,7 +255,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
@Override
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String keyword, int pageSize) {
Page<DictModel> page = new Page<DictModel>(1, pageSize);
Page<DictModel> page = new Page<DictModel>(1, pageSize);
IPage<DictModel> pageList = baseMapper.queryTableDictItems(page, table, text, code, "%"+keyword+"%");
return pageList.getRecords();
}
@@ -406,7 +406,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
Integer pageSize = Integer.parseInt(params.get("pageSize").toString());
IPage page = new Page(pageNo, pageSize);
IPage<SysDict> result = sysDictMapper.queryPageList(page, params);
List<SysDict> records = result.getRecords();
/*List<SysDict> records = result.getRecords();
String cut = (String) params.get("cut");
//中英切换-字典名称+属性类型列
if(CutEnum.EN.getValue().equals(cut)){
@@ -414,7 +414,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
data.setDictName(data.getDictEnName());
data.setAttributeTypeName(data.getAttributeTypeEnName());
}
}
}*/
return result;
}
}
@@ -41,18 +41,31 @@
where f.cgform_head_id="48308196e7b04761b533dc31bc899707"
and f.is_delete=0
and i.dict_id=1493098515761917954
<choose>
<when test="params.dbFieldTxt != null and params.dbFieldTxt != ''">
<if test='params.cut="cn"'>
<!--切换数据成英文-->
<!-- <choose>
<when test="params.dbFieldTxt != null and params.dbFieldTxt != ''">
<if test='params.cut="cn"'>
and f.db_field_txt like concat('%',#{params.dbFieldTxt},'%')
</if>
<if test='params.cut="en"'>
and f.db_field_en_name like concat('%',#{params.dbFieldTxt},'%')
</if>
</when>
</choose>-->
<if test="params.dbFieldTxt != null and params.dbFieldTxt != ''">
<!--搜索条件:标签名称包含%,单独搜索-->
<choose>
<when test='params.dbFieldTxt != null and params.dbFieldTxt != "" and params.dbFieldTxt.contains("%")'>
and f.db_field_txt like '%1%%' escape '1'
</when>
<otherwise>
and f.db_field_txt like concat('%',#{params.dbFieldTxt},'%')
</if>
<if test='params.cut="en"'>
and f.db_field_en_name like concat('%',#{params.dbFieldTxt},'%')
</if>
</when>
</choose>
</otherwise>
</choose>
</if>
<if test="params.showArea != null and params.showArea != '' ">
and f.show_area like concat('%',#{params.showArea},'%')
</if>
@@ -145,14 +145,14 @@ public class OnlCgformAreaServiceImpl extends ServiceImpl<OnlCgformAreaMapper, O
Integer pageSize = Integer.parseInt(params.get("pageSize").toString());
IPage page = new Page(pageNo, pageSize);
IPage<OnlCgformArea> result = onlCgformAreaMapper.queryPageList(page, params);
List<OnlCgformArea> records = result.getRecords();
/*List<OnlCgformArea> records = result.getRecords();
String cut = (String) params.get("cut");
//中英切换-所属模块
if(CutEnum.EN.getValue().equals(cut)){
for(OnlCgformArea data:records){
data.setIsModelName(data.getEnName());
}
}
}*/
return result;
}
}
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.system.vo.LoginUser;
import com.jero.generater.modules.online.cgform.service.impl.OnlCgformFieldServiceImpl;
import com.jero.modules.document.enums.FieldTypeEnum;
@@ -182,7 +181,8 @@ public class OnlCgformTagServiceImpl extends ServiceImpl<OnlCgformTagMapper, Onl
Integer pageSize = Integer.parseInt(params.get("pageSize").toString());
IPage page = new Page(pageNo, pageSize);
IPage<OnlCgformTag> result = onlCgformTagMapper.queryPageList(page, params);
List<OnlCgformTag> records = result.getRecords();
//params.get("dbFieldTxt").toString().contains("%");
/*List<OnlCgformTag> records = result.getRecords();
String cut = (String) params.get("cut");
//中英切换-属性类型+展示区域列
if(CutEnum.EN.getValue().equals(cut)){
@@ -190,7 +190,7 @@ public class OnlCgformTagServiceImpl extends ServiceImpl<OnlCgformTagMapper, Onl
data.setFieldShowTypeName(data.getFieldShowTypeEnName());
data.setShowAreaName(data.getShowAreaEnName());
}
}
}*/
return result;
}