diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/controller/SysConfigController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/controller/SysConfigController.java new file mode 100644 index 000000000..de2175d71 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/controller/SysConfigController.java @@ -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("成功"); + } +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/entity/SysConfig.java b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/entity/SysConfig.java new file mode 100644 index 000000000..401d05ac7 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/entity/SysConfig.java @@ -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; + + } + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/mapper/SysConfigMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/mapper/SysConfigMapper.java new file mode 100644 index 000000000..1ada84860 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/mapper/SysConfigMapper.java @@ -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 { + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/mapper/xml/SysConfigMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/mapper/xml/SysConfigMapper.xml new file mode 100644 index 000000000..9e0ccc464 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/mapper/xml/SysConfigMapper.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + update sys_dept set ancestors = + + when #{item.deptId} then #{item.ancestors} + + where dept_id in + + #{item.deptId} + + + + + update sys_dept set status = '0' where dept_id in + + #{deptId} + + + + + \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/service/SysConfigService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/service/SysConfigService.java new file mode 100644 index 000000000..5626489d9 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/service/SysConfigService.java @@ -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 { + void saveVo(SysConfig sysConfig); + void updateByIdVo(SysConfig sysConfig); + void removeByIdVo(Long id); + String getValueByKey(String keyStr); + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/service/impl/SysConfigServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/service/impl/SysConfigServiceImpl.java new file mode 100644 index 000000000..6244c0387 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/system/config/service/impl/SysConfigServiceImpl.java @@ -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 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 queryWrapper =new LambdaQueryWrapper<>(); + queryWrapper.eq(SysConfig::getKeyStr,keyStr); + SysConfig one = this.getOne(queryWrapper); + if (ObjectUtils.isNotEmpty(one)){ + return one.getValueStr(); + } + return null; + } +} + diff --git a/fuintBackend/fuint-framework/src/main/java/com/fuint/framework/shiroConfig/ShiroConfig.java b/fuintBackend/fuint-framework/src/main/java/com/fuint/framework/shiroConfig/ShiroConfig.java index 9bc72f5c6..5bbbab166 100644 --- a/fuintBackend/fuint-framework/src/main/java/com/fuint/framework/shiroConfig/ShiroConfig.java +++ b/fuintBackend/fuint-framework/src/main/java/com/fuint/framework/shiroConfig/ShiroConfig.java @@ -38,6 +38,7 @@ public class ShiroConfig { filterMap.put("/static/**","anon"); filterMap.put("/**","authc"); filter.setFilterChainDefinitionMap(filterMap); + filter.setLoginUrl("/login"); return filter; }