|
|
@@ -10,6 +10,7 @@ import com.github.microservice.auth.security.model.AuthDetails;
|
|
|
import com.github.microservice.auth.security.type.AuthType;
|
|
|
import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
|
|
|
import com.github.microservice.core.util.net.IPUtil;
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
import com.zhongshu.card.client.model.login.LoginBusModel;
|
|
|
import com.zhongshu.card.client.model.login.LoginCommonModel;
|
|
|
import com.zhongshu.card.client.model.org.*;
|
|
|
@@ -17,14 +18,15 @@ import com.zhongshu.card.client.model.org.orgUser.OrganizationUserModel;
|
|
|
import com.zhongshu.card.client.model.setting.PlatFormLoginConfig;
|
|
|
import com.zhongshu.card.client.model.wechat.PhoneModel;
|
|
|
import com.zhongshu.card.client.model.wechat.WechatPhoneNumber;
|
|
|
-import com.github.microservice.net.ResultContent;
|
|
|
import com.zhongshu.card.client.type.LoginFromType;
|
|
|
import com.zhongshu.card.client.type.OrganizationState;
|
|
|
import com.zhongshu.card.client.type.UserState;
|
|
|
import com.zhongshu.card.client.type.setting.SettingType;
|
|
|
+import com.zhongshu.card.client.type.user.OrgUserState;
|
|
|
import com.zhongshu.card.server.core.dao.org.*;
|
|
|
import com.zhongshu.card.server.core.domain.org.*;
|
|
|
import com.zhongshu.card.server.core.service.base.RedisService;
|
|
|
+import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.service.setting.PlatFormConfigInfoService;
|
|
|
import com.zhongshu.card.server.core.service.user.RoleServiceImpl;
|
|
|
import com.zhongshu.card.server.core.service.user.UserAccountServiceImpl;
|
|
|
@@ -41,7 +43,11 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author TRX
|
|
|
@@ -49,7 +55,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class IndexService {
|
|
|
+public class IndexService extends SuperService {
|
|
|
|
|
|
@Autowired
|
|
|
private UserCountDao userCountDao;
|
|
|
@@ -102,6 +108,9 @@ public class IndexService {
|
|
|
@Autowired
|
|
|
PlatFormConfigInfoService platFormConfigInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrganizationUserServiceImpl organizationUserServiceImpl;
|
|
|
+
|
|
|
/**
|
|
|
* 物联网登录
|
|
|
*
|
|
|
@@ -114,7 +123,7 @@ public class IndexService {
|
|
|
|
|
|
String phone = param.getLoginValue();
|
|
|
UserAccount userAccount = userCountDao.findTopByLoginName(phone);
|
|
|
- UserCountModel userCountModel = userAccountService.toModel(userAccount);
|
|
|
+ UserCountSimpleModel userCountModel = userAccountService.toSimpleModel(userAccount);
|
|
|
|
|
|
UserAuthLoginModel userAuthLoginModel = new UserAuthLoginModel();
|
|
|
BeanUtils.copyProperties(param, userAuthLoginModel);
|
|
|
@@ -156,53 +165,6 @@ public class IndexService {
|
|
|
return ResultContent.buildSuccess(commonModel);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 商户小程序登录
|
|
|
- *
|
|
|
- * @param param
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent<LoginBusModel> busLogin(LoginParam param) {
|
|
|
- StopWatch stopWatch = new StopWatch();
|
|
|
- stopWatch.start("1");
|
|
|
-
|
|
|
- UserAuthLoginModel userAuthLoginModel = new UserAuthLoginModel();
|
|
|
- BeanUtils.copyProperties(param, userAuthLoginModel);
|
|
|
- // 登录
|
|
|
- ResultContent<LoginTokenModel> resultContent = commonLogin(userAuthLoginModel);
|
|
|
- if (resultContent.isFailed()) {
|
|
|
- return ResultContent.buildFail(resultContent.getMsg());
|
|
|
- }
|
|
|
-
|
|
|
- String phone = param.getLoginValue();
|
|
|
- UserAccount userAccount = userCountDao.findTopByLoginName(phone);
|
|
|
- UserCountModel userCountModel = userAccountService.toModel(userAccount);
|
|
|
-
|
|
|
- // 用户加入的商户列表
|
|
|
- List<UserJoinBusOrgModel> busModels = organizationService.getUserAboutShopList(userAccount.getUserId());
|
|
|
- if (ObjectUtils.isEmpty(busModels)) {
|
|
|
- return ResultContent.buildFail("用户未关联商户,登录失败");
|
|
|
- }
|
|
|
-
|
|
|
- LoginBusModel commonModel = new LoginBusModel();
|
|
|
- LoginTokenModel loginTokenModel = resultContent.getContent();
|
|
|
- com.zhongshu.card.server.core.util.BeanUtils.copyProperties(loginTokenModel, commonModel);
|
|
|
- stopWatch.stop();
|
|
|
- commonModel.setBusList(busModels);
|
|
|
-
|
|
|
- stopWatch.start("2");
|
|
|
- commonModel.setUserInfo(userCountModel);
|
|
|
- stopWatch.stop();
|
|
|
-
|
|
|
- stopWatch.start("3");
|
|
|
- // 用户所有的权限
|
|
|
-// Set<String> auth = roleServiceImpl.getUserAllAuths(userAccount.getUserId());
|
|
|
-// commonModel.setAuths(auth);
|
|
|
- stopWatch.stop();
|
|
|
- log.info(stopWatch.prettyPrint());
|
|
|
- return ResultContent.buildSuccess(commonModel);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 通用用户登录(返回所有权限数据)
|
|
|
*
|
|
|
@@ -234,7 +196,7 @@ public class IndexService {
|
|
|
stopWatch.start("2");
|
|
|
|
|
|
UserAccount userAccount = userCountDao.findTopByLoginName(phone);
|
|
|
- UserCountModel userCountModel = userAccountService.toModel(userAccount);
|
|
|
+ UserCountSimpleModel userCountModel = userAccountService.toSimpleModel(userAccount);
|
|
|
commonModel.setUserInfo(userCountModel);
|
|
|
|
|
|
// 平台信息
|
|
|
@@ -293,13 +255,44 @@ public class IndexService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 微信普通用户登录
|
|
|
- *
|
|
|
+ * 小程序登录
|
|
|
* @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- public ResultContent wxUserLogin(LoginParam param) {
|
|
|
- return login(param);
|
|
|
+ public ResultContent wxXcxlogin(LoginParam param) {
|
|
|
+ String projectOid = getCurrentProjectOid();
|
|
|
+ if (ObjectUtils.isEmpty(projectOid)) {
|
|
|
+ return ResultContent.buildFail("当前项目信息为空");
|
|
|
+ }
|
|
|
+ String phone = param.getLoginValue();
|
|
|
+ UserAccount userAccount = userCountDao.findTopByLoginName(phone);
|
|
|
+ if (ObjectUtils.isEmpty(userAccount)) {
|
|
|
+ return ResultContent.buildFail("用户名或密码错误.");
|
|
|
+ }
|
|
|
+ List<OrganizationUser> list = organizationUserServiceImpl.getUserOrgList(userAccount.getUserId(), projectOid);
|
|
|
+ if (ObjectUtils.isEmpty(list)) {
|
|
|
+ return ResultContent.buildFail("用户未加入项目");
|
|
|
+ }
|
|
|
+ list = list.stream().filter(it -> {
|
|
|
+ if (it.getOrgUserState() == null || it.getOrgUserState() == OrgUserState.Formal) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toUnmodifiableList());
|
|
|
+
|
|
|
+ if (ObjectUtils.isEmpty(list)) {
|
|
|
+ return ResultContent.buildFail("用户未加入项目");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证用户名密码
|
|
|
+ UserAuthLoginModel userAuthLoginModel = new UserAuthLoginModel();
|
|
|
+ BeanUtils.copyProperties(param, userAuthLoginModel);
|
|
|
+ ResultContent resultContent = commonLogin(userAuthLoginModel);
|
|
|
+
|
|
|
+ if (resultContent.isFailed()) {
|
|
|
+ return resultContent;
|
|
|
+ }
|
|
|
+ return resultContent;
|
|
|
}
|
|
|
|
|
|
/**
|