From 6a6302ff43c3b6b81da4423587413b3d775a4e79 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 17 Jun 2022 15:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=AE=E9=80=9A=E7=94=A8=E6=88=B7=E5=92=8CVI?= =?UTF-8?q?P=E7=94=A8=E6=88=B7=E5=8C=BA=E5=88=AB=E5=AF=B9=E5=BE=85?= =?UTF-8?q?=EF=BC=9A=201=E3=80=81=E6=99=AE=E9=80=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=9F=A5=E7=9C=8B=E5=8E=86=E5=8F=B2=E7=81=AB?= =?UTF-8?q?=E6=83=85=EF=BC=8CVIP=E5=8F=AF=E4=BB=A5=E3=80=82=202=E3=80=81?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E7=94=A8=E6=88=B7=E4=B8=8D=E8=83=BD=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=EF=BC=8CVIP=E5=8F=AF=E4=BB=A5=E3=80=82=203=E3=80=81?= =?UTF-8?q?=E6=99=AE=E9=80=9A=E7=94=A8=E6=88=B7=E4=B8=8D=E8=83=BD=E6=8E=A5?= =?UTF-8?q?=E6=94=B6=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=9F=A5=EF=BC=8CVIP?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../account/CustomAuthenticationProvider.java | 18 +- .../xkrs/common/account/JwtLoginFilter.java | 40 +--- .../account/TokenAuthenticationService.java | 46 +--- .../xkrs/common/config/WebSecurityConfig.java | 5 + .../controller/ConfigGlobalController.java | 53 +++-- .../xkrs/dao/ConfigGlobalFirePointDao.java | 11 - .../java/com/xkrs/dao/ConfigGlobalSMSDao.java | 10 - .../com/xkrs/dao/ConfigGlobalUserDao.java | 10 - .../java/com/xkrs/dao/GlobalConfigDao.java | 15 ++ .../com/xkrs/dao/GlobalConfigDictDao.java | 15 ++ .../entity/ConfigGlobalFirePointEntity.java | 91 -------- .../model/entity/ConfigGlobalSMSEntity.java | 162 -------------- .../model/entity/ConfigGlobalUserEntity.java | 46 ---- .../model/entity/GlobalConfigDictEntity.java | 70 ++++++ .../xkrs/model/entity/GlobalConfigEntity.java | 57 +++++ .../com/xkrs/model/qo/GlobalConfigDictQo.java | 46 ++++ src/main/java/com/xkrs/model/vo/ConfigVo.java | 69 ------ .../service/ConfigGlobalFirePointService.java | 24 --- .../xkrs/service/ConfigGlobalSMSService.java | 30 --- .../xkrs/service/ConfigGlobalUserService.java | 14 -- .../com/xkrs/service/GlobalConfigService.java | 19 ++ .../ConfigGlobalFirePointServiceImpl.java | 126 ----------- .../impl/ConfigGlobalSMSServiceImpl.java | 200 ------------------ .../impl/ConfigGlobalUserServiceImpl.java | 65 ------ .../service/impl/FirePointServiceImpl.java | 23 +- .../service/impl/GlobalConfigServiceImpl.java | 111 ++++++++++ .../java/com/xkrs/utils/ConfigConstant.java | 7 - 27 files changed, 386 insertions(+), 997 deletions(-) delete mode 100644 src/main/java/com/xkrs/dao/ConfigGlobalFirePointDao.java delete mode 100644 src/main/java/com/xkrs/dao/ConfigGlobalSMSDao.java delete mode 100644 src/main/java/com/xkrs/dao/ConfigGlobalUserDao.java create mode 100644 src/main/java/com/xkrs/dao/GlobalConfigDao.java create mode 100644 src/main/java/com/xkrs/dao/GlobalConfigDictDao.java delete mode 100644 src/main/java/com/xkrs/model/entity/ConfigGlobalFirePointEntity.java delete mode 100644 src/main/java/com/xkrs/model/entity/ConfigGlobalSMSEntity.java delete mode 100644 src/main/java/com/xkrs/model/entity/ConfigGlobalUserEntity.java create mode 100644 src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java create mode 100644 src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java create mode 100644 src/main/java/com/xkrs/model/qo/GlobalConfigDictQo.java delete mode 100644 src/main/java/com/xkrs/model/vo/ConfigVo.java delete mode 100644 src/main/java/com/xkrs/service/ConfigGlobalFirePointService.java delete mode 100644 src/main/java/com/xkrs/service/ConfigGlobalSMSService.java delete mode 100644 src/main/java/com/xkrs/service/ConfigGlobalUserService.java create mode 100644 src/main/java/com/xkrs/service/GlobalConfigService.java delete mode 100644 src/main/java/com/xkrs/service/impl/ConfigGlobalFirePointServiceImpl.java delete mode 100644 src/main/java/com/xkrs/service/impl/ConfigGlobalSMSServiceImpl.java delete mode 100644 src/main/java/com/xkrs/service/impl/ConfigGlobalUserServiceImpl.java create mode 100644 src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java delete mode 100644 src/main/java/com/xkrs/utils/ConfigConstant.java diff --git a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java index 554f360..300bf22 100644 --- a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java +++ b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java @@ -2,7 +2,6 @@ package com.xkrs.common.account; import com.xkrs.model.entity.SysAuthorityEntity; import com.xkrs.model.entity.SysUserEntity; -import com.xkrs.service.ConfigGlobalUserService; import com.xkrs.service.SysAuthorityService; import com.xkrs.service.SysRoleService; import com.xkrs.service.SysUserService; @@ -26,8 +25,6 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256; /** * 自定义认证Provider - * - * @author tajochen */ @Component public class CustomAuthenticationProvider implements AuthenticationProvider { @@ -41,9 +38,6 @@ public class CustomAuthenticationProvider implements AuthenticationProvider { @Resource private SysAuthorityService sysAuthorityService; - @Resource - private ConfigGlobalUserService configGlobalUserService; - /** * 初使化时将已静态化的Service实例化 */ @@ -58,7 +52,6 @@ public class CustomAuthenticationProvider implements AuthenticationProvider { customAuthenticationProvider.sysUserService = this.sysUserService; customAuthenticationProvider.sysRoleService = this.sysRoleService; customAuthenticationProvider.sysAuthorityService = this.sysAuthorityService; - customAuthenticationProvider.configGlobalUserService = this.configGlobalUserService; } /** @@ -73,7 +66,6 @@ public class CustomAuthenticationProvider implements AuthenticationProvider { // 获取认证的用户名 & 密码 String userName = authentication.getName(); String password = authentication.getCredentials().toString(); - SysUserEntity userEntity = customAuthenticationProvider.sysUserService.getSysUserByUserName(userName); // 检查用户是否存在 @@ -82,7 +74,7 @@ public class CustomAuthenticationProvider implements AuthenticationProvider { } // 检查用户是否激活 - if (userEntity.getActiveFlag().intValue() != 0) { + if (userEntity.getActiveFlag() != 0) { throw new DisabledException("该账号还未激活,请联系管理员"); } @@ -91,14 +83,6 @@ public class CustomAuthenticationProvider implements AuthenticationProvider { throw new DisabledException("用户状态不正常,请联系管理员"); } - if (userEntity.getDayNum() == 7) { - if (DateTimeUtil.dateTimeToString(LocalDateTime.now()).compareTo(userEntity.getOverTime()) > 0) { - if (!customAuthenticationProvider.configGlobalUserService.loginAbleWhenExpired()) { - throw new DisabledException("该账号已过期,请联系管理员"); - } - } - } - // 认证逻辑 String encryptPassword = encry256(password + userEntity.getSalt()); if (encryptPassword.equals(userEntity.getPassword())) { diff --git a/src/main/java/com/xkrs/common/account/JwtLoginFilter.java b/src/main/java/com/xkrs/common/account/JwtLoginFilter.java index 9c2a7b4..f70318c 100644 --- a/src/main/java/com/xkrs/common/account/JwtLoginFilter.java +++ b/src/main/java/com/xkrs/common/account/JwtLoginFilter.java @@ -2,14 +2,9 @@ package com.xkrs.common.account; import com.xkrs.common.encapsulation.OutputEncapsulation; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.model.entity.ConfigGlobalFirePointEntity; -import com.xkrs.model.vo.ConfigVo; import com.xkrs.model.vo.SysUserVo; -import com.xkrs.service.ConfigGlobalFirePointService; import com.xkrs.service.SysUserService; import com.xkrs.utils.IpUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.BadCredentialsException; @@ -33,19 +28,12 @@ import java.util.Locale; /** * jwt登录过滤器 - * - * @author tajochen */ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter { - private static final Logger logger = LoggerFactory.getLogger(JwtLoginFilter.class); - @Resource private SysUserService sysUserService; - @Resource - private ConfigGlobalFirePointService configGlobalFirePointService; - public JwtLoginFilter(String url, AuthenticationManager authManager) { super(new AntPathRequestMatcher(url)); setAuthenticationManager(authManager); @@ -88,12 +76,6 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter { WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); sysUserService = webApplicationContext.getBean(SysUserService.class); } - if (configGlobalFirePointService == null) { - ServletContext servletContext = req.getServletContext(); - WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); - configGlobalFirePointService = webApplicationContext.getBean(ConfigGlobalFirePointService.class); - } - ConfigVo config = getConfigVo(); //更新用户登录信息 sysUserService.updateSysUserLogin(auth.getName(), IpUtil.getIpAddr(req)); SysUserVo userByUserName = sysUserService.getUserByUserName(auth.getName()); @@ -101,27 +83,7 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter { response.setHeader("Access-Control-Allow-Credentials", "false"); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); - TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName, config); - } - - /** - * 生成配置信息 - */ - private ConfigVo getConfigVo() { - ConfigVo config = new ConfigVo(); - ConfigGlobalFirePointEntity firePointGlobalConfig = configGlobalFirePointService.findFirePointGlobalConfig(); - if (firePointGlobalConfig == null) { - config.setTodayAbleWhenExpired(1L); - config.setHistoryAbleWhenExpired(0L); - config.setStatisticsAbleWhenExpired(1L); - config.setNavigateAbleWhenExpired(0L); - } else { - config.setTodayAbleWhenExpired(firePointGlobalConfig.getTodayAbleWhenExpired()); - config.setHistoryAbleWhenExpired(firePointGlobalConfig.getHistoryAbleWhenExpired()); - config.setStatisticsAbleWhenExpired(firePointGlobalConfig.getStatisticsAbleWhenExpired()); - config.setNavigateAbleWhenExpired(firePointGlobalConfig.getNavigateAbleWhenExpired()); - } - return config; + TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName); } /** diff --git a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java index ca50a22..2ef9370 100644 --- a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java +++ b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java @@ -2,7 +2,6 @@ package com.xkrs.common.account; import com.xkrs.common.encapsulation.OutputEncapsulation; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.model.vo.ConfigVo; import com.xkrs.model.vo.SysUserVo; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; @@ -34,6 +33,7 @@ public class TokenAuthenticationService { * 加密密钥 */ static public final String SECRET_KEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U303" + "45HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXU" + "JOI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8"; + /** * Token前缀 */ @@ -52,7 +52,7 @@ public class TokenAuthenticationService { * @param userName * @param authorities */ - static void addAuthentication(HttpServletResponse response, String userName, Collection authorities, SysUserVo sysUserEntity, ConfigVo config) { + static void addAuthentication(HttpServletResponse response, String userName, Collection authorities, SysUserVo sysUserEntity) { Locale locale = new Locale("zh", "CN"); Map map = new HashMap(3); @@ -67,50 +67,10 @@ public class TokenAuthenticationService { } else { logger.warn(userName + " has no permission!"); } -// if (sysUserEntity.getDayNum() == 7) { -// // 结束的时间 -// LocalDateTime overTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime()); -// // 计算距离结束时间的天数作为token -// Duration duration = Duration.between(LocalDateTime.now(), overTime); -// /** -// * 动态设置过期时间 -// */ -// final long EXPIRATIONTIME = 60 * 60 * (duration.toDays() + 1) * 24_000; -// -// // 生成JWT -// String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName) -// // 保存权限 -// .claim("auths", authsList) -// // 有效期设置 -// .setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME)) -// // 签名设置 -// .signWith(key).compact(); -// map.put("token", jwt); -// map.put("user", sysUserEntity); -// map.put("config", config); -// } else { -// /** -// * 过期时间6小时 -// */ -// final long EXPIRATIONTIME = 21_600_000; -// -// // 生成JWT -// String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName) -// // 保存权限 -// .claim("auths", authsList) -// // 有效期设置 -// .setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME)) -// // 签名设置 -// .signWith(key).compact(); -// map.put("token", jwt); -// map.put("user", sysUserEntity); -// map.put("config", config); -// } /** * 过期时间6小时 */ final long EXPIRATIONTIME = 21_600_000; - // 生成JWT String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName) // 保存权限 @@ -121,7 +81,6 @@ public class TokenAuthenticationService { .signWith(key).compact(); map.put("token", jwt); map.put("user", sysUserEntity); - map.put("config", config); // 将 JWT 写入 body PrintWriter out = null; try { @@ -161,4 +120,5 @@ public class TokenAuthenticationService { return null; } } + } diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 8a62beb..8507578 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -33,6 +33,11 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { //.antMatchers("/").permitAll() // 所有OPTIONS请求都放行 .antMatchers(HttpMethod.OPTIONS).permitAll() + .antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll() + .antMatchers(HttpMethod.GET, "/selectGlobalConfigValue").permitAll() + .antMatchers(HttpMethod.GET, "/selectGlobalConfig").permitAll() + .antMatchers(HttpMethod.POST, "/globalConfig").permitAll() + .antMatchers(HttpMethod.POST, "/globalConfigDict").permitAll() // 所有 /user/add 用户注册 的POST请求 都放行 .antMatchers(HttpMethod.POST, "/api/user/add").permitAll() // 所有 /user/check/duplicate 检查用户名是否重复 的POST请求 都放行 diff --git a/src/main/java/com/xkrs/controller/ConfigGlobalController.java b/src/main/java/com/xkrs/controller/ConfigGlobalController.java index 12ac50b..eb847fc 100644 --- a/src/main/java/com/xkrs/controller/ConfigGlobalController.java +++ b/src/main/java/com/xkrs/controller/ConfigGlobalController.java @@ -1,42 +1,53 @@ package com.xkrs.controller; -import com.xkrs.service.ConfigGlobalFirePointService; -import com.xkrs.service.ConfigGlobalSMSService; -import com.xkrs.service.ConfigGlobalUserService; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.model.qo.GlobalConfigDictQo; +import com.xkrs.service.GlobalConfigService; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.lang.Nullable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.Locale; import java.util.Map; +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; + /** * 全局配置服务 */ @RestController public class ConfigGlobalController { - @Resource - private ConfigGlobalUserService configGlobalUserService; - @Resource - private ConfigGlobalFirePointService configGlobalFirePointService; - @Resource - private ConfigGlobalSMSService configGlobalSMSService; + private final Locale locale = LocaleContextHolder.getLocale(); - @PostMapping("/configGlobalUser") - public String configGlobalUser(@Nullable @RequestBody Map configMap) { - return configGlobalUserService.configGlobalUser(configMap); + @Resource + private GlobalConfigService globalConfigService; + + @GetMapping("/selectGlobalConfigDict") + public String selectGlobalConfigDict() { + return globalConfigService.selectGlobalConfigDict(); } - @PostMapping("/configGlobalFirePoint") - public String configGlobalFirePoint(@Nullable @RequestBody Map configMap) { - return configGlobalFirePointService.configGlobalFirePoint(configMap); + @GetMapping("/selectGlobalConfigValue") + public String selectGlobalConfigValue(@RequestParam(value = "code") Long code) { + Long value = globalConfigService.selectGlobalConfigValue(code); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, value, locale); } - @PostMapping("/configGlobalSMS") - public String configGlobalSMS(@Nullable @RequestBody Map configMap) { - return configGlobalSMSService.configGlobalSMS(configMap); + @GetMapping("/selectGlobalConfig") + public String selectGlobalConfig(@RequestParam(required = false, value = "code") Long code) { + return globalConfigService.selectGlobalConfig(code); + } + + @PostMapping("/globalConfig") + public String globalConfig(@Nullable @RequestBody Map configMap) { + return globalConfigService.globalConfig(configMap); + } + + @PostMapping("/globalConfigDict") + public String globalConfigDict(@RequestBody GlobalConfigDictQo globalConfigDictQo) { + return globalConfigService.globalConfigDict(globalConfigDictQo); } } diff --git a/src/main/java/com/xkrs/dao/ConfigGlobalFirePointDao.java b/src/main/java/com/xkrs/dao/ConfigGlobalFirePointDao.java deleted file mode 100644 index e9bcaf6..0000000 --- a/src/main/java/com/xkrs/dao/ConfigGlobalFirePointDao.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.ConfigGlobalFirePointEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -@Component -public interface ConfigGlobalFirePointDao extends JpaRepository, JpaSpecificationExecutor { - -} diff --git a/src/main/java/com/xkrs/dao/ConfigGlobalSMSDao.java b/src/main/java/com/xkrs/dao/ConfigGlobalSMSDao.java deleted file mode 100644 index e1e20ed..0000000 --- a/src/main/java/com/xkrs/dao/ConfigGlobalSMSDao.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.ConfigGlobalSMSEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -@Component -public interface ConfigGlobalSMSDao extends JpaRepository, JpaSpecificationExecutor { -} diff --git a/src/main/java/com/xkrs/dao/ConfigGlobalUserDao.java b/src/main/java/com/xkrs/dao/ConfigGlobalUserDao.java deleted file mode 100644 index 7914847..0000000 --- a/src/main/java/com/xkrs/dao/ConfigGlobalUserDao.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.ConfigGlobalUserEntity; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.stereotype.Component; - -@Component -public interface ConfigGlobalUserDao extends JpaRepository, JpaSpecificationExecutor { -} diff --git a/src/main/java/com/xkrs/dao/GlobalConfigDao.java b/src/main/java/com/xkrs/dao/GlobalConfigDao.java new file mode 100644 index 0000000..2ed4665 --- /dev/null +++ b/src/main/java/com/xkrs/dao/GlobalConfigDao.java @@ -0,0 +1,15 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.GlobalConfigEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +@Component +public interface GlobalConfigDao extends JpaRepository, JpaSpecificationExecutor { + + Optional findByCode(Long code); + +} diff --git a/src/main/java/com/xkrs/dao/GlobalConfigDictDao.java b/src/main/java/com/xkrs/dao/GlobalConfigDictDao.java new file mode 100644 index 0000000..77572fa --- /dev/null +++ b/src/main/java/com/xkrs/dao/GlobalConfigDictDao.java @@ -0,0 +1,15 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.GlobalConfigDictEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +@Component +public interface GlobalConfigDictDao extends JpaRepository, JpaSpecificationExecutor { + + Optional findByCode(Long code); + +} diff --git a/src/main/java/com/xkrs/model/entity/ConfigGlobalFirePointEntity.java b/src/main/java/com/xkrs/model/entity/ConfigGlobalFirePointEntity.java deleted file mode 100644 index 78f1ba5..0000000 --- a/src/main/java/com/xkrs/model/entity/ConfigGlobalFirePointEntity.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * 火情信息全局配置信息 - */ -@Entity -@Table(name = "config_global_fire_point") -public class ConfigGlobalFirePointEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "config_global_fire_point_seq_gen") - @SequenceGenerator(name = "config_global_fire_point_seq_gen", sequenceName = "config_global_fire_point_id_seq", allocationSize = 1) - private Long id; - - /** - * 过期后能否获取今日火情信息 - * 0:不能获取 - * 1:能够获取 - */ - private Long todayAbleWhenExpired; - - /** - * 过期后能否获取历史火情信息 - * 0:不能获取 - * 1:能够获取 - */ - private Long historyAbleWhenExpired; - - /** - * 过期后能否获取统计分析数据 - * 0:不能获取 - * 1:能够获取 - */ - private Long statisticsAbleWhenExpired; - - /** - * 过期后能否使用导航功能 - * 0:不能导航 - * 1:能够导航 - */ - private Long navigateAbleWhenExpired; - - public ConfigGlobalFirePointEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getTodayAbleWhenExpired() { - return todayAbleWhenExpired; - } - - public void setTodayAbleWhenExpired(Long todayAbleWhenExpired) { - this.todayAbleWhenExpired = todayAbleWhenExpired; - } - - public Long getHistoryAbleWhenExpired() { - return historyAbleWhenExpired; - } - - public void setHistoryAbleWhenExpired(Long historyAbleWhenExpired) { - this.historyAbleWhenExpired = historyAbleWhenExpired; - } - - public Long getStatisticsAbleWhenExpired() { - return statisticsAbleWhenExpired; - } - - public void setStatisticsAbleWhenExpired(Long statisticsAbleWhenExpired) { - this.statisticsAbleWhenExpired = statisticsAbleWhenExpired; - } - - public Long getNavigateAbleWhenExpired() { - return navigateAbleWhenExpired; - } - - public void setNavigateAbleWhenExpired(Long navigateAbleWhenExpired) { - this.navigateAbleWhenExpired = navigateAbleWhenExpired; - } -} diff --git a/src/main/java/com/xkrs/model/entity/ConfigGlobalSMSEntity.java b/src/main/java/com/xkrs/model/entity/ConfigGlobalSMSEntity.java deleted file mode 100644 index 7d2cb66..0000000 --- a/src/main/java/com/xkrs/model/entity/ConfigGlobalSMSEntity.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * 短信全局配置信息 - */ -@Entity -@Table(name = "config_global_sms") -public class ConfigGlobalSMSEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "config_global_sms_seq_gen") - @SequenceGenerator(name = "config_global_sms_seq_gen", sequenceName = "config_global_sms_id_seq", allocationSize = 1) - private Long id; - - /** - * 过期后能否接收短信 - * 0:不能 - * 1:能 - */ - private Long smsAbleWhenExpired; - - /** - * 省过期前能否提前通知 - * 0:不能通知 - * 1:能够通知 - */ - private Long proAnAbleBeforeExpired; - - /** - * 省过期前提前几天短信通知 - * 天数 - */ - private Long proAnDayBeforeExpired; - - /** - * 市过期前能否提前通知 - * 0:不能通知 - * 1:能够通知 - */ - private Long cityAnAbleBeforeExpired; - - /** - * 市过期前提前几天短信通知 - * 天数 - */ - private Long cityAnDayBeforeExpired; - - /** - * 区县过期前能否提前通知 - * 0:不能通知 - * 1:能够通知 - */ - private Long countyAnAbleBeforeExpired; - - /** - * 区县过期前提前几天短信通知 - * 天数 - */ - private Long countyAnDayBeforeExpired; - - /** - * 街道过期前能否提前通知 - * 0:不能通知 - * 1:能够通知 - */ - private Long streetAnAbleBeforeExpired; - - /** - * 街道过期前提前几天短信通知 - * 天数 - */ - private Long streetAnDayBeforeExpired; - - public ConfigGlobalSMSEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getSmsAbleWhenExpired() { - return smsAbleWhenExpired; - } - - public void setSmsAbleWhenExpired(Long smsAbleWhenExpired) { - this.smsAbleWhenExpired = smsAbleWhenExpired; - } - - public Long getProAnAbleBeforeExpired() { - return proAnAbleBeforeExpired; - } - - public void setProAnAbleBeforeExpired(Long proAnAbleBeforeExpired) { - this.proAnAbleBeforeExpired = proAnAbleBeforeExpired; - } - - public Long getProAnDayBeforeExpired() { - return proAnDayBeforeExpired; - } - - public void setProAnDayBeforeExpired(Long proAnDayBeforeExpired) { - this.proAnDayBeforeExpired = proAnDayBeforeExpired; - } - - public Long getCityAnAbleBeforeExpired() { - return cityAnAbleBeforeExpired; - } - - public void setCityAnAbleBeforeExpired(Long cityAnAbleBeforeExpired) { - this.cityAnAbleBeforeExpired = cityAnAbleBeforeExpired; - } - - public Long getCityAnDayBeforeExpired() { - return cityAnDayBeforeExpired; - } - - public void setCityAnDayBeforeExpired(Long cityAnDayBeforeExpired) { - this.cityAnDayBeforeExpired = cityAnDayBeforeExpired; - } - - public Long getCountyAnAbleBeforeExpired() { - return countyAnAbleBeforeExpired; - } - - public void setCountyAnAbleBeforeExpired(Long countyAnAbleBeforeExpired) { - this.countyAnAbleBeforeExpired = countyAnAbleBeforeExpired; - } - - public Long getCountyAnDayBeforeExpired() { - return countyAnDayBeforeExpired; - } - - public void setCountyAnDayBeforeExpired(Long countyAnDayBeforeExpired) { - this.countyAnDayBeforeExpired = countyAnDayBeforeExpired; - } - - public Long getStreetAnAbleBeforeExpired() { - return streetAnAbleBeforeExpired; - } - - public void setStreetAnAbleBeforeExpired(Long streetAnAbleBeforeExpired) { - this.streetAnAbleBeforeExpired = streetAnAbleBeforeExpired; - } - - public Long getStreetAnDayBeforeExpired() { - return streetAnDayBeforeExpired; - } - - public void setStreetAnDayBeforeExpired(Long streetAnDayBeforeExpired) { - this.streetAnDayBeforeExpired = streetAnDayBeforeExpired; - } -} diff --git a/src/main/java/com/xkrs/model/entity/ConfigGlobalUserEntity.java b/src/main/java/com/xkrs/model/entity/ConfigGlobalUserEntity.java deleted file mode 100644 index 3e0b9cc..0000000 --- a/src/main/java/com/xkrs/model/entity/ConfigGlobalUserEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.xkrs.model.entity; - -import javax.persistence.*; -import java.io.Serializable; - -/** - * 用户全局配置信息 - */ -@Entity -@Table(name = "config_global_user") -public class ConfigGlobalUserEntity implements Serializable { - - /** - * 主键id - */ - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "config_global_user_seq_gen") - @SequenceGenerator(name = "config_global_user_seq_gen", sequenceName = "config_global_user_id_seq", allocationSize = 1) - private Long id; - - /** - * 过期后能否继续登录 - * 0:不能登录 - * 1:能够登录 - */ - private Long loginAbleWhenExpired; - - public ConfigGlobalUserEntity() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getLoginAbleWhenExpired() { - return loginAbleWhenExpired; - } - - public void setLoginAbleWhenExpired(Long loginAbleWhenExpired) { - this.loginAbleWhenExpired = loginAbleWhenExpired; - } -} diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java new file mode 100644 index 0000000..6366160 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/GlobalConfigDictEntity.java @@ -0,0 +1,70 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * 全局配置字典表 + */ +@Entity +@Table(name = "global_config_dict") +public class GlobalConfigDictEntity implements Serializable { + + /** + * 主键id + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "global_config_dict_seq_gen") + @SequenceGenerator(name = "global_config_dict_seq_gen", sequenceName = "global_config_dict_id_seq", allocationSize = 1) + private Long id; + + /** + * 全局配置字典的编码 + */ + private Long code; + + /** + * 全局配置字典的名称 + */ + private String name; + + /** + * 全局配置字典的备注 + */ + private String remark; + + public GlobalConfigDictEntity() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getCode() { + return code; + } + + public void setCode(Long code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} diff --git a/src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java b/src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java new file mode 100644 index 0000000..02727d7 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/GlobalConfigEntity.java @@ -0,0 +1,57 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * 全局配置表 + */ +@Entity +@Table(name = "global_config") +public class GlobalConfigEntity implements Serializable { + + /** + * 主键id + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "global_config_seq_gen") + @SequenceGenerator(name = "global_config_seq_gen", sequenceName = "global_config_id_seq", allocationSize = 1) + private Long id; + + /** + * 全局配置项的编号 + */ + private Long code; + + /** + * 全局配置项的值 + */ + private Long value; + + public GlobalConfigEntity() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getCode() { + return code; + } + + public void setCode(Long code) { + this.code = code; + } + + public Long getValue() { + return value; + } + + public void setValue(Long value) { + this.value = value; + } +} diff --git a/src/main/java/com/xkrs/model/qo/GlobalConfigDictQo.java b/src/main/java/com/xkrs/model/qo/GlobalConfigDictQo.java new file mode 100644 index 0000000..778272f --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/GlobalConfigDictQo.java @@ -0,0 +1,46 @@ +package com.xkrs.model.qo; + +public class GlobalConfigDictQo { + + /** + * 全局配置字典的编码 + */ + private Long code; + + /** + * 全局配置字典的名称 + */ + private String name; + + /** + * 全局配置字典的备注 + */ + private String remark; + + public GlobalConfigDictQo() { + } + + public Long getCode() { + return code; + } + + public void setCode(Long code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } +} diff --git a/src/main/java/com/xkrs/model/vo/ConfigVo.java b/src/main/java/com/xkrs/model/vo/ConfigVo.java deleted file mode 100644 index a2854c7..0000000 --- a/src/main/java/com/xkrs/model/vo/ConfigVo.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.xkrs.model.vo; - -import java.io.Serializable; - -public class ConfigVo implements Serializable { - - /** - * 过期后能否获取今日火情信息 - * 0:不能获取 - * 1:能够获取 - */ - private Long todayAbleWhenExpired; - - /** - * 过期后能否获取历史火情信息 - * 0:不能获取 - * 1:能够获取 - */ - private Long historyAbleWhenExpired; - - /** - * 过期后能否获取统计分析数据 - * 0:不能获取 - * 1:能够获取 - */ - private Long statisticsAbleWhenExpired; - - /** - * 过期后能否使用导航功能 - * 0:不能导航 - * 1:能够导航 - */ - private Long navigateAbleWhenExpired; - - public ConfigVo() { - } - - public Long getTodayAbleWhenExpired() { - return todayAbleWhenExpired; - } - - public void setTodayAbleWhenExpired(Long todayAbleWhenExpired) { - this.todayAbleWhenExpired = todayAbleWhenExpired; - } - - public Long getHistoryAbleWhenExpired() { - return historyAbleWhenExpired; - } - - public void setHistoryAbleWhenExpired(Long historyAbleWhenExpired) { - this.historyAbleWhenExpired = historyAbleWhenExpired; - } - - public Long getStatisticsAbleWhenExpired() { - return statisticsAbleWhenExpired; - } - - public void setStatisticsAbleWhenExpired(Long statisticsAbleWhenExpired) { - this.statisticsAbleWhenExpired = statisticsAbleWhenExpired; - } - - public Long getNavigateAbleWhenExpired() { - return navigateAbleWhenExpired; - } - - public void setNavigateAbleWhenExpired(Long navigateAbleWhenExpired) { - this.navigateAbleWhenExpired = navigateAbleWhenExpired; - } -} diff --git a/src/main/java/com/xkrs/service/ConfigGlobalFirePointService.java b/src/main/java/com/xkrs/service/ConfigGlobalFirePointService.java deleted file mode 100644 index e4cb7b4..0000000 --- a/src/main/java/com/xkrs/service/ConfigGlobalFirePointService.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.xkrs.service; - -import com.xkrs.model.entity.ConfigGlobalFirePointEntity; - -import java.util.Map; - -/** - * 火情信息全局配置服务 - */ -public interface ConfigGlobalFirePointService { - - boolean todayAbleWhenExpired(); - - boolean historyAbleWhenExpired(); - - boolean statisticsAbleWhenExpired(); - - boolean navigateAbleWhenExpired(); - - ConfigGlobalFirePointEntity findFirePointGlobalConfig(); - - String configGlobalFirePoint(Map configMap); - -} diff --git a/src/main/java/com/xkrs/service/ConfigGlobalSMSService.java b/src/main/java/com/xkrs/service/ConfigGlobalSMSService.java deleted file mode 100644 index 3b41564..0000000 --- a/src/main/java/com/xkrs/service/ConfigGlobalSMSService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.xkrs.service; - -import java.util.Map; - -/** - * 短信全局配置服务 - */ -public interface ConfigGlobalSMSService { - - boolean smsAbleWhenExpired(); - - boolean proAnAbleBeforeExpired(); - - long proAnDayBeforeExpired(); - - boolean cityAnAbleBeforeExpired(); - - long cityAnDayBeforeExpired(); - - boolean countyAnAbleBeforeExpired(); - - long countyAnDayBeforeExpired(); - - boolean streetAnAbleBeforeExpired(); - - long streetAnDayBeforeExpired(); - - String configGlobalSMS(Map configMap); - -} diff --git a/src/main/java/com/xkrs/service/ConfigGlobalUserService.java b/src/main/java/com/xkrs/service/ConfigGlobalUserService.java deleted file mode 100644 index 6e273c6..0000000 --- a/src/main/java/com/xkrs/service/ConfigGlobalUserService.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.xkrs.service; - -import java.util.Map; - -/** - * 用户全局配置服务 - */ -public interface ConfigGlobalUserService { - - boolean loginAbleWhenExpired(); - - String configGlobalUser(Map configMap); - -} diff --git a/src/main/java/com/xkrs/service/GlobalConfigService.java b/src/main/java/com/xkrs/service/GlobalConfigService.java new file mode 100644 index 0000000..0de13f1 --- /dev/null +++ b/src/main/java/com/xkrs/service/GlobalConfigService.java @@ -0,0 +1,19 @@ +package com.xkrs.service; + +import com.xkrs.model.qo.GlobalConfigDictQo; + +import java.util.Map; + +public interface GlobalConfigService { + + String selectGlobalConfigDict(); + + Long selectGlobalConfigValue(Long code); + + String selectGlobalConfig(Long code); + + String globalConfig(Map globalConfigMap); + + String globalConfigDict(GlobalConfigDictQo globalConfigDictQo); + +} diff --git a/src/main/java/com/xkrs/service/impl/ConfigGlobalFirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/ConfigGlobalFirePointServiceImpl.java deleted file mode 100644 index c9db95d..0000000 --- a/src/main/java/com/xkrs/service/impl/ConfigGlobalFirePointServiceImpl.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.xkrs.service.impl; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.ConfigGlobalFirePointDao; -import com.xkrs.model.entity.ConfigGlobalFirePointEntity; -import com.xkrs.service.ConfigGlobalFirePointService; -import com.xkrs.utils.ConfigConstant; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 火情信息全局配置服务 - */ -@Service -public class ConfigGlobalFirePointServiceImpl implements ConfigGlobalFirePointService { - - private final Locale locale = LocaleContextHolder.getLocale(); - - /** - * 火情信息全局配置信息 - */ - @Resource - private ConfigGlobalFirePointDao configGlobalFirePointDao; - - @Override - public boolean todayAbleWhenExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalFirePointDao.findAll().get(0).getTodayAbleWhenExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public boolean historyAbleWhenExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalFirePointDao.findAll().get(0).getHistoryAbleWhenExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public boolean statisticsAbleWhenExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalFirePointDao.findAll().get(0).getStatisticsAbleWhenExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public boolean navigateAbleWhenExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalFirePointDao.findAll().get(0).getNavigateAbleWhenExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public ConfigGlobalFirePointEntity findFirePointGlobalConfig() { - try { - return configGlobalFirePointDao.findAll().get(0); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - @Override - public String configGlobalFirePoint(Map configMap) { - if (configMap == null) { - return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale); - } - Long todayAbleWhenExpired = configMap.get("todayAbleWhenExpired"); - Long historyAbleWhenExpired = configMap.get("historyAbleWhenExpired"); - Long statisticsAbleWhenExpired = configMap.get("statisticsAbleWhenExpired"); - Long navigateAbleWhenExpired = configMap.get("navigateAbleWhenExpired"); - List configGlobalFirePointEntityList = configGlobalFirePointDao.findAll(); - if (configGlobalFirePointEntityList.isEmpty()) { - ConfigGlobalFirePointEntity configGlobalFirePointEntity = new ConfigGlobalFirePointEntity(); - configGlobalFirePointEntity.setTodayAbleWhenExpired(todayAbleWhenExpired); - configGlobalFirePointEntity.setHistoryAbleWhenExpired(historyAbleWhenExpired); - configGlobalFirePointEntity.setStatisticsAbleWhenExpired(statisticsAbleWhenExpired); - configGlobalFirePointEntity.setNavigateAbleWhenExpired(navigateAbleWhenExpired); - configGlobalFirePointDao.save(configGlobalFirePointEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - ConfigGlobalFirePointEntity configGlobalFirePointEntity = configGlobalFirePointEntityList.get(0); - if (todayAbleWhenExpired != null) { - if (configGlobalFirePointEntity.getTodayAbleWhenExpired() == null || configGlobalFirePointEntity.getTodayAbleWhenExpired().longValue() != todayAbleWhenExpired.longValue()) { - configGlobalFirePointEntity.setTodayAbleWhenExpired(todayAbleWhenExpired); - } - } - if (historyAbleWhenExpired != null) { - if (configGlobalFirePointEntity.getHistoryAbleWhenExpired() == null || configGlobalFirePointEntity.getHistoryAbleWhenExpired().longValue() != historyAbleWhenExpired.longValue()) { - configGlobalFirePointEntity.setHistoryAbleWhenExpired(historyAbleWhenExpired); - } - } - if (statisticsAbleWhenExpired != null) { - if (configGlobalFirePointEntity.getStatisticsAbleWhenExpired() == null || configGlobalFirePointEntity.getStatisticsAbleWhenExpired().longValue() != statisticsAbleWhenExpired.longValue()) { - configGlobalFirePointEntity.setStatisticsAbleWhenExpired(statisticsAbleWhenExpired); - } - } - if (navigateAbleWhenExpired != null) { - if (configGlobalFirePointEntity.getNavigateAbleWhenExpired() == null || configGlobalFirePointEntity.getNavigateAbleWhenExpired().longValue() != navigateAbleWhenExpired.longValue()) { - configGlobalFirePointEntity.setNavigateAbleWhenExpired(navigateAbleWhenExpired); - } - } - configGlobalFirePointDao.save(configGlobalFirePointEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - -} diff --git a/src/main/java/com/xkrs/service/impl/ConfigGlobalSMSServiceImpl.java b/src/main/java/com/xkrs/service/impl/ConfigGlobalSMSServiceImpl.java deleted file mode 100644 index 5deab09..0000000 --- a/src/main/java/com/xkrs/service/impl/ConfigGlobalSMSServiceImpl.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.xkrs.service.impl; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.ConfigGlobalSMSDao; -import com.xkrs.model.entity.ConfigGlobalSMSEntity; -import com.xkrs.service.ConfigGlobalSMSService; -import com.xkrs.utils.ConfigConstant; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 短信全局配置服务 - */ -@Service -public class ConfigGlobalSMSServiceImpl implements ConfigGlobalSMSService { - - private final Locale locale = LocaleContextHolder.getLocale(); - - /** - * 短信全局配置信息 - */ - @Resource - private ConfigGlobalSMSDao configGlobalSMSDao; - - @Override - public boolean smsAbleWhenExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getSmsAbleWhenExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public boolean proAnAbleBeforeExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getProAnAbleBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public long proAnDayBeforeExpired() { - try { - return configGlobalSMSDao.findAll().get(0).getProAnDayBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0L; - } - - @Override - public boolean cityAnAbleBeforeExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getCityAnAbleBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public long cityAnDayBeforeExpired() { - try { - return configGlobalSMSDao.findAll().get(0).getCityAnDayBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0L; - } - - @Override - public boolean countyAnAbleBeforeExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getCountyAnAbleBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public long countyAnDayBeforeExpired() { - try { - return configGlobalSMSDao.findAll().get(0).getCountyAnDayBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0L; - } - - @Override - public boolean streetAnAbleBeforeExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getStreetAnAbleBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public long streetAnDayBeforeExpired() { - try { - return configGlobalSMSDao.findAll().get(0).getStreetAnDayBeforeExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return 0L; - } - - @Override - public String configGlobalSMS(Map configMap) { - if (configMap == null) { - return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale); - } - Long smsAbleWhenExpired = configMap.get("smsAbleWhenExpired"); - Long proAnAbleBeforeExpired = configMap.get("proAnAbleBeforeExpired"); - Long proAnDayBeforeExpired = configMap.get("proAnDayBeforeExpired"); - Long cityAnAbleBeforeExpired = configMap.get("cityAnAbleBeforeExpired"); - Long cityAnDayBeforeExpired = configMap.get("cityAnDayBeforeExpired"); - Long countyAnAbleBeforeExpired = configMap.get("countyAnAbleBeforeExpired"); - Long countyAnDayBeforeExpired = configMap.get("countyAnDayBeforeExpired"); - Long streetAnAbleBeforeExpired = configMap.get("streetAnAbleBeforeExpired"); - Long streetAnDayBeforeExpired = configMap.get("streetAnDayBeforeExpired"); - List configGlobalSMSEntityList = configGlobalSMSDao.findAll(); - if (configGlobalSMSEntityList.isEmpty()) { - ConfigGlobalSMSEntity configGlobalSMSEntity = new ConfigGlobalSMSEntity(); - configGlobalSMSEntity.setSmsAbleWhenExpired(smsAbleWhenExpired); - configGlobalSMSEntity.setProAnAbleBeforeExpired(proAnAbleBeforeExpired); - configGlobalSMSEntity.setProAnDayBeforeExpired(proAnDayBeforeExpired); - configGlobalSMSEntity.setCityAnAbleBeforeExpired(cityAnAbleBeforeExpired); - configGlobalSMSEntity.setCityAnDayBeforeExpired(cityAnDayBeforeExpired); - configGlobalSMSEntity.setCountyAnAbleBeforeExpired(countyAnAbleBeforeExpired); - configGlobalSMSEntity.setCountyAnDayBeforeExpired(countyAnDayBeforeExpired); - configGlobalSMSEntity.setStreetAnAbleBeforeExpired(streetAnAbleBeforeExpired); - configGlobalSMSEntity.setStreetAnDayBeforeExpired(streetAnDayBeforeExpired); - configGlobalSMSDao.save(configGlobalSMSEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - ConfigGlobalSMSEntity configGlobalSMSEntity = configGlobalSMSEntityList.get(0); - if (smsAbleWhenExpired != null) { - if (configGlobalSMSEntity.getSmsAbleWhenExpired() == null || configGlobalSMSEntity.getSmsAbleWhenExpired().longValue() != smsAbleWhenExpired.longValue()) { - configGlobalSMSEntity.setSmsAbleWhenExpired(smsAbleWhenExpired); - } - } - if (proAnAbleBeforeExpired != null) { - if (configGlobalSMSEntity.getProAnAbleBeforeExpired() == null || configGlobalSMSEntity.getProAnAbleBeforeExpired().longValue() != proAnAbleBeforeExpired.longValue()) { - configGlobalSMSEntity.setProAnAbleBeforeExpired(proAnAbleBeforeExpired); - } - } - if (proAnDayBeforeExpired != null) { - if (configGlobalSMSEntity.getProAnDayBeforeExpired() == null || configGlobalSMSEntity.getProAnDayBeforeExpired().longValue() != proAnDayBeforeExpired.longValue()) { - configGlobalSMSEntity.setProAnDayBeforeExpired(proAnDayBeforeExpired); - } - } - if (cityAnAbleBeforeExpired != null) { - if (configGlobalSMSEntity.getCityAnAbleBeforeExpired() == null || configGlobalSMSEntity.getCityAnAbleBeforeExpired().longValue() != cityAnAbleBeforeExpired.longValue()) { - configGlobalSMSEntity.setCityAnAbleBeforeExpired(cityAnAbleBeforeExpired); - } - } - if (cityAnDayBeforeExpired != null) { - if (configGlobalSMSEntity.getCityAnDayBeforeExpired() == null || configGlobalSMSEntity.getCityAnDayBeforeExpired().longValue() != cityAnDayBeforeExpired.longValue()) { - configGlobalSMSEntity.setCityAnDayBeforeExpired(cityAnDayBeforeExpired); - } - } - if (countyAnAbleBeforeExpired != null) { - if (configGlobalSMSEntity.getCountyAnAbleBeforeExpired() == null || configGlobalSMSEntity.getCountyAnAbleBeforeExpired().longValue() != countyAnAbleBeforeExpired.longValue()) { - configGlobalSMSEntity.setCountyAnAbleBeforeExpired(countyAnAbleBeforeExpired); - } - } - if (countyAnDayBeforeExpired != null) { - if (configGlobalSMSEntity.getCountyAnDayBeforeExpired() == null || configGlobalSMSEntity.getCountyAnDayBeforeExpired().longValue() != countyAnDayBeforeExpired.longValue()) { - configGlobalSMSEntity.setCountyAnDayBeforeExpired(countyAnDayBeforeExpired); - } - } - if (streetAnAbleBeforeExpired != null) { - if (configGlobalSMSEntity.getStreetAnAbleBeforeExpired() == null || configGlobalSMSEntity.getStreetAnAbleBeforeExpired().longValue() != streetAnAbleBeforeExpired.longValue()) { - configGlobalSMSEntity.setStreetAnAbleBeforeExpired(streetAnAbleBeforeExpired); - } - } - if (streetAnDayBeforeExpired != null) { - if (configGlobalSMSEntity.getStreetAnDayBeforeExpired() == null || configGlobalSMSEntity.getStreetAnDayBeforeExpired().longValue() != streetAnDayBeforeExpired.longValue()) { - configGlobalSMSEntity.setStreetAnDayBeforeExpired(streetAnDayBeforeExpired); - } - } - configGlobalSMSDao.save(configGlobalSMSEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } -} diff --git a/src/main/java/com/xkrs/service/impl/ConfigGlobalUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/ConfigGlobalUserServiceImpl.java deleted file mode 100644 index c6440b9..0000000 --- a/src/main/java/com/xkrs/service/impl/ConfigGlobalUserServiceImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.xkrs.service.impl; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.dao.ConfigGlobalUserDao; -import com.xkrs.model.entity.ConfigGlobalUserEntity; -import com.xkrs.service.ConfigGlobalUserService; -import com.xkrs.utils.ConfigConstant; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * 用户全局配置服务 - */ -@Service -public class ConfigGlobalUserServiceImpl implements ConfigGlobalUserService { - - private final Locale locale = LocaleContextHolder.getLocale(); - - /** - * 用户全局配置信息 - */ - @Resource - private ConfigGlobalUserDao configGlobalUserDao; - - @Override - public boolean loginAbleWhenExpired() { - try { - return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalUserDao.findAll().get(0).getLoginAbleWhenExpired().longValue(); - } catch (Exception e) { - e.printStackTrace(); - } - return false; - } - - @Override - public String configGlobalUser(Map configMap) { - if (configMap == null) { - return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale); - } - Long loginAbleWhenExpired = configMap.get("loginAbleWhenExpired"); - List configGlobalUserEntityList = configGlobalUserDao.findAll(); - if (configGlobalUserEntityList.isEmpty()) { - ConfigGlobalUserEntity configGlobalUserEntity = new ConfigGlobalUserEntity(); - configGlobalUserEntity.setLoginAbleWhenExpired(loginAbleWhenExpired); - configGlobalUserDao.save(configGlobalUserEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - ConfigGlobalUserEntity configGlobalUserEntity = configGlobalUserEntityList.get(0); - if (loginAbleWhenExpired != null) { - if (configGlobalUserEntity.getLoginAbleWhenExpired() == null || configGlobalUserEntity.getLoginAbleWhenExpired().longValue() != loginAbleWhenExpired.longValue()) { - configGlobalUserEntity.setLoginAbleWhenExpired(loginAbleWhenExpired); - } - } - configGlobalUserDao.save(configGlobalUserEntity); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); - } - -} diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index b61d304..1a6b33b 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -8,10 +8,8 @@ import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.AppPhotoVo; import com.xkrs.model.vo.AppTaskBodyVo; import com.xkrs.model.vo.GaoDeIgGeocodeVo; -import com.xkrs.service.ConfigGlobalFirePointService; -import com.xkrs.service.ConfigGlobalSMSService; -import com.xkrs.service.ConfigGlobalUserService; import com.xkrs.service.FirePointService; +import com.xkrs.service.GlobalConfigService; import com.xkrs.utils.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -87,13 +85,9 @@ public class FirePointServiceImpl implements FirePointService { @Resource private FirePointQueryHelper firePointQueryHelper; - @Resource - private ConfigGlobalUserService configGlobalUserService; - @Resource - private ConfigGlobalFirePointService configGlobalFirePointService; - @Resource - private ConfigGlobalSMSService configGlobalSMSService; + @Resource + private GlobalConfigService globalConfigService; /** * 添加火点信息 @@ -431,9 +425,14 @@ public class FirePointServiceImpl implements FirePointService { continue; } LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME); - if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {//过期用户 - //过期用户需要根据配置决定是否发送短信 - if (!configGlobalSMSService.smsAbleWhenExpired()) { + if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {//普通用户 + boolean smsEnable = 1L == globalConfigService.selectGlobalConfigValue(9L); + if (!smsEnable) {//根据配置信息决定是否发送短信 + continue; + } + } else {//VIP用户 + boolean smsEnable = 1L == globalConfigService.selectGlobalConfigValue(10L); + if (!smsEnable) {//根据配置信息决定是否发送短信 continue; } } diff --git a/src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java b/src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java new file mode 100644 index 0000000..6a811d0 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/GlobalConfigServiceImpl.java @@ -0,0 +1,111 @@ +package com.xkrs.service.impl; + +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.dao.GlobalConfigDao; +import com.xkrs.dao.GlobalConfigDictDao; +import com.xkrs.model.entity.GlobalConfigDictEntity; +import com.xkrs.model.entity.GlobalConfigEntity; +import com.xkrs.model.qo.GlobalConfigDictQo; +import com.xkrs.service.GlobalConfigService; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.persistence.criteria.Predicate; +import java.util.*; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; + +@Service +public class GlobalConfigServiceImpl implements GlobalConfigService { + + private final Locale locale = LocaleContextHolder.getLocale(); + + @Resource + private GlobalConfigDao globalConfigDao; + + @Resource + private GlobalConfigDictDao globalConfigDictDao; + + @Override + public String selectGlobalConfigDict() { + List globalConfigDictList = globalConfigDictDao.findAll(Sort.by(Sort.Direction.ASC, "id")); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigDictList, locale); + } + + @Override + public Long selectGlobalConfigValue(Long code) { + try { + Optional existsGlobalConfigOptional = globalConfigDao.findByCode(code); + if (existsGlobalConfigOptional.isEmpty()) { + return 0L; + } + return existsGlobalConfigOptional.get().getValue(); + } catch (Exception e) { + e.printStackTrace(); + } + return 0L; + } + + @Override + public String selectGlobalConfig(Long code) { + Specification specification = (root, criteriaQuery, criteriaBuilder) -> { + //查询条件集合 + List predicateList = new ArrayList<>(); + if (code != null) { + predicateList.add(criteriaBuilder.equal(root.get("code").as(Long.class), code)); + } + Predicate[] predicateArray = new Predicate[predicateList.size()]; + return criteriaBuilder.and(predicateList.toArray(predicateArray)); + }; + List globalConfigList = globalConfigDao.findAll(specification, Sort.by(Sort.Direction.ASC, "id")); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, globalConfigList, locale); + } + + @Override + public String globalConfig(Map globalConfigMap) { + if (globalConfigMap == null || globalConfigMap.isEmpty()) { + return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale); + } + for (Map.Entry entry : globalConfigMap.entrySet()) { + Long code = entry.getKey(); + Long value = entry.getValue(); + if (code == null || value == null) { + continue; + } + Optional existsGlobalConfigOptional = globalConfigDao.findByCode(code); + if (existsGlobalConfigOptional.isEmpty()) { + GlobalConfigEntity globalConfigEntity = new GlobalConfigEntity(); + globalConfigEntity.setCode(code); + globalConfigEntity.setValue(value); + globalConfigDao.save(globalConfigEntity); + } else { + GlobalConfigEntity existsGlobalConfig = existsGlobalConfigOptional.get(); + existsGlobalConfig.setCode(code); + existsGlobalConfig.setValue(value); + globalConfigDao.save(existsGlobalConfig); + } + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); + } + + @Override + public String globalConfigDict(GlobalConfigDictQo globalConfigDictQo) { + Long code = globalConfigDictQo.getCode(); + String name = globalConfigDictQo.getName(); + String remark = globalConfigDictQo.getRemark(); + Optional existsGlobalConfigDictOptional = globalConfigDictDao.findByCode(code); + if (existsGlobalConfigDictOptional.isPresent()) { + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "配置失败", locale); + } + GlobalConfigDictEntity globalConfigDictEntity = new GlobalConfigDictEntity(); + globalConfigDictEntity.setCode(code); + globalConfigDictEntity.setName(name); + globalConfigDictEntity.setRemark(remark); + globalConfigDictDao.save(globalConfigDictEntity); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale); + } + +} diff --git a/src/main/java/com/xkrs/utils/ConfigConstant.java b/src/main/java/com/xkrs/utils/ConfigConstant.java deleted file mode 100644 index 8c58083..0000000 --- a/src/main/java/com/xkrs/utils/ConfigConstant.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.xkrs.utils; - -public interface ConfigConstant { - - Long STATE_ACTIVE = 1L; - -}