diff --git a/bonus-modules/bonus-material-bigscreen/pom.xml b/bonus-modules/bonus-material-bigscreen/pom.xml new file mode 100644 index 00000000..bdc8958b --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/pom.xml @@ -0,0 +1,116 @@ + + + + com.bonus + bonus-modules + 24.8.0 + + 4.0.0 + + bonus-modules-material-bigscreen + + + bonus-modules-material-bigscreen仓储大屏模块 + + + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + ${jasypt-spring-boot-starter.version} + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + com.mysql + mysql-connector-j + + + + + com.bonus + bonus-common-datasource + + + + + com.bonus + bonus-common-datascope + + + + + com.bonus + bonus-common-log + + + + + com.bonus + bonus-common-swagger + + + com.google.guava + guava + 30.0-jre + compile + + + + org.springframework.boot + spring-boot-starter-mail + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/BonusMaterialBigScreenApplication.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/BonusMaterialBigScreenApplication.java new file mode 100644 index 00000000..da26eaef --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/BonusMaterialBigScreenApplication.java @@ -0,0 +1,35 @@ +package com.bonus.material; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import com.bonus.common.security.annotation.EnableCustomConfig; +import com.bonus.common.security.annotation.EnableRyFeignClients; +import com.bonus.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + +/** + * 系统模块 + * + * @author bonus + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) +public class BonusMaterialBigScreenApplication +{ + public static void main(String[] args) + { + SpringApplication.run(BonusMaterialBigScreenApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 仓储大屏模块启动成功 ლ(´ڡ`ლ)゙ \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/controller/BmConfigController.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/controller/BmConfigController.java new file mode 100644 index 00000000..63786493 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/controller/BmConfigController.java @@ -0,0 +1,169 @@ +package com.bonus.material.bigscreen.controller; + +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; +import com.bonus.common.security.annotation.RequiresPermissions; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.bigscreen.domain.BmConfig; +import com.bonus.material.bigscreen.service.IBmConfigService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * 参数配置 信息操作处理 + * + * @author bonus + */ +@RestController +@RequestMapping("/config") +@Slf4j +public class BmConfigController extends BaseController { + + @Autowired + private IBmConfigService bmConfigService; + + /** + * 获取参数配置列表 + */ + + +// @ApiOperation("获取参数配置列表") + @RequiresPermissions("material:config:list") + @GetMapping("/list") + @SysLog(title = "参数配置", businessType = OperaType.QUERY,logType = 0,module = "系统管理->参数配置") +// @ApiResponses(value = { +// @ApiResponse(code = 200, message = "成功", response = TableDataInfo.class), +// @ApiResponse(code = 400, message = "无效的ID"), +// @ApiResponse(code = 404, message = "未找到用户") +// }) + public TableDataInfo list(BmConfig config) { + try{ + startPage(); + List list = bmConfigService.selectConfigList(config); + return getDataTable(list); + }catch (Exception e){ + log.error(e.toString(),e); + } + return getDataTableError(new ArrayList()); + } + + @RequiresPermissions("material:config:export") + @PostMapping("/export") + @SysLog(title = "参数配置", businessType = OperaType.EXPORT,logType = 0,module = "系统管理->参数配置") + public void export(HttpServletResponse response, BmConfig config) { + try{ + List list = bmConfigService.selectConfigList(config); + ExcelUtil util = new ExcelUtil(BmConfig.class); + util.exportExcel(response, list, "参数数据"); + }catch (Exception e){ + ExcelUtil util = new ExcelUtil(BmConfig.class); + util.exportExcel(response, new ArrayList(), "参数数据"); + log.error(e.toString(),e); + } + } + + /** + * 根据参数编号获取详细信息 + */ + @GetMapping(value = "/{configId}") + public AjaxResult getInfo(@PathVariable Long configId) { + try{ + return success(bmConfigService.selectConfigById(configId)); + }catch (Exception e){ + log.error(e.toString(),e); + return error("系统异常"); + } + } + + /** + * 根据参数键名查询参数值 + */ + @GetMapping(value = "/configKey/{configKey}") + public AjaxResult getConfigKey(@PathVariable String configKey) { + try{ + return success(bmConfigService.selectConfigByKey(configKey)); + }catch (Exception e){ + log.error(e.toString(),e); + return error("系统异常"); + } + } + + /** + * 新增参数配置 + */ + @RequiresPermissions("material:config:add") + @SysLog(title = "参数配置", businessType = OperaType.INSERT,logType = 0,module = "系统管理->参数配置") + @PostMapping + public AjaxResult add(@Validated @RequestBody BmConfig config) { + try{ + if (!bmConfigService.checkConfigKeyUnique(config)) { + return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setCreateBy(SecurityUtils.getUsername()); + return toAjax(bmConfigService.insertConfig(config)); + }catch (Exception e){ + log.error(e.toString(),e); + return error("系统异常"); + } + } + + /** + * 修改参数配置 + */ + @RequiresPermissions("material:config:edit") + @PutMapping + @SysLog(title = "参数配置", businessType = OperaType.UPDATE,logType = 0,module = "系统管理->参数配置") + public AjaxResult edit(@Validated @RequestBody BmConfig config) { + try{ + if (!bmConfigService.checkConfigKeyUnique(config)) { + return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); + } + config.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(bmConfigService.updateConfig(config)); + }catch (Exception e){ + log.error(e.toString(),e); + return error("系统异常"); + } + } + + /** + * 删除参数配置 + */ + @RequiresPermissions("material:config:remove") + @SysLog(title = "参数配置", businessType = OperaType.DELETE,logType = 0,module = "系统管理->参数配置") + @DeleteMapping("/{configIds}") + public AjaxResult remove(@PathVariable Long[] configIds) { + try{ + bmConfigService.deleteConfigByIds(configIds); + return success(); + }catch (Exception e){ + log.error(e.toString(),e); + return error("系统异常"); + } + } + + /** + * 刷新参数缓存 + */ + @RequiresPermissions("material:config:remove") + @DeleteMapping("/refreshCache") + @SysLog(title = "参数配置", businessType = OperaType.FLASH,logType = 0,module = "系统管理->参数配置",details = "刷新参数缓存") + public AjaxResult refreshCache() { + try{ + bmConfigService.resetConfigCache(); + return success(); + }catch (Exception e){ + log.error(e.toString(),e); + return error("系统异常"); + } + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/BmConfig.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/BmConfig.java new file mode 100644 index 00000000..723e6cd0 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/BmConfig.java @@ -0,0 +1,117 @@ +package com.bonus.material.bigscreen.domain; + +import cn.hutool.core.annotation.Alias; +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.annotation.Excel.ColumnType; +import com.bonus.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * 参数配置表 bm_config + * + * @author bonus + */ +public class BmConfig extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + //用于excel导出的序号一列,不需要业务逻辑处理 + @Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT) + int sequence; + + /** 参数主键 */ + @Excel(name = "参数主键", cellType = ColumnType.NUMERIC) + private Long configId; + + /** 参数名称 */ + @Excel(name = "参数名称") + private String configName; + + /** 参数键名 */ + @Excel(name = "参数键名") + private String configKey; + + /** 参数键值 */ + @Excel(name = "参数键值") + private String configValue; + + /** 系统内置(Y是 N否) */ + @Excel(name = "系统内置", readConverterExp = "Y=是,N=否") + private String configType; + + public Long getConfigId() + { + return configId; + } + + public void setConfigId(Long configId) + { + this.configId = configId; + } + + @NotBlank(message = "参数名称不能为空") + @Size(min = 0, max = 100, message = "参数名称不能超过100个字符") + public String getConfigName() + { + return configName; + } + + public void setConfigName(String configName) + { + this.configName = configName; + } + + @NotBlank(message = "参数键名长度不能为空") + @Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符") + public String getConfigKey() + { + return configKey; + } + + public void setConfigKey(String configKey) + { + this.configKey = configKey; + } + + @NotBlank(message = "参数键值不能为空") + @Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符") + public String getConfigValue() + { + return configValue; + } + + public void setConfigValue(String configValue) + { + this.configValue = configValue; + } + + public String getConfigType() + { + return configType; + } + + public void setConfigType(String configType) + { + this.configType = configType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("configId", getConfigId()) + .append("configName", getConfigName()) + .append("configKey", getConfigKey()) + .append("configValue", getConfigValue()) + .append("configType", getConfigType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/MetaVo.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/MetaVo.java new file mode 100644 index 00000000..8116d7ab --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/MetaVo.java @@ -0,0 +1,106 @@ +package com.bonus.material.bigscreen.domain.vo; + +import com.bonus.common.core.utils.StringUtils; + +/** + * 路由显示信息 + * + * @author bonus + */ +public class MetaVo +{ + /** + * 设置该路由在侧边栏和面包屑中展示的名字 + */ + private String title; + + /** + * 设置该路由的图标,对应路径src/assets/icons/svg + */ + private String icon; + + /** + * 设置为true,则不会被 缓存 + */ + private boolean noCache; + + /** + * 内链地址(http(s)://开头) + */ + private String link; + + public MetaVo() + { + } + + public MetaVo(String title, String icon) + { + this.title = title; + this.icon = icon; + } + + public MetaVo(String title, String icon, boolean noCache) + { + this.title = title; + this.icon = icon; + this.noCache = noCache; + } + + public MetaVo(String title, String icon, String link) + { + this.title = title; + this.icon = icon; + this.link = link; + } + + public MetaVo(String title, String icon, boolean noCache, String link) + { + this.title = title; + this.icon = icon; + this.noCache = noCache; + if (StringUtils.ishttp(link)) + { + this.link = link; + } + } + + public boolean isNoCache() + { + return noCache; + } + + public void setNoCache(boolean noCache) + { + this.noCache = noCache; + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } + + public String getIcon() + { + return icon; + } + + public void setIcon(String icon) + { + this.icon = icon; + } + + public String getLink() + { + return link; + } + + public void setLink(String link) + { + this.link = link; + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/RouterVo.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/RouterVo.java new file mode 100644 index 00000000..2e82a531 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/RouterVo.java @@ -0,0 +1,149 @@ +package com.bonus.material.bigscreen.domain.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.util.List; + +/** + * 路由配置信息 + * + * @author bonus + */ +@JsonInclude(JsonInclude.Include.NON_EMPTY) +public class RouterVo +{ + /** + * 路由名字 + */ + private String name; + + /** + * 路由地址 + */ + private String path; + + /** + * 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现 + */ + private boolean hidden; + + /** + * 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击 + */ + private String redirect; + + /** + * 组件地址 + */ + private String component; + + /** + * 路由参数:如 {"id": 1, "name": "ry"} + */ + private String query; + + /** + * 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面 + */ + private Boolean alwaysShow; + + /** + * 其他元素 + */ + private MetaVo meta; + + /** + * 子路由 + */ + private List children; + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + public boolean getHidden() + { + return hidden; + } + + public void setHidden(boolean hidden) + { + this.hidden = hidden; + } + + public String getRedirect() + { + return redirect; + } + + public void setRedirect(String redirect) + { + this.redirect = redirect; + } + + public String getComponent() + { + return component; + } + + public void setComponent(String component) + { + this.component = component; + } + + public String getQuery() + { + return query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public Boolean getAlwaysShow() + { + return alwaysShow; + } + + public void setAlwaysShow(Boolean alwaysShow) + { + this.alwaysShow = alwaysShow; + } + + public MetaVo getMeta() + { + return meta; + } + + public void setMeta(MetaVo meta) + { + this.meta = meta; + } + + public List getChildren() + { + return children; + } + + public void setChildren(List children) + { + this.children = children; + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/TreeSelect.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/TreeSelect.java new file mode 100644 index 00000000..fef9d51d --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/domain/vo/TreeSelect.java @@ -0,0 +1,87 @@ +package com.bonus.material.bigscreen.domain.vo; + +import com.bonus.system.api.domain.SysDept; +import com.bonus.system.api.domain.SysMenu; +import com.fasterxml.jackson.annotation.JsonInclude; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Treeselect树结构实体类 + * + * @author bonus + */ +public class TreeSelect implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 节点ID + */ + private Long id; + + /** + * 节点名称 + */ + private String label; + + private String status; + + + /** + * 子节点 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public TreeSelect() { + + } + + public TreeSelect(SysDept dept) { + this.id = dept.getDeptId(); + this.status = dept.getStatus(); + this.label = dept.getDeptName(); + this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public TreeSelect(SysMenu menu) { + this.id = menu.getMenuId(); + this.label = menu.getMenuName(); + this.status = menu.getStatus(); + this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/mapper/BmConfigMapper.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/mapper/BmConfigMapper.java new file mode 100644 index 00000000..edc31158 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/mapper/BmConfigMapper.java @@ -0,0 +1,76 @@ +package com.bonus.material.bigscreen.mapper; + +import com.bonus.material.bigscreen.domain.BmConfig; +import java.util.List; + +/** + * 参数配置 数据层 + * + * @author bonus + */ +public interface BmConfigMapper +{ + /** + * 查询参数配置信息 + * + * @param config 参数配置信息 + * @return 参数配置信息 + */ + public BmConfig selectConfig(BmConfig config); + + /** + * 通过ID查询配置 + * + * @param configId 参数ID + * @return 参数配置信息 + */ + public BmConfig selectConfigById(Long configId); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(BmConfig config); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数配置信息 + */ + public BmConfig checkConfigKeyUnique(String configKey); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(BmConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(BmConfig config); + + /** + * 删除参数配置 + * + * @param configId 参数ID + * @return 结果 + */ + public int deleteConfigById(Long configId); + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + * @return 结果 + */ + public int deleteConfigByIds(Long[] configIds); +} \ No newline at end of file diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/service/IBmConfigService.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/service/IBmConfigService.java new file mode 100644 index 00000000..7c6a83da --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/service/IBmConfigService.java @@ -0,0 +1,83 @@ +package com.bonus.material.bigscreen.service; + +import com.bonus.material.bigscreen.domain.BmConfig; + +import java.util.List; + +/** + * 参数配置 服务层 + * + * @author bonus + */ +public interface IBmConfigService +{ + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + public BmConfig selectConfigById(Long configId); + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数键名 + * @return 参数键值 + */ + public String selectConfigByKey(String configKey); + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + public List selectConfigList(BmConfig config); + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int insertConfig(BmConfig config); + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + public int updateConfig(BmConfig config); + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + */ + public void deleteConfigByIds(Long[] configIds); + + /** + * 加载参数缓存数据 + */ + public void loadingConfigCache(); + + /** + * 清空参数缓存数据 + */ + public void clearConfigCache(); + + /** + * 重置参数缓存数据 + */ + public void resetConfigCache(); + + /** + * 校验参数键名是否唯一 + * + * @param config 参数信息 + * @return 结果 + */ + public boolean checkConfigKeyUnique(BmConfig config); +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/service/impl/BmConfigServiceImpl.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/service/impl/BmConfigServiceImpl.java new file mode 100644 index 00000000..36c45332 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/bigscreen/service/impl/BmConfigServiceImpl.java @@ -0,0 +1,213 @@ +package com.bonus.material.bigscreen.service.impl; + +import com.bonus.common.core.constant.CacheConstants; +import com.bonus.common.core.constant.UserConstants; +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.text.Convert; +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.redis.service.RedisService; +import com.bonus.material.bigscreen.domain.BmConfig; +import com.bonus.material.bigscreen.mapper.BmConfigMapper; +import com.bonus.material.bigscreen.service.IBmConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; +import java.util.Collection; +import java.util.List; + +/** + * 参数配置 服务层实现 + * + * @author bonus + */ +@Service +public class BmConfigServiceImpl implements IBmConfigService +{ + @Autowired + private BmConfigMapper bmConfigMapper; + + @Autowired + private RedisService redisService; + + /** + * 项目启动时,初始化参数到缓存 + */ + @PostConstruct + public void init() + { + loadingConfigCache(); + } + + /** + * 查询参数配置信息 + * + * @param configId 参数配置ID + * @return 参数配置信息 + */ + @Override + public BmConfig selectConfigById(Long configId) + { + BmConfig config = new BmConfig(); + config.setConfigId(configId); + return bmConfigMapper.selectConfig(config); + } + + /** + * 根据键名查询参数配置信息 + * + * @param configKey 参数key + * @return 参数键值 + */ + @Override + public String selectConfigByKey(String configKey) + { + String configValue = Convert.toStr(redisService.getCacheObject(getCacheKey(configKey))); + if (StringUtils.isNotEmpty(configValue)) + { + return configValue; + } + BmConfig config = new BmConfig(); + config.setConfigKey(configKey); + BmConfig retConfig = bmConfigMapper.selectConfig(config); + if (StringUtils.isNotNull(retConfig)) + { + redisService.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); + return retConfig.getConfigValue(); + } + return StringUtils.EMPTY; + } + + /** + * 查询参数配置列表 + * + * @param config 参数配置信息 + * @return 参数配置集合 + */ + @Override + public List selectConfigList(BmConfig config) + { + return bmConfigMapper.selectConfigList(config); + } + + /** + * 新增参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int insertConfig(BmConfig config) + { + int row = bmConfigMapper.insertConfig(config); + if (row > 0) + { + redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } + + /** + * 修改参数配置 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public int updateConfig(BmConfig config) + { + BmConfig temp = bmConfigMapper.selectConfigById(config.getConfigId()); + if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) + { + redisService.deleteObject(getCacheKey(temp.getConfigKey())); + } + + int row = bmConfigMapper.updateConfig(config); + if (row > 0) + { + redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + return row; + } + + /** + * 批量删除参数信息 + * + * @param configIds 需要删除的参数ID + */ + @Override + public void deleteConfigByIds(Long[] configIds) + { + for (Long configId : configIds) + { + BmConfig config = selectConfigById(configId); + if (StringUtils.equals(UserConstants.YES, config.getConfigType())) + { + throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey())); + } + bmConfigMapper.deleteConfigById(configId); + redisService.deleteObject(getCacheKey(config.getConfigKey())); + } + } + + /** + * 加载参数缓存数据 + */ + @Override + public void loadingConfigCache() + { + List configsList = bmConfigMapper.selectConfigList(new BmConfig()); + for (BmConfig config : configsList) + { + redisService.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue()); + } + } + + /** + * 清空参数缓存数据 + */ + @Override + public void clearConfigCache() + { + Collection keys = redisService.keys(CacheConstants.SYS_CONFIG_KEY + "*"); + redisService.deleteObject(keys); + } + + /** + * 重置参数缓存数据 + */ + @Override + public void resetConfigCache() + { + clearConfigCache(); + loadingConfigCache(); + } + + /** + * 校验参数键名是否唯一 + * + * @param config 参数配置信息 + * @return 结果 + */ + @Override + public boolean checkConfigKeyUnique(BmConfig config) + { + Long configId = StringUtils.isNull(config.getConfigId()) ? -1L : config.getConfigId(); + BmConfig info = bmConfigMapper.checkConfigKeyUnique(config.getConfigKey()); + if (StringUtils.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) + { + return UserConstants.NOT_UNIQUE; + } + return UserConstants.UNIQUE; + } + + /** + * 设置cache key + * + * @param configKey 参数键 + * @return 缓存键key + */ + private String getCacheKey(String configKey) + { + return CacheConstants.SYS_CONFIG_KEY + configKey; + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/constant/BmConfigItems.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/constant/BmConfigItems.java new file mode 100644 index 00000000..748e58a7 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/constant/BmConfigItems.java @@ -0,0 +1,6 @@ +package com.bonus.material.common.constant; + +public class BmConfigItems { + public final String LEASE_AUDIT_ROLE_KEYS = "LeaseAuditRoleKeys"; + +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/constant/MaterialConstants.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/constant/MaterialConstants.java new file mode 100644 index 00000000..8dae6d63 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/constant/MaterialConstants.java @@ -0,0 +1,17 @@ +package com.bonus.material.common.constant; + +/** + * 仓储通用常量信息 + * + * @author bonus + */ +public class MaterialConstants +{ + private MaterialConstants(){} + /** + * UTF-8 字符集 + */ + public static final String UTF8 = "UTF-8"; + + +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/utils/CommonDataPermissionInfo.java b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/utils/CommonDataPermissionInfo.java new file mode 100644 index 00000000..50bbebbc --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/java/com/bonus/material/common/utils/CommonDataPermissionInfo.java @@ -0,0 +1,50 @@ +package com.bonus.material.common.utils; + +import com.bonus.common.core.web.domain.BaseEntity; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.system.api.domain.SysRole; +import com.bonus.system.api.domain.SysUser; +import com.bonus.system.api.model.LoginUser; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class CommonDataPermissionInfo { + + public static BaseEntity backMissionInfo(String dataScope){ + BaseEntity entity = new BaseEntity(); + Set roleIds = new HashSet<>(); + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null) { + SysUser sysUser = loginUser.getSysUser(); + if (sysUser != null) { + Long deptId = sysUser.getDeptId(); + entity.setNewUserId(sysUser.getUserId()); + List roles = sysUser.getRoles(); + if (roles != null) { + entity.setNewdeptId(deptId); + // 如果需要记录多个角色ID,可以使用Set或List + for (SysRole role : roles) { + roleIds.add(role.getRoleId()); + entity.setMissionSource(role.getDataScope()); + // 只在第一次迭代时设置dataScope,且dataScope不为空的情况下 + if (dataScope.isEmpty() && !"".equals(role.getDataScope())) { + entity.setMissionSource(dataScope); + break; + }else if(roles.size()>1){ + entity.setMissionSource(4+""); + } + + // 设置角色ID集合 + entity.setNewrole(roleIds); + } + + } + } + } + + return entity; + + } +} diff --git a/bonus-modules/bonus-material-bigscreen/src/main/resources/banner.txt b/bonus-modules/bonus-material-bigscreen/src/main/resources/banner.txt new file mode 100644 index 00000000..fbd45f53 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/resources/banner.txt @@ -0,0 +1,10 @@ +Spring Boot Version: ${spring-boot.version} +Spring Application Name: ${spring.application.name} + _ _ + (_) | | + _ __ _ _ ___ _ _ _ ______ ___ _ _ ___ | |_ ___ _ __ ___ +| '__|| | | | / _ \ | | | || ||______|/ __|| | | |/ __|| __| / _ \| '_ ` _ \ +| | | |_| || (_) || |_| || | \__ \| |_| |\__ \| |_ | __/| | | | | | +|_| \__,_| \___/ \__, ||_| |___/ \__, ||___/ \__| \___||_| |_| |_| + __/ | __/ | + |___/ |___/ \ No newline at end of file diff --git a/bonus-modules/bonus-material-bigscreen/src/main/resources/bootstrap-sgzb_bns_local.yml b/bonus-modules/bonus-material-bigscreen/src/main/resources/bootstrap-sgzb_bns_local.yml new file mode 100644 index 00000000..9422e3f3 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/resources/bootstrap-sgzb_bns_local.yml @@ -0,0 +1,28 @@ +# Tomcat +server: + port: 18589 + +# Spring +spring: + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 127.0.0.1:8848 + # namespace: sgzb_bns + namespace: sgzb_bns + config: + # 配置中心地址 + server-addr: 127.0.0.1:8848 + # namespace: sgzb_bns + namespace: sgzb_bns + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} + +#加密组件 +jasypt: + encryptor: + password: Encrypt diff --git a/bonus-modules/bonus-material-bigscreen/src/main/resources/bootstrap.yml b/bonus-modules/bonus-material-bigscreen/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..5776d4c5 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/resources/bootstrap.yml @@ -0,0 +1,8 @@ +# Spring +spring: + application: + # 应用名称 + name: bonus-material-bigscreen + profiles: + # 环境配置 + active: sgzb_bns_local diff --git a/bonus-modules/bonus-material-bigscreen/src/main/resources/logback.xml b/bonus-modules/bonus-material-bigscreen/src/main/resources/logback.xml new file mode 100644 index 00000000..9b4ec4d8 --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/resources/logback.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material-bigscreen/src/main/resources/mapper/material/basic/BmConfigMapper.xml b/bonus-modules/bonus-material-bigscreen/src/main/resources/mapper/material/basic/BmConfigMapper.xml new file mode 100644 index 00000000..9f26691a --- /dev/null +++ b/bonus-modules/bonus-material-bigscreen/src/main/resources/mapper/material/basic/BmConfigMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark + from sys_config + + + + + + + and config_id = #{configId} + + + and config_key = #{configKey} + + + + + + + + + + + + + + insert into sys_config ( + config_name, + config_key, + config_value, + config_type, + create_by, + remark, + create_time + )values( + #{configName}, + #{configKey}, + #{configValue}, + #{configType}, + #{createBy}, + #{remark}, + sysdate() + ) + + + + update sys_config + + config_name = #{configName}, + config_key = #{configKey}, + config_value = #{configValue}, + config_type = #{configType}, + update_by = #{updateBy}, + remark = #{remark}, + update_time = sysdate() + + where config_id = #{configId} + + + + delete from sys_config where config_id = #{configId} + + + + delete from sys_config where config_id in + + #{configId} + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/bootstrap-sgzb_bns_local.yml b/bonus-modules/bonus-material/src/main/resources/bootstrap-sgzb_bns_local.yml index 952b426a..e0b166ef 100644 --- a/bonus-modules/bonus-material/src/main/resources/bootstrap-sgzb_bns_local.yml +++ b/bonus-modules/bonus-material/src/main/resources/bootstrap-sgzb_bns_local.yml @@ -1,6 +1,6 @@ # Tomcat server: - port: 58082 + port: 18588 # Spring spring: diff --git a/bonus-modules/pom.xml b/bonus-modules/pom.xml index 58573017..d66452d8 100644 --- a/bonus-modules/pom.xml +++ b/bonus-modules/pom.xml @@ -10,6 +10,7 @@ bonus-material + bonus-material-bigscreen bonus-modules