添加全局配置服务
This commit is contained in:
parent
18074cf605
commit
1af9c92788
@ -2,6 +2,7 @@ package com.xkrs.common.account;
|
|||||||
|
|
||||||
import com.xkrs.model.entity.SysAuthorityEntity;
|
import com.xkrs.model.entity.SysAuthorityEntity;
|
||||||
import com.xkrs.model.entity.SysUserEntity;
|
import com.xkrs.model.entity.SysUserEntity;
|
||||||
|
import com.xkrs.service.ConfigGlobalUserService;
|
||||||
import com.xkrs.service.SysAuthorityService;
|
import com.xkrs.service.SysAuthorityService;
|
||||||
import com.xkrs.service.SysRoleService;
|
import com.xkrs.service.SysRoleService;
|
||||||
import com.xkrs.service.SysUserService;
|
import com.xkrs.service.SysUserService;
|
||||||
@ -25,6 +26,7 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义认证Provider
|
* 自定义认证Provider
|
||||||
|
*
|
||||||
* @author tajochen
|
* @author tajochen
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@ -39,6 +41,9 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysAuthorityService sysAuthorityService;
|
private SysAuthorityService sysAuthorityService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalUserService configGlobalUserService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初使化时将已静态化的Service实例化
|
* 初使化时将已静态化的Service实例化
|
||||||
*/
|
*/
|
||||||
@ -53,10 +58,12 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||||||
customAuthenticationProvider.sysUserService = this.sysUserService;
|
customAuthenticationProvider.sysUserService = this.sysUserService;
|
||||||
customAuthenticationProvider.sysRoleService = this.sysRoleService;
|
customAuthenticationProvider.sysRoleService = this.sysRoleService;
|
||||||
customAuthenticationProvider.sysAuthorityService = this.sysAuthorityService;
|
customAuthenticationProvider.sysAuthorityService = this.sysAuthorityService;
|
||||||
|
customAuthenticationProvider.configGlobalUserService = this.configGlobalUserService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户认证授权
|
* 用户认证授权
|
||||||
|
*
|
||||||
* @param authentication
|
* @param authentication
|
||||||
* @return
|
* @return
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
@ -70,23 +77,25 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||||||
SysUserEntity userEntity = customAuthenticationProvider.sysUserService.getSysUserByUserName(userName);
|
SysUserEntity userEntity = customAuthenticationProvider.sysUserService.getSysUserByUserName(userName);
|
||||||
|
|
||||||
// 检查用户是否存在
|
// 检查用户是否存在
|
||||||
if(userEntity == null){
|
if (userEntity == null) {
|
||||||
throw new BadCredentialsException("账号不存在或错误,请您确认注册");
|
throw new BadCredentialsException("账号不存在或错误,请您确认注册");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查用户是否激活
|
// 检查用户是否激活
|
||||||
if(userEntity.getActiveFlag().intValue() != 0){
|
if (userEntity.getActiveFlag().intValue() != 0) {
|
||||||
throw new DisabledException("该账号还未激活,请联系管理员");
|
throw new DisabledException("该账号还未激活,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查用户状态是否正常
|
//检查用户状态是否正常
|
||||||
if(userEntity.getStatusCode() != 0){
|
if (userEntity.getStatusCode() != 0) {
|
||||||
throw new DisabledException("用户状态不正常,请联系管理员");
|
throw new DisabledException("用户状态不正常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(userEntity.getDayNum() == 7){
|
if (userEntity.getDayNum() == 7) {
|
||||||
if(DateTimeUtil.dateTimeToString(LocalDateTime.now()).compareTo(userEntity.getOverTime()) > 0){
|
if (DateTimeUtil.dateTimeToString(LocalDateTime.now()).compareTo(userEntity.getOverTime()) > 0) {
|
||||||
throw new DisabledException("该账号已过期,请联系管理员");
|
if (!customAuthenticationProvider.configGlobalUserService.loginAbleWhenExpired()) {
|
||||||
|
throw new DisabledException("该账号已过期,请联系管理员");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,22 +106,22 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||||||
ArrayList<GrantedAuthority> permissions = new ArrayList<>();
|
ArrayList<GrantedAuthority> permissions = new ArrayList<>();
|
||||||
List<Integer> integers = customAuthenticationProvider.sysAuthorityService.selectAuthorityByUserId(userEntity.getId());
|
List<Integer> integers = customAuthenticationProvider.sysAuthorityService.selectAuthorityByUserId(userEntity.getId());
|
||||||
List<SysAuthorityEntity> permissionList = customAuthenticationProvider.sysAuthorityService.findAllByIdIn(integers);
|
List<SysAuthorityEntity> permissionList = customAuthenticationProvider.sysAuthorityService.findAllByIdIn(integers);
|
||||||
for(SysAuthorityEntity sysAuthorityEntity : permissionList) {
|
for (SysAuthorityEntity sysAuthorityEntity : permissionList) {
|
||||||
permissions.add(new GrantedAuthorityImpl(sysAuthorityEntity.getAuthorityName()));
|
permissions.add(new GrantedAuthorityImpl(sysAuthorityEntity.getAuthorityName()));
|
||||||
}
|
}
|
||||||
customAuthenticationProvider.sysUserService.updateLoginNum(userEntity.getId(),userEntity.getLoginNum() + 1);
|
customAuthenticationProvider.sysUserService.updateLoginNum(userEntity.getId(), userEntity.getLoginNum() + 1);
|
||||||
customAuthenticationProvider.sysUserService.updateLoginLastTime(userEntity.getId(),DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
customAuthenticationProvider.sysUserService.updateLoginLastTime(userEntity.getId(), DateTimeUtil.dateTimeToString(LocalDateTime.now()));
|
||||||
// 生成令牌
|
// 生成令牌
|
||||||
Authentication authToken = new UsernamePasswordAuthenticationToken(userName, encryptPassword, permissions);
|
Authentication authToken = new UsernamePasswordAuthenticationToken(userName, encryptPassword, permissions);
|
||||||
return authToken;
|
return authToken;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw new BadCredentialsException("用户密码错误,请重新输入");
|
throw new BadCredentialsException("用户密码错误,请重新输入");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否可以提供输入类型的认证服务
|
* 是否可以提供输入类型的认证服务
|
||||||
|
*
|
||||||
* @param authentication
|
* @param authentication
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -2,7 +2,10 @@ package com.xkrs.common.account;
|
|||||||
|
|
||||||
import com.xkrs.common.encapsulation.OutputEncapsulation;
|
import com.xkrs.common.encapsulation.OutputEncapsulation;
|
||||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
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.model.vo.SysUserVo;
|
||||||
|
import com.xkrs.service.ConfigGlobalFirePointService;
|
||||||
import com.xkrs.service.SysUserService;
|
import com.xkrs.service.SysUserService;
|
||||||
import com.xkrs.utils.IpUtil;
|
import com.xkrs.utils.IpUtil;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -21,7 +24,6 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -41,6 +43,9 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysUserService sysUserService;
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalFirePointService configGlobalFirePointService;
|
||||||
|
|
||||||
public JwtLoginFilter(String url, AuthenticationManager authManager) {
|
public JwtLoginFilter(String url, AuthenticationManager authManager) {
|
||||||
super(new AntPathRequestMatcher(url));
|
super(new AntPathRequestMatcher(url));
|
||||||
setAuthenticationManager(authManager);
|
setAuthenticationManager(authManager);
|
||||||
@ -48,10 +53,6 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录时验证
|
* 登录时验证
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* @param res
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) throws UnsupportedEncodingException {
|
public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) throws UnsupportedEncodingException {
|
||||||
@ -79,13 +80,6 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证成功后调用
|
* 验证成功后调用
|
||||||
*
|
|
||||||
* @param req
|
|
||||||
* @param response
|
|
||||||
* @param chain
|
|
||||||
* @param auth
|
|
||||||
* @throws IOException
|
|
||||||
* @throws ServletException
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse response, FilterChain chain, Authentication auth) {
|
protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse response, FilterChain chain, Authentication auth) {
|
||||||
@ -94,6 +88,12 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|||||||
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
|
||||||
sysUserService = webApplicationContext.getBean(SysUserService.class);
|
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));
|
sysUserService.updateSysUserLogin(auth.getName(), IpUtil.getIpAddr(req));
|
||||||
SysUserVo userByUserName = sysUserService.getUserByUserName(auth.getName());
|
SysUserVo userByUserName = sysUserService.getUserByUserName(auth.getName());
|
||||||
@ -101,16 +101,31 @@ public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter {
|
|||||||
response.setHeader("Access-Control-Allow-Credentials", "false");
|
response.setHeader("Access-Control-Allow-Credentials", "false");
|
||||||
response.setContentType("application/json");
|
response.setContentType("application/json");
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
TokenAuthenticationService.addAuthentication(response, auth.getName(), auth.getAuthorities(), userByUserName);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证失败后调用
|
* 验证失败后调用
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @param response
|
|
||||||
* @param failed
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) throws IOException {
|
protected void unsuccessfulAuthentication(HttpServletRequest request, HttpServletResponse response, AuthenticationException failed) throws IOException {
|
||||||
|
@ -2,8 +2,8 @@ package com.xkrs.common.account;
|
|||||||
|
|
||||||
import com.xkrs.common.encapsulation.OutputEncapsulation;
|
import com.xkrs.common.encapsulation.OutputEncapsulation;
|
||||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||||
|
import com.xkrs.model.vo.ConfigVo;
|
||||||
import com.xkrs.model.vo.SysUserVo;
|
import com.xkrs.model.vo.SysUserVo;
|
||||||
import com.xkrs.utils.DateTimeUtil;
|
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.security.Keys;
|
import io.jsonwebtoken.security.Keys;
|
||||||
@ -19,8 +19,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +52,7 @@ public class TokenAuthenticationService {
|
|||||||
* @param userName
|
* @param userName
|
||||||
* @param authorities
|
* @param authorities
|
||||||
*/
|
*/
|
||||||
static void addAuthentication(HttpServletResponse response, String userName, Collection<? extends GrantedAuthority> authorities, SysUserVo sysUserEntity) {
|
static void addAuthentication(HttpServletResponse response, String userName, Collection<? extends GrantedAuthority> authorities, SysUserVo sysUserEntity, ConfigVo config) {
|
||||||
|
|
||||||
Locale locale = new Locale("zh", "CN");
|
Locale locale = new Locale("zh", "CN");
|
||||||
Map map = new HashMap(3);
|
Map map = new HashMap(3);
|
||||||
@ -69,43 +67,61 @@ public class TokenAuthenticationService {
|
|||||||
} else {
|
} else {
|
||||||
logger.warn(userName + " has no permission!");
|
logger.warn(userName + " has no permission!");
|
||||||
}
|
}
|
||||||
if (sysUserEntity.getDayNum() == 7) {
|
// if (sysUserEntity.getDayNum() == 7) {
|
||||||
// 结束的时间
|
// // 结束的时间
|
||||||
LocalDateTime overTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
// LocalDateTime overTime = DateTimeUtil.stringToDateTime(sysUserEntity.getOverTime());
|
||||||
// 计算距离结束时间的天数作为token
|
// // 计算距离结束时间的天数作为token
|
||||||
Duration duration = Duration.between(LocalDateTime.now(), overTime);
|
// Duration duration = Duration.between(LocalDateTime.now(), overTime);
|
||||||
/**
|
// /**
|
||||||
* 动态设置过期时间
|
// * 动态设置过期时间
|
||||||
*/
|
// */
|
||||||
final long EXPIRATIONTIME = 60 * 60 * (duration.toDays() + 1) * 24_000;
|
// 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
|
// 生成JWT
|
||||||
String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName)
|
String jwt = Jwts.builder().setSubject(userName).setIssuer("https://www.microservice.com").setAudience(userName)
|
||||||
// 保存权限
|
// 保存权限
|
||||||
.claim("auths", authsList)
|
.claim("auths", authsList)
|
||||||
// 有效期设置
|
// 有效期设置
|
||||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
||||||
// 签名设置
|
// 签名设置
|
||||||
.signWith(key).compact();
|
.signWith(key).compact();
|
||||||
map.put("token", jwt);
|
map.put("token", jwt);
|
||||||
map.put("user", sysUserEntity);
|
map.put("user", sysUserEntity);
|
||||||
} else {
|
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)
|
|
||||||
// 保存权限
|
|
||||||
.claim("auths", authsList)
|
|
||||||
// 有效期设置
|
|
||||||
.setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME))
|
|
||||||
// 签名设置
|
|
||||||
.signWith(key).compact();
|
|
||||||
map.put("token", jwt);
|
|
||||||
map.put("user", sysUserEntity);
|
|
||||||
}
|
|
||||||
// 将 JWT 写入 body
|
// 将 JWT 写入 body
|
||||||
PrintWriter out = null;
|
PrintWriter out = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.xkrs.controller;
|
package com.xkrs.controller;
|
||||||
|
|
||||||
import com.xkrs.service.ConfigGlobalService;
|
import com.xkrs.service.ConfigGlobalFirePointService;
|
||||||
|
import com.xkrs.service.ConfigGlobalSMSService;
|
||||||
|
import com.xkrs.service.ConfigGlobalUserService;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@ -16,30 +18,25 @@ import java.util.Map;
|
|||||||
public class ConfigGlobalController {
|
public class ConfigGlobalController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ConfigGlobalService configGlobalService;
|
private ConfigGlobalUserService configGlobalUserService;
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalFirePointService configGlobalFirePointService;
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalSMSService configGlobalSMSService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户全局配置服务
|
|
||||||
*/
|
|
||||||
@PostMapping("/configGlobalUser")
|
@PostMapping("/configGlobalUser")
|
||||||
public String configGlobalUser(@Nullable @RequestBody Map<String, Long> configMap) {
|
public String configGlobalUser(@Nullable @RequestBody Map<String, Long> configMap) {
|
||||||
return configGlobalService.configGlobalUser(configMap);
|
return configGlobalUserService.configGlobalUser(configMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 火情信息全局配置服务
|
|
||||||
*/
|
|
||||||
@PostMapping("/configGlobalFirePoint")
|
@PostMapping("/configGlobalFirePoint")
|
||||||
public String configGlobalFirePoint(@Nullable @RequestBody Map<String, Long> configMap) {
|
public String configGlobalFirePoint(@Nullable @RequestBody Map<String, Long> configMap) {
|
||||||
return configGlobalService.configGlobalFirePoint(configMap);
|
return configGlobalFirePointService.configGlobalFirePoint(configMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信全局配置服务
|
|
||||||
*/
|
|
||||||
@PostMapping("/configGlobalSMS")
|
@PostMapping("/configGlobalSMS")
|
||||||
public String configGlobalSMS(@Nullable @RequestBody Map<String, Long> configMap) {
|
public String configGlobalSMS(@Nullable @RequestBody Map<String, Long> configMap) {
|
||||||
return configGlobalService.configGlobalSMS(configMap);
|
return configGlobalSMSService.configGlobalSMS(configMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,21 +20,29 @@ public class ConfigGlobalFirePointEntity implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期后能否获取今日火情信息
|
* 过期后能否获取今日火情信息
|
||||||
|
* 0:不能获取
|
||||||
|
* 1:能够获取
|
||||||
*/
|
*/
|
||||||
private Long todayAbleWhenExpired;
|
private Long todayAbleWhenExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期后能否获取历史火情信息
|
* 过期后能否获取历史火情信息
|
||||||
|
* 0:不能获取
|
||||||
|
* 1:能够获取
|
||||||
*/
|
*/
|
||||||
private Long historyAbleWhenExpired;
|
private Long historyAbleWhenExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期后能否获取统计分析数据
|
* 过期后能否获取统计分析数据
|
||||||
|
* 0:不能获取
|
||||||
|
* 1:能够获取
|
||||||
*/
|
*/
|
||||||
private Long statisticsAbleWhenExpired;
|
private Long statisticsAbleWhenExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过期后能否使用导航功能
|
* 过期后能否使用导航功能
|
||||||
|
* 0:不能导航
|
||||||
|
* 1:能够导航
|
||||||
*/
|
*/
|
||||||
private Long navigateAbleWhenExpired;
|
private Long navigateAbleWhenExpired;
|
||||||
|
|
||||||
|
@ -27,41 +27,53 @@ public class ConfigGlobalSMSEntity implements Serializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 省过期前能否提前通知
|
* 省过期前能否提前通知
|
||||||
|
* 0:不能通知
|
||||||
|
* 1:能够通知
|
||||||
*/
|
*/
|
||||||
private Long proAnAbleBeforeExpired;
|
private Long proAnAbleBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省过期前提前几天短信通知
|
* 省过期前提前几天短信通知
|
||||||
|
* 天数
|
||||||
*/
|
*/
|
||||||
private Long proAnDayBeforeExpired;
|
private Long proAnDayBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 市过期前能否提前通知
|
* 市过期前能否提前通知
|
||||||
|
* 0:不能通知
|
||||||
|
* 1:能够通知
|
||||||
*/
|
*/
|
||||||
private Long cityAnAbleBeforeExpired;
|
private Long cityAnAbleBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 市过期前提前几天短信通知
|
* 市过期前提前几天短信通知
|
||||||
|
* 天数
|
||||||
*/
|
*/
|
||||||
private Long cityAnDayBeforeExpired;
|
private Long cityAnDayBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 区县过期前能否提前通知
|
* 区县过期前能否提前通知
|
||||||
|
* 0:不能通知
|
||||||
|
* 1:能够通知
|
||||||
*/
|
*/
|
||||||
private Long countyAnAbleBeforeExpired;
|
private Long countyAnAbleBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 区县过期前提前几天短信通知
|
* 区县过期前提前几天短信通知
|
||||||
|
* 天数
|
||||||
*/
|
*/
|
||||||
private Long countyAnDayBeforeExpired;
|
private Long countyAnDayBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 街道过期前能否提前通知
|
* 街道过期前能否提前通知
|
||||||
|
* 0:不能通知
|
||||||
|
* 1:能够通知
|
||||||
*/
|
*/
|
||||||
private Long streetAnAbleBeforeExpired;
|
private Long streetAnAbleBeforeExpired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 街道过期前提前几天短信通知
|
* 街道过期前提前几天短信通知
|
||||||
|
* 天数
|
||||||
*/
|
*/
|
||||||
private Long streetAnDayBeforeExpired;
|
private Long streetAnDayBeforeExpired;
|
||||||
|
|
||||||
|
69
src/main/java/com/xkrs/model/vo/ConfigVo.java
Normal file
69
src/main/java/com/xkrs/model/vo/ConfigVo.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
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<String, Long> configMap);
|
||||||
|
|
||||||
|
}
|
30
src/main/java/com/xkrs/service/ConfigGlobalSMSService.java
Normal file
30
src/main/java/com/xkrs/service/ConfigGlobalSMSService.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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<String, Long> configMap);
|
||||||
|
|
||||||
|
}
|
@ -1,25 +0,0 @@
|
|||||||
package com.xkrs.service;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局配置服务
|
|
||||||
*/
|
|
||||||
public interface ConfigGlobalService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户全局配置服务
|
|
||||||
*/
|
|
||||||
String configGlobalUser(Map<String, Long> configMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火情信息全局配置服务
|
|
||||||
*/
|
|
||||||
String configGlobalFirePoint(Map<String, Long> configMap);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 短信全局配置服务
|
|
||||||
*/
|
|
||||||
String configGlobalSMS(Map<String, Long> configMap);
|
|
||||||
|
|
||||||
}
|
|
14
src/main/java/com/xkrs/service/ConfigGlobalUserService.java
Normal file
14
src/main/java/com/xkrs/service/ConfigGlobalUserService.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.xkrs.service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户全局配置服务
|
||||||
|
*/
|
||||||
|
public interface ConfigGlobalUserService {
|
||||||
|
|
||||||
|
boolean loginAbleWhenExpired();
|
||||||
|
|
||||||
|
String configGlobalUser(Map<String, Long> configMap);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,126 @@
|
|||||||
|
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<String, Long> 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<ConfigGlobalFirePointEntity> 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,10 @@
|
|||||||
package com.xkrs.service.impl;
|
package com.xkrs.service.impl;
|
||||||
|
|
||||||
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
import com.xkrs.common.encapsulation.PromptMessageEnum;
|
||||||
import com.xkrs.dao.ConfigGlobalFirePointDao;
|
|
||||||
import com.xkrs.dao.ConfigGlobalSMSDao;
|
import com.xkrs.dao.ConfigGlobalSMSDao;
|
||||||
import com.xkrs.dao.ConfigGlobalUserDao;
|
|
||||||
import com.xkrs.model.entity.ConfigGlobalFirePointEntity;
|
|
||||||
import com.xkrs.model.entity.ConfigGlobalSMSEntity;
|
import com.xkrs.model.entity.ConfigGlobalSMSEntity;
|
||||||
import com.xkrs.model.entity.ConfigGlobalUserEntity;
|
import com.xkrs.service.ConfigGlobalSMSService;
|
||||||
import com.xkrs.service.ConfigGlobalService;
|
import com.xkrs.utils.ConfigConstant;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -19,121 +16,123 @@ import java.util.Map;
|
|||||||
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局配置服务
|
* 短信全局配置服务
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ConfigGlobalServiceImpl implements ConfigGlobalService {
|
public class ConfigGlobalSMSServiceImpl implements ConfigGlobalSMSService {
|
||||||
|
|
||||||
private final Locale locale = LocaleContextHolder.getLocale();
|
private final Locale locale = LocaleContextHolder.getLocale();
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户全局配置信息
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
private ConfigGlobalUserDao configGlobalUserDao;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 火情信息全局配置信息
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
private ConfigGlobalFirePointDao configGlobalFirePointDao;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 短信全局配置信息
|
* 短信全局配置信息
|
||||||
*/
|
*/
|
||||||
@Resource
|
@Resource
|
||||||
private ConfigGlobalSMSDao configGlobalSMSDao;
|
private ConfigGlobalSMSDao configGlobalSMSDao;
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户全局配置服务
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String configGlobalUser(Map<String, Long> configMap) {
|
public boolean smsAbleWhenExpired() {
|
||||||
if (configMap == null) {
|
try {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
|
return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getSmsAbleWhenExpired().longValue();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Long loginAbleWhenExpired = configMap.get("LoginAbleWhenExpired");
|
return false;
|
||||||
List<ConfigGlobalUserEntity> 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 火情信息全局配置服务
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String configGlobalFirePoint(Map<String, Long> configMap) {
|
public boolean proAnAbleBeforeExpired() {
|
||||||
if (configMap == null) {
|
try {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
|
return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getProAnAbleBeforeExpired().longValue();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Long todayAbleWhenExpired = configMap.get("TodayAbleWhenExpired");
|
return false;
|
||||||
Long historyAbleWhenExpired = configMap.get("HistoryAbleWhenExpired");
|
}
|
||||||
Long statisticsAbleWhenExpired = configMap.get("StatisticsAbleWhenExpired");
|
|
||||||
Long navigateAbleWhenExpired = configMap.get("NavigateAbleWhenExpired");
|
@Override
|
||||||
List<ConfigGlobalFirePointEntity> configGlobalFirePointEntityList = configGlobalFirePointDao.findAll();
|
public long proAnDayBeforeExpired() {
|
||||||
if (configGlobalFirePointEntityList.isEmpty()) {
|
try {
|
||||||
ConfigGlobalFirePointEntity configGlobalFirePointEntity = new ConfigGlobalFirePointEntity();
|
return configGlobalSMSDao.findAll().get(0).getProAnDayBeforeExpired().longValue();
|
||||||
configGlobalFirePointEntity.setTodayAbleWhenExpired(todayAbleWhenExpired);
|
} catch (Exception e) {
|
||||||
configGlobalFirePointEntity.setHistoryAbleWhenExpired(historyAbleWhenExpired);
|
e.printStackTrace();
|
||||||
configGlobalFirePointEntity.setStatisticsAbleWhenExpired(statisticsAbleWhenExpired);
|
}
|
||||||
configGlobalFirePointEntity.setNavigateAbleWhenExpired(navigateAbleWhenExpired);
|
return 0L;
|
||||||
configGlobalFirePointDao.save(configGlobalFirePointEntity);
|
}
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
|
|
||||||
}
|
@Override
|
||||||
ConfigGlobalFirePointEntity configGlobalFirePointEntity = configGlobalFirePointEntityList.get(0);
|
public boolean cityAnAbleBeforeExpired() {
|
||||||
if (todayAbleWhenExpired != null) {
|
try {
|
||||||
if (configGlobalFirePointEntity.getTodayAbleWhenExpired() == null || configGlobalFirePointEntity.getTodayAbleWhenExpired().longValue() != todayAbleWhenExpired.longValue()) {
|
return ConfigConstant.STATE_ACTIVE.longValue() == configGlobalSMSDao.findAll().get(0).getCityAnAbleBeforeExpired().longValue();
|
||||||
configGlobalFirePointEntity.setTodayAbleWhenExpired(todayAbleWhenExpired);
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (historyAbleWhenExpired != null) {
|
return false;
|
||||||
if (configGlobalFirePointEntity.getHistoryAbleWhenExpired() == null || configGlobalFirePointEntity.getHistoryAbleWhenExpired().longValue() != historyAbleWhenExpired.longValue()) {
|
}
|
||||||
configGlobalFirePointEntity.setHistoryAbleWhenExpired(historyAbleWhenExpired);
|
|
||||||
}
|
@Override
|
||||||
}
|
public long cityAnDayBeforeExpired() {
|
||||||
if (statisticsAbleWhenExpired != null) {
|
try {
|
||||||
if (configGlobalFirePointEntity.getStatisticsAbleWhenExpired() == null || configGlobalFirePointEntity.getStatisticsAbleWhenExpired().longValue() != statisticsAbleWhenExpired.longValue()) {
|
return configGlobalSMSDao.findAll().get(0).getCityAnDayBeforeExpired().longValue();
|
||||||
configGlobalFirePointEntity.setStatisticsAbleWhenExpired(statisticsAbleWhenExpired);
|
} catch (Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (navigateAbleWhenExpired != null) {
|
return 0L;
|
||||||
if (configGlobalFirePointEntity.getNavigateAbleWhenExpired() == null || configGlobalFirePointEntity.getNavigateAbleWhenExpired().longValue() != navigateAbleWhenExpired.longValue()) {
|
}
|
||||||
configGlobalFirePointEntity.setNavigateAbleWhenExpired(navigateAbleWhenExpired);
|
|
||||||
}
|
@Override
|
||||||
}
|
public boolean countyAnAbleBeforeExpired() {
|
||||||
configGlobalFirePointDao.save(configGlobalFirePointEntity);
|
try {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "配置成功", locale);
|
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
|
@Override
|
||||||
public String configGlobalSMS(Map<String, Long> configMap) {
|
public String configGlobalSMS(Map<String, Long> configMap) {
|
||||||
if (configMap == null) {
|
if (configMap == null) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
|
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
|
||||||
}
|
}
|
||||||
Long smsAbleWhenExpired = configMap.get("SmsAbleWhenExpired");
|
Long smsAbleWhenExpired = configMap.get("smsAbleWhenExpired");
|
||||||
Long proAnAbleBeforeExpired = configMap.get("ProAnAbleBeforeExpired");
|
Long proAnAbleBeforeExpired = configMap.get("proAnAbleBeforeExpired");
|
||||||
Long proAnDayBeforeExpired = configMap.get("ProAnDayBeforeExpired");
|
Long proAnDayBeforeExpired = configMap.get("proAnDayBeforeExpired");
|
||||||
Long cityAnAbleBeforeExpired = configMap.get("CityAnAbleBeforeExpired");
|
Long cityAnAbleBeforeExpired = configMap.get("cityAnAbleBeforeExpired");
|
||||||
Long cityAnDayBeforeExpired = configMap.get("CityAnDayBeforeExpired");
|
Long cityAnDayBeforeExpired = configMap.get("cityAnDayBeforeExpired");
|
||||||
Long countyAnAbleBeforeExpired = configMap.get("CountyAnAbleBeforeExpired");
|
Long countyAnAbleBeforeExpired = configMap.get("countyAnAbleBeforeExpired");
|
||||||
Long countyAnDayBeforeExpired = configMap.get("CountyAnDayBeforeExpired");
|
Long countyAnDayBeforeExpired = configMap.get("countyAnDayBeforeExpired");
|
||||||
Long streetAnAbleBeforeExpired = configMap.get("StreetAnAbleBeforeExpired");
|
Long streetAnAbleBeforeExpired = configMap.get("streetAnAbleBeforeExpired");
|
||||||
Long streetAnDayBeforeExpired = configMap.get("StreetAnDayBeforeExpired");
|
Long streetAnDayBeforeExpired = configMap.get("streetAnDayBeforeExpired");
|
||||||
List<ConfigGlobalSMSEntity> configGlobalSMSEntityList = configGlobalSMSDao.findAll();
|
List<ConfigGlobalSMSEntity> configGlobalSMSEntityList = configGlobalSMSDao.findAll();
|
||||||
if (configGlobalSMSEntityList.isEmpty()) {
|
if (configGlobalSMSEntityList.isEmpty()) {
|
||||||
ConfigGlobalSMSEntity configGlobalSMSEntity = new ConfigGlobalSMSEntity();
|
ConfigGlobalSMSEntity configGlobalSMSEntity = new ConfigGlobalSMSEntity();
|
@ -0,0 +1,65 @@
|
|||||||
|
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<String, Long> configMap) {
|
||||||
|
if (configMap == null) {
|
||||||
|
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "配置失败", locale);
|
||||||
|
}
|
||||||
|
Long loginAbleWhenExpired = configMap.get("loginAbleWhenExpired");
|
||||||
|
List<ConfigGlobalUserEntity> 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -8,6 +8,9 @@ import com.xkrs.model.qo.FirePointQo;
|
|||||||
import com.xkrs.model.vo.AppPhotoVo;
|
import com.xkrs.model.vo.AppPhotoVo;
|
||||||
import com.xkrs.model.vo.AppTaskBodyVo;
|
import com.xkrs.model.vo.AppTaskBodyVo;
|
||||||
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
|
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.FirePointService;
|
||||||
import com.xkrs.utils.*;
|
import com.xkrs.utils.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -84,6 +87,13 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FirePointQueryHelper firePointQueryHelper;
|
private FirePointQueryHelper firePointQueryHelper;
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalUserService configGlobalUserService;
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalFirePointService configGlobalFirePointService;
|
||||||
|
@Resource
|
||||||
|
private ConfigGlobalSMSService configGlobalSMSService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加火点信息
|
* 添加火点信息
|
||||||
@ -423,8 +433,11 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME);
|
LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME);
|
||||||
if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {//过期用户不发短信
|
if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {//过期用户
|
||||||
continue;
|
//过期用户需要根据配置决定是否发送短信
|
||||||
|
if (!configGlobalSMSService.smsAbleWhenExpired()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isAdministrator(administratorList, sysUser)) {//管理员用户不发短信
|
if (isAdministrator(administratorList, sysUser)) {//管理员用户不发短信
|
||||||
continue;
|
continue;
|
||||||
|
7
src/main/java/com/xkrs/utils/ConfigConstant.java
Normal file
7
src/main/java/com/xkrs/utils/ConfigConstant.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.xkrs.utils;
|
||||||
|
|
||||||
|
public interface ConfigConstant {
|
||||||
|
|
||||||
|
Long STATE_ACTIVE = 1L;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user