|
|
@@ -23,6 +23,7 @@ import com.uas.sso.support.SyncFail;
|
|
|
import com.uas.sso.util.AccountTypeUtils;
|
|
|
import com.uas.sso.util.CountUtils;
|
|
|
import com.uas.sso.util.PasswordLevelUtils;
|
|
|
+import net.sf.ehcache.search.aggregator.Count;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
@@ -34,6 +35,7 @@ import org.springframework.util.Assert;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import javax.persistence.Version;
|
|
|
import javax.persistence.criteria.*;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
import java.sql.Timestamp;
|
|
|
@@ -254,9 +256,9 @@ public class UserServiceImpl implements UserService {
|
|
|
/**
|
|
|
* 校验用户密码
|
|
|
*
|
|
|
- * @param oldUser 用户信息
|
|
|
+ * @param oldUser 用户信息
|
|
|
* @param password 需要校验的密码
|
|
|
- * @param isEncry 需校验的密码是否被加密
|
|
|
+ * @param isEncry 需校验的密码是否被加密
|
|
|
*/
|
|
|
private void checkPassword(User oldUser, String password, boolean isEncry) {
|
|
|
// 密码未加密,转换成加密后的密码
|
|
|
@@ -408,12 +410,13 @@ public class UserServiceImpl implements UserService {
|
|
|
syncUserBindSpace(userUU, spaceUU);
|
|
|
|
|
|
// 保存日志
|
|
|
- userLogger.info(user, Type.BIND_USERSPACE.getValue()+spaceUU);
|
|
|
+ userLogger.info(user, Type.BIND_USERSPACE.getValue() + spaceUU);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 同步用户绑定企业关系
|
|
|
- * @param userUU 用户uu号
|
|
|
+ *
|
|
|
+ * @param userUU 用户uu号
|
|
|
* @param spaceUU 企业uu号
|
|
|
*/
|
|
|
private void syncUserBindSpace(Long userUU, Long spaceUU) {
|
|
|
@@ -422,7 +425,8 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
/**
|
|
|
* 同步用户解除绑定企业关系
|
|
|
- * @param userUU 用户uu号
|
|
|
+ *
|
|
|
+ * @param userUU 用户uu号
|
|
|
* @param spaceUU 企业uu号
|
|
|
*/
|
|
|
private void syncUserUnbindSpace(Long userUU, Long spaceUU) {
|
|
|
@@ -431,9 +435,10 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
/**
|
|
|
* 同步用户与企业的关系
|
|
|
- * @param userUU 用户uu号
|
|
|
+ *
|
|
|
+ * @param userUU 用户uu号
|
|
|
* @param spaceUU 企业uu号
|
|
|
- * @param type 类型 (bind or unbind)
|
|
|
+ * @param type 类型 (bind or unbind)
|
|
|
*/
|
|
|
private void syncRelation(final Long userUU, final Long spaceUU, final String type) {
|
|
|
Userspace userspace = userspaceService.findOne(spaceUU);
|
|
|
@@ -492,7 +497,7 @@ public class UserServiceImpl implements UserService {
|
|
|
syncUserUnbindSpace(userUU, spaceUU);
|
|
|
|
|
|
// 保存日志
|
|
|
- userLogger.info(user, Type.UNBIND_USERSPACE.getValue()+spaceUU);
|
|
|
+ userLogger.info(user, Type.UNBIND_USERSPACE.getValue() + spaceUU);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -505,7 +510,7 @@ public class UserServiceImpl implements UserService {
|
|
|
if (CollectionUtils.isEmpty(userQuestions)) {
|
|
|
user.setQuestions(questions);
|
|
|
} else {
|
|
|
- for (int i=0; i<questions.size(); i++) {
|
|
|
+ for (int i = 0; i < questions.size(); i++) {
|
|
|
if (userQuestions.get(i) == null) {
|
|
|
user.getQuestions().add(questions.get(i));
|
|
|
} else {
|
|
|
@@ -541,7 +546,7 @@ public class UserServiceImpl implements UserService {
|
|
|
user.setPassword(getEncryPassword(Const.ENCRY_FORMAT, noEncryPwd, user.getSalt()));
|
|
|
user.setPasswordLevel(PasswordLevelUtils.checkPasswordLevel(noEncryPwd).getValue());
|
|
|
|
|
|
- user = syncUserInfo(user , noEncryPwd, "用户修改密码", null);
|
|
|
+ user = syncUserInfo(user, noEncryPwd, "用户修改密码", null);
|
|
|
|
|
|
return userDao.save(user);
|
|
|
}
|
|
|
@@ -652,6 +657,10 @@ public class UserServiceImpl implements UserService {
|
|
|
List<Map<String, Object>> counts = userDao.getCountByRegisterDate(start, end, fromApps);
|
|
|
for (Map<String, Object> count : counts) {
|
|
|
data.put((String) count.get("appId"), (Long) count.get("count"));
|
|
|
+ fromApps.remove(count.get("appId"));
|
|
|
+ }
|
|
|
+ for(String fromApp: fromApps){
|
|
|
+ data.put(fromApp, 0L);
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
@@ -721,6 +730,36 @@ public class UserServiceImpl implements UserService {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Long> countInToday(List<String> fromApps) {
|
|
|
+ return CountUtils.countInToday(new CountCallBack<Map<String, Long>>() {
|
|
|
+ @Override
|
|
|
+ public Map<String, Long> countByTime(Calendar start, Calendar end) {
|
|
|
+ return countByRegisterDate(new Timestamp(start.getTimeInMillis()), new Timestamp(end.getTimeInMillis()), fromApps);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Long> countInYesterday(List<String> fromApps) {
|
|
|
+ return CountUtils.countInYesterday(new CountCallBack<Map<String, Long>>() {
|
|
|
+ @Override
|
|
|
+ public Map<String, Long> countByTime(Calendar start, Calendar end) {
|
|
|
+ return countByRegisterDate(new Timestamp(start.getTimeInMillis()), new Timestamp(end.getTimeInMillis()), fromApps);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Long> countgInLastMonth(List<String> fromApps) {
|
|
|
+ return CountUtils.countInLastMonth(new CountCallBack<Map<String, Long>>() {
|
|
|
+ @Override
|
|
|
+ public Map<String, Long> countByTime(Calendar start, Calendar end) {
|
|
|
+ return countByRegisterDate(new Timestamp(start.getTimeInMillis()), new Timestamp(end.getTimeInMillis()), fromApps);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public User findByWxUnionid(String unionid) {
|
|
|
return userDao.findByWxUnionid(unionid);
|
|
|
@@ -844,7 +883,8 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
/**
|
|
|
* 设置用户第三方openId,不同应用对应不同字段
|
|
|
- * @param user 用户信息
|
|
|
+ *
|
|
|
+ * @param user 用户信息
|
|
|
* @param foreignInfo
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -870,9 +910,10 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
/**
|
|
|
* 同步用户信息到各个应用
|
|
|
- * @param user 用户信息
|
|
|
+ *
|
|
|
+ * @param user 用户信息
|
|
|
* @param noEncryPwd 未加密密码,用于同步im
|
|
|
- * @param msg 同步信息描述,用户区分同步类型
|
|
|
+ * @param msg 同步信息描述,用户区分同步类型
|
|
|
*/
|
|
|
private User syncUserInfo(User user, String noEncryPwd, final String msg, App otherApp) {
|
|
|
List<App> apps = appService.findDefaultUseApp();
|
|
|
@@ -930,33 +971,35 @@ public class UserServiceImpl implements UserService {
|
|
|
|
|
|
/**
|
|
|
* 同步信息到指定应用
|
|
|
+ *
|
|
|
* @param formData 同步数据
|
|
|
- * @param msg 同步信息
|
|
|
- * @param apps 需要同步的应用
|
|
|
+ * @param msg 同步信息
|
|
|
+ * @param apps 需要同步的应用
|
|
|
*/
|
|
|
private void syncUserInfo(final Map<String, Object> formData, final String msg, List<App> apps) {
|
|
|
- for (final App app : apps) {
|
|
|
- executorService.execute(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- String url = app.getBackUserUrl();
|
|
|
- if (StringUtils.isEmpty(url)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- HttpUtil.ResponseWrap res;
|
|
|
- try {
|
|
|
- res = HttpUtil.doPost(url, formData, 10000);
|
|
|
- if (!res.isSuccess()) {
|
|
|
- SyncLog syncLog = syncLogger.error(app.getUid(), msg + ",同步用户信息失败", JSON.toJSONString(formData), res.getContent());
|
|
|
- SyncFail.add(syncLog.getId(), formData, url, app.getUid());
|
|
|
- } else {
|
|
|
- syncLogger.info(app.getUid(), msg + ",同步用户信息成功", JSON.toJSONString(formData));
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- syncLogger.error(app.getUid(), msg + ",同步用户信息失败", JSON.toJSONString(formData), e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ for (final App app : apps) {
|
|
|
+ executorService.execute(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ String url = app.getBackUserUrl();
|
|
|
+ if (StringUtils.isEmpty(url)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ HttpUtil.ResponseWrap res;
|
|
|
+ try {
|
|
|
+ url = "http://127.0.0.1:28810/api/public/user";
|
|
|
+ res = HttpUtil.doPost(url, formData, 10000);
|
|
|
+ if (!res.isSuccess()) {
|
|
|
+ SyncLog syncLog = syncLogger.error(app.getUid(), msg + ",同步用户信息失败", JSON.toJSONString(formData), res.getContent());
|
|
|
+ SyncFail.add(syncLog.getId(), formData, url, app.getUid());
|
|
|
+ } else {
|
|
|
+ syncLogger.info(app.getUid(), msg + ",同步用户信息成功", JSON.toJSONString(formData));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ syncLogger.error(app.getUid(), msg + ",同步用户信息失败", JSON.toJSONString(formData), e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|