优化
This commit is contained in:
parent
5a319287a1
commit
e14962bc5f
@ -78,11 +78,6 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
|||||||
throw new DisabledException("该账号还未激活,请联系管理员");
|
throw new DisabledException("该账号还未激活,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查用户状态是否正常
|
|
||||||
if (userEntity.getStatusCode() != 0) {
|
|
||||||
throw new DisabledException("用户状态不正常,请联系管理员");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 认证逻辑
|
// 认证逻辑
|
||||||
String encryptPassword = encry256(password + userEntity.getSalt());
|
String encryptPassword = encry256(password + userEntity.getSalt());
|
||||||
if (encryptPassword.equals(userEntity.getPassword())) {
|
if (encryptPassword.equals(userEntity.getPassword())) {
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package com.xkrs.common.tool;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CompareVersion 比较版本号
|
|
||||||
* @author tajochen
|
|
||||||
*/
|
|
||||||
public class CompareVersion {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 比较三位版本号 ,若 版本1>版本2 返回 1,若版本1<版本2 返回 -1,否则返回0
|
|
||||||
* @param version1 版本1
|
|
||||||
* @param version2 版本2
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static int compareVersion(String version1, String version2) {
|
|
||||||
String[] v1 = version1.split("\\.");
|
|
||||||
String[] v2 = version2.split("\\.");
|
|
||||||
int n = Math.max(v1.length, v2.length);
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
int v1Int = i < v1.length ? Integer.parseInt(v1[i]) : 0;
|
|
||||||
int v2Int = i < v2.length ? Integer.parseInt(v2[i]) : 0;
|
|
||||||
if (v1Int == v2Int) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (v1Int > v2Int){
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
package com.xkrs.common.tool;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dao接口类处理工具
|
|
||||||
* @author tajochen
|
|
||||||
*/
|
|
||||||
public class EntityUtil {
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(EntityUtil.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 将数组数据转换为实体类
|
|
||||||
* 此处数组元素的顺序必须与实体类构造函数中的属性顺序一致
|
|
||||||
* @param list 数组对象集合
|
|
||||||
* @param clazz 实体类
|
|
||||||
* @param <T> 实体类
|
|
||||||
* @param model 实例化的实体类
|
|
||||||
* @return 实体类集合
|
|
||||||
*/
|
|
||||||
public static <T> List<T> castEntity(List<Object[]> list, Class<T> clazz, Object model) {
|
|
||||||
List<T> returnList = new ArrayList<T>();
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
//获取每个数组集合的元素个数
|
|
||||||
Object[] co = list.get(0);
|
|
||||||
|
|
||||||
//获取当前实体类的属性名、属性值、属性类别
|
|
||||||
List<Map> attributeInfoList = getFiledsInfo(model);
|
|
||||||
//创建属性类别数组
|
|
||||||
Class[] c2 = new Class[attributeInfoList.size()];
|
|
||||||
//如果数组集合元素个数与实体类属性个数不一致则发生错误
|
|
||||||
if (attributeInfoList.size() != co.length) {
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
//确定构造方法
|
|
||||||
for (int i = 0; i < attributeInfoList.size(); i++) {
|
|
||||||
c2[i] = (Class) attributeInfoList.get(i).get("type");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
for (Object[] o : list) {
|
|
||||||
Constructor<T> constructor = clazz.getConstructor(c2);
|
|
||||||
returnList.add(constructor.newInstance(o));
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.error("实体数据转化为实体类发生异常:异常信息:{}", ex.getMessage());
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
return returnList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据属性名获取属性值
|
|
||||||
* @param fieldName 属性名
|
|
||||||
* @param modle 实体类
|
|
||||||
* @return 属性值
|
|
||||||
*/
|
|
||||||
private static Object getFieldValueByName(String fieldName, Object modle) {
|
|
||||||
try {
|
|
||||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
|
||||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
|
||||||
Method method = modle.getClass().getMethod(getter, new Class[]{});
|
|
||||||
Object value = method.invoke(modle, new Object[]{});
|
|
||||||
return value;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取属性类型(type),属性名(name),属性值(value)的map组成的list
|
|
||||||
* @param model 实体类
|
|
||||||
* @return list集合
|
|
||||||
*/
|
|
||||||
private static List<Map> getFiledsInfo(Object model) {
|
|
||||||
Field[] fields = model.getClass().getDeclaredFields();
|
|
||||||
List<Map> list = new ArrayList(fields.length);
|
|
||||||
Map infoMap = null;
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
infoMap = new HashMap(3);
|
|
||||||
infoMap.put("type", fields[i].getType());
|
|
||||||
infoMap.put("name", fields[i].getName());
|
|
||||||
infoMap.put("value", getFieldValueByName(fields[i].getName(), model));
|
|
||||||
list.add(infoMap);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,8 +32,7 @@ public class PushController {
|
|||||||
@PostMapping("/bindUserPushInfo")
|
@PostMapping("/bindUserPushInfo")
|
||||||
public String bindUserPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) {
|
public String bindUserPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) {
|
||||||
Long id = sysUserPushAccountQo.getId();
|
Long id = sysUserPushAccountQo.getId();
|
||||||
String regID = sysUserPushAccountQo.getRegID();
|
String pushId = sysUserPushAccountQo.getPushId();
|
||||||
String userAccount = sysUserPushAccountQo.getUserAccount();
|
|
||||||
if (null == id) {
|
if (null == id) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,id == null", locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,id == null", locale);
|
||||||
}
|
}
|
||||||
@ -41,17 +40,12 @@ public class PushController {
|
|||||||
if (targetSysUserOptional.isEmpty()) {
|
if (targetSysUserOptional.isEmpty()) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,id不存在", locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,id不存在", locale);
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(regID)) {
|
if (TextUtils.isEmpty(pushId)) {
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,regID == null", locale);
|
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,pushId == null", locale);
|
||||||
}
|
|
||||||
if (TextUtils.isEmpty(userAccount)) {
|
|
||||||
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "绑定失败,userAccount == null", locale);
|
|
||||||
}
|
}
|
||||||
SysUserEntity targetSysUser = targetSysUserOptional.get();
|
SysUserEntity targetSysUser = targetSysUserOptional.get();
|
||||||
// 更新 regID
|
// 更新 pushId
|
||||||
targetSysUser.setPushRegID(regID);
|
targetSysUser.setPushId(pushId);
|
||||||
// 更新 userAccount
|
|
||||||
targetSysUser.setPushUserAccount(userAccount);
|
|
||||||
sysUserDao.save(targetSysUser);
|
sysUserDao.save(targetSysUser);
|
||||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "绑定成功", locale);
|
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "绑定成功", locale);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,7 @@ public class SysUserPushAccountQo {
|
|||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String regID;
|
private String pushId;
|
||||||
|
|
||||||
private String userAccount;
|
|
||||||
|
|
||||||
public SysUserPushAccountQo() {
|
public SysUserPushAccountQo() {
|
||||||
}
|
}
|
||||||
@ -19,19 +17,11 @@ public class SysUserPushAccountQo {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRegID() {
|
public String getPushId() {
|
||||||
return regID;
|
return pushId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegID(String regID) {
|
public void setPushId(String pushId) {
|
||||||
this.regID = regID;
|
this.pushId = pushId;
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserAccount() {
|
|
||||||
return userAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserAccount(String userAccount) {
|
|
||||||
this.userAccount = userAccount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,14 +18,14 @@ public class PushHelper {
|
|||||||
public PushHelper() {
|
public PushHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> obtainUserAccountList(List<SysUserEntity> sysUserList) {
|
public List<String> obtainUserPushIdList(List<SysUserEntity> sysUserList) {
|
||||||
List<String> userAccountList = new ArrayList<>();
|
List<String> userPushIdList = new ArrayList<>();
|
||||||
if (sysUserList != null && sysUserList.size() > 0) {
|
if (sysUserList != null && sysUserList.size() > 0) {
|
||||||
for (SysUserEntity sysUserEntity : sysUserList) {
|
for (SysUserEntity sysUserEntity : sysUserList) {
|
||||||
userAccountList.add(sysUserEntity.getPushUserAccount());
|
userPushIdList.add(sysUserEntity.getPushId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return userAccountList;
|
return userPushIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,15 +71,9 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
List<SysUserEntity> sysUserList = sysUserDao.findAll();
|
||||||
List<SysUserEntity> vipSysUserList = new ArrayList<>();
|
List<SysUserEntity> vipSysUserList = new ArrayList<>();
|
||||||
for (SysUserEntity sysUser : sysUserList) {
|
for (SysUserEntity sysUser : sysUserList) {
|
||||||
if (sysUser.getDeleteFlag() != 0) {//被删除的用户不属于Vip
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不属于Vip
|
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不属于Vip
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sysUser.getStatusCode() != 0) {//状态不正常的用户不属于Vip
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ("管理员".equals(sysUser.getAccountType())) {//管理员用户不属于Vip
|
if ("管理员".equals(sysUser.getAccountType())) {//管理员用户不属于Vip
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -190,16 +184,13 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
} else {//省市区县账号5天后过期
|
} else {//省市区县账号5天后过期
|
||||||
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
|
sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L)));
|
||||||
}
|
}
|
||||||
sysUserEntity.setStatusCode(0);
|
|
||||||
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
|
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
|
||||||
sysUserEntity.setDeleteFlag(0);
|
|
||||||
sysUserEntity.setLoginNum(0);
|
sysUserEntity.setLoginNum(0);
|
||||||
sysUserEntity.setCountyCode(countyCode);
|
sysUserEntity.setCountyCode(countyCode);
|
||||||
sysUserEntity.setCountyName(countyName);
|
sysUserEntity.setCountyName(countyName);
|
||||||
sysUserEntity.setVipLevel(0);
|
sysUserEntity.setVipLevel(0);
|
||||||
sysUserEntity.setReceiveSms(0);
|
sysUserEntity.setReceiveSms(0);
|
||||||
sysUserEntity.setRemark("");//备注
|
sysUserEntity.setRemark("");//备注
|
||||||
sysUserEntity.setAgentOrgId(sysUserQo.getAgentOrgId() == null ? 1L : sysUserQo.getAgentOrgId());
|
|
||||||
sysUserDao.save(sysUserEntity);
|
sysUserDao.save(sysUserEntity);
|
||||||
|
|
||||||
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
|
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();
|
||||||
|
@ -45,18 +45,12 @@ public class FirePointCodeUtils {
|
|||||||
try {
|
try {
|
||||||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode());
|
String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode());
|
||||||
if (firePointStreetCode.startsWith(formatCutCode)) {
|
if (firePointStreetCode.startsWith(formatCutCode)) {
|
||||||
if (sysUser.getDeleteFlag() != 0) {//被删除的用户不发短信
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
|
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信
|
if (sysUser.getReceiveSms() != 1) {//关掉开关的用户不发短信
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sysUser.getStatusCode() != 0) {//状态不正常的用户不发短信
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ("管理员".equals(sysUser.getAccountType())) {//管理员用户不发短信
|
if ("管理员".equals(sysUser.getAccountType())) {//管理员用户不发短信
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,88 +0,0 @@
|
|||||||
package com.xkrs.utils;
|
|
||||||
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author XinYi Song
|
|
||||||
*/
|
|
||||||
public class ObjectToBeanUtils {
|
|
||||||
|
|
||||||
public static Logger log = LoggerFactory.getLogger(ObjectToBeanUtils.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 把List<Object[]>转换成List<T>
|
|
||||||
*/
|
|
||||||
public static <T> List<T> objectToBean(List<Object[]> objList, Class<T> clz) throws Exception {
|
|
||||||
if (objList == null || objList.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Class<?>[] cz = null;
|
|
||||||
Constructor<?>[] cons = clz.getConstructors();
|
|
||||||
for (Constructor<?> ct : cons) {
|
|
||||||
Class<?>[] clazz = ct.getParameterTypes();
|
|
||||||
if (objList.get(0).length == clazz.length) {
|
|
||||||
cz = clazz;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<T> list = new ArrayList<T>();
|
|
||||||
for (Object[] obj : objList) {
|
|
||||||
Constructor<T> cr = clz.getConstructor(cz);
|
|
||||||
list.add(cr.newInstance(obj));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据属性名获取属性值
|
|
||||||
*
|
|
||||||
* @param fieldName 属性名
|
|
||||||
* @param modle 实体类
|
|
||||||
* @return 属性值
|
|
||||||
*/
|
|
||||||
private static Object getFieldValueByName(String fieldName, Object modle) {
|
|
||||||
try {
|
|
||||||
String firstLetter = fieldName.substring(0, 1).toUpperCase();
|
|
||||||
String getter = "get" + firstLetter + fieldName.substring(1);
|
|
||||||
Method method = modle.getClass().getMethod(getter, new Class[]{});
|
|
||||||
Object value = method.invoke(modle, new Object[]{});
|
|
||||||
return value;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取属性类型(type),属性名(name),属性值(value)的map组成的list
|
|
||||||
*
|
|
||||||
* @param model 实体类
|
|
||||||
* @return list集合
|
|
||||||
*/
|
|
||||||
private static List<Map> getFiledsInfo(Object model) {
|
|
||||||
Field[] fields = model.getClass().getDeclaredFields();
|
|
||||||
List<Map> list = new ArrayList(fields.length);
|
|
||||||
Map infoMap = null;
|
|
||||||
for (int i = 0; i < fields.length; i++) {
|
|
||||||
infoMap = new HashMap(3);
|
|
||||||
infoMap.put("type", fields[i].getType());
|
|
||||||
infoMap.put("name", fields[i].getName());
|
|
||||||
infoMap.put("value", getFieldValueByName(fields[i].getName(), model));
|
|
||||||
list.add(infoMap);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.xkrs.websocket.controller.websocketbroker;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author xkrs
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class ViewController extends WebMvcConfigurerAdapter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addViewControllers(ViewControllerRegistry registry) {
|
|
||||||
registry.addViewController("/ws").setViewName("/ws");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user