处理
This commit is contained in:
parent
e89ddfecab
commit
91448e7e2a
@ -0,0 +1,105 @@
|
||||
package com.fuint.system.config.controller;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.api.ApiController;
|
||||
import com.baomidou.mybatisplus.extension.api.R;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.framework.web.BaseController;
|
||||
import com.fuint.framework.web.ResponseObject;
|
||||
import com.fuint.system.config.entity.SysConfig;
|
||||
import com.fuint.system.config.service.SysConfigService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (SysConfig)表控制层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-16 17:18:59
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("sysConfig")
|
||||
public class SysConfigController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Resource
|
||||
private SysConfigService sysConfigService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
*
|
||||
* @param sysConfig 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@GetMapping
|
||||
public ResponseObject selectAll(SysConfig sysConfig,
|
||||
@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) {
|
||||
Page page =new Page(pageNum,pageSize);
|
||||
return getSuccessResult(this.sysConfigService.page(page, new QueryWrapper<>(sysConfig)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
public ResponseObject selectOne(@PathVariable Serializable id) {
|
||||
return getSuccessResult(this.sysConfigService.getById(id));
|
||||
}
|
||||
/**
|
||||
* 通过主键查询单条数据
|
||||
*
|
||||
* @param key 主键
|
||||
* @return 单条数据
|
||||
*/
|
||||
@GetMapping("/getByKey/{key}")
|
||||
public ResponseObject getByKey(@PathVariable String key) {
|
||||
return getSuccessResult(this.sysConfigService.getValueByKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param sysConfig 实体对象
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping
|
||||
public ResponseObject insert(@RequestBody SysConfig sysConfig) {
|
||||
this.sysConfigService.saveVo(sysConfig);
|
||||
return getSuccessResult("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param sysConfig 实体对象
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PutMapping
|
||||
public ResponseObject update(@RequestBody SysConfig sysConfig) {
|
||||
this.sysConfigService.updateByIdVo(sysConfig);
|
||||
return getSuccessResult("成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键结合
|
||||
* @return 删除结果
|
||||
*/
|
||||
@DeleteMapping
|
||||
public ResponseObject delete(@RequestParam("id") Long id) {
|
||||
this.sysConfigService.removeByIdVo(id);
|
||||
return getSuccessResult("成功");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.fuint.system.config.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fuint.repository.model.base.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (SysConfig)表实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-16 17:18:59
|
||||
*/
|
||||
@Data
|
||||
public class SysConfig extends BaseEntity {
|
||||
//主键
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
//key值
|
||||
private String keyStr;
|
||||
//value值
|
||||
private String valueStr;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.fuint.system.config.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.system.config.entity.SysConfig;
|
||||
|
||||
/**
|
||||
* (SysConfig)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-16 17:18:59
|
||||
*/
|
||||
public interface SysConfigMapper extends BaseMapper<SysConfig> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.system.dept.mapper.SysDeptMapper">
|
||||
|
||||
|
||||
<select id="selectDeptList" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select *
|
||||
from sys_dept d
|
||||
where 1=1
|
||||
<if test="dept.deptId != null and dept.deptId != 0">
|
||||
AND dept_id = #{dept.deptId}
|
||||
</if>
|
||||
<if test="dept.parentId != null and dept.parentId != 0">
|
||||
AND parent_id = #{dept.parentId}
|
||||
</if>
|
||||
<if test="dept.deptName != null and dept.deptName != ''">
|
||||
AND dept_name like concat('%', #{dept.deptName}, '%')
|
||||
</if>
|
||||
<if test="dept.status != null and dept.status != ''">
|
||||
AND status = #{dept.status}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
<if test="ownDeptStr != null and ownDeptStr!=''">
|
||||
AND ancestors like concat (#{ownDeptStr},'%')
|
||||
</if>
|
||||
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptListByRoleId" resultType="Long">
|
||||
select d.dept_id
|
||||
from sys_dept d
|
||||
left join sys_role_dept rd on d.dept_id = rd.dept_id
|
||||
where rd.role_id = #{roleId}
|
||||
<if test="deptCheckStrictly">
|
||||
and d.dept_id not in (select d.parent_id from sys_dept d inner join sys_role_dept rd on d.dept_id = rd.dept_id and rd.role_id = #{roleId})
|
||||
</if>
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptById" parameterType="Long" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select d.*,
|
||||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
||||
from sys_dept d
|
||||
where d.dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
||||
select count(1) from t_account where dept_id = #{deptId}
|
||||
</select>
|
||||
|
||||
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
|
||||
select count(1) from sys_dept
|
||||
where parent_id = #{deptId} limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectChildrenDeptById" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select * from sys_dept where find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
|
||||
select count(*) from sys_dept where status = 0 and find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
<select id="checkDeptNameUnique" resultType="com.fuint.system.dept.entity.SysDept">
|
||||
select *
|
||||
from sys_dept
|
||||
where dept_name=#{deptName} and parent_id = #{parentId} limit 1
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<update id="updateDeptChildren" parameterType="java.util.List">
|
||||
update sys_dept set ancestors =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator=" " open="case dept_id" close="end">
|
||||
when #{item.deptId} then #{item.ancestors}
|
||||
</foreach>
|
||||
where dept_id in
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
separator="," open="(" close=")">
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateDeptStatusNormal" parameterType="Long">
|
||||
update sys_dept set status = '0' where dept_id in
|
||||
<foreach collection="array" item="deptId" open="(" separator="," close=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,19 @@
|
||||
package com.fuint.system.config.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.system.config.entity.SysConfig;
|
||||
|
||||
/**
|
||||
* (SysConfig)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-16 17:18:59
|
||||
*/
|
||||
public interface SysConfigService extends IService<SysConfig> {
|
||||
void saveVo(SysConfig sysConfig);
|
||||
void updateByIdVo(SysConfig sysConfig);
|
||||
void removeByIdVo(Long id);
|
||||
String getValueByKey(String keyStr);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.fuint.system.config.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.common.util.RedisUtil;
|
||||
import com.fuint.system.config.mapper.SysConfigMapper;
|
||||
import com.fuint.system.config.entity.SysConfig;
|
||||
import com.fuint.system.config.service.SysConfigService;
|
||||
import com.fuint.utils.ObjectUtil;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* (SysConfig)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-10-16 17:18:59
|
||||
*/
|
||||
@Service("sysConfigService")
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
|
||||
|
||||
public static String configRedisKey = "sys:config:";
|
||||
|
||||
@Override
|
||||
public void saveVo(SysConfig sysConfig) {
|
||||
RedisUtil.set(configRedisKey+sysConfig.getKeyStr(),sysConfig.getValueStr());
|
||||
this.save(sysConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByIdVo(SysConfig sysConfig) {
|
||||
RedisUtil.set(configRedisKey+sysConfig.getKeyStr(),sysConfig.getValueStr());
|
||||
this.updateById(sysConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByIdVo(Long id) {
|
||||
SysConfig sysConfig = this.getById(id);
|
||||
RedisUtil.remove(configRedisKey+sysConfig.getKeyStr());
|
||||
this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValueByKey(String keyStr) {
|
||||
if (RedisUtil.hasKey(configRedisKey+keyStr)){
|
||||
return RedisUtil.get(configRedisKey+keyStr);
|
||||
}
|
||||
LambdaQueryWrapper<SysConfig> queryWrapper =new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysConfig::getKeyStr,keyStr);
|
||||
SysConfig one = this.getOne(queryWrapper);
|
||||
if (ObjectUtils.isNotEmpty(one)){
|
||||
return one.getValueStr();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ public class ShiroConfig {
|
||||
filterMap.put("/static/**","anon");
|
||||
filterMap.put("/**","authc");
|
||||
filter.setFilterChainDefinitionMap(filterMap);
|
||||
filter.setLoginUrl("/login");
|
||||
return filter;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user