|
|
@@ -11,15 +11,14 @@ 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.*;
|
|
|
-import com.zhongshu.card.client.model.org.orgUser.OrganizationUserModel;
|
|
|
+import com.zhongshu.card.client.model.org.GetPhoneModel;
|
|
|
+import com.zhongshu.card.client.model.org.LoginParam;
|
|
|
+import com.zhongshu.card.client.model.org.UserCountSimpleModel;
|
|
|
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.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;
|
|
|
@@ -281,7 +280,7 @@ public class IndexService extends SuperService {
|
|
|
}).collect(Collectors.toUnmodifiableList());
|
|
|
|
|
|
if (ObjectUtils.isEmpty(list)) {
|
|
|
- return ResultContent.buildFail("用户未加入项目");
|
|
|
+ return ResultContent.buildFail("用户未加入项目.");
|
|
|
}
|
|
|
|
|
|
// 验证用户名密码
|
|
|
@@ -295,93 +294,6 @@ public class IndexService extends SuperService {
|
|
|
return resultContent;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 平台端用户登录
|
|
|
- *
|
|
|
- * @param param
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent loginPlatform(LoginParam param) {
|
|
|
- String phone = param.getLoginValue();
|
|
|
- UserAuthLoginModel userAuthLoginModel = new UserAuthLoginModel();
|
|
|
- BeanUtils.copyProperties(param, userAuthLoginModel);
|
|
|
- ResultContent<LoginTokenModel> resultContent = commonLogin(userAuthLoginModel);
|
|
|
- if (resultContent.isFailed()) {
|
|
|
- return resultContent;
|
|
|
- }
|
|
|
- Organization organization = organizationDao.findTopByAuthType(AuthType.Platform);
|
|
|
- if (ObjectUtils.isEmpty(organization)) {
|
|
|
- return ResultContent.buildFail(String.format("平台未初始化,请联系管理员"));
|
|
|
- }
|
|
|
- if (organization.getState() == OrganizationState.Locked || organization.getState() == OrganizationState.Frozen) {
|
|
|
- return ResultContent.buildFail(String.format("平台已被锁定,不能登录"));
|
|
|
- }
|
|
|
- UserAccount userAccount = userCountDao.findTopByLoginName(phone);
|
|
|
- OrganizationUser organizationUser = organizationUserDao.findTopByOrganizationAndUser(organization, userAccount);
|
|
|
- if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
- return ResultContent.buildFail(String.format("该用户不属于平台端用户:%s", phone));
|
|
|
- }
|
|
|
- LoginTokenModel loginTokenModel = resultContent.getContent();
|
|
|
- LoginPlatformTokenModel tokenModel = new LoginPlatformTokenModel();
|
|
|
- com.zhongshu.card.server.core.util.BeanUtils.copyProperties(loginTokenModel, tokenModel);
|
|
|
-
|
|
|
- tokenModel.setPlatformOid(organization.getOid());
|
|
|
-
|
|
|
- OrganizationUserModel userModel = userAccountService.toOrgUserModel(organizationUser);
|
|
|
- tokenModel.setUserInfo(userModel);
|
|
|
-
|
|
|
- return ResultContent.buildSuccess(tokenModel);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 登录--验证用户名和密码 + 是否在指定的机构
|
|
|
- *
|
|
|
- * @param param
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ResultContent loginToOid(LoginParam param) {
|
|
|
- String phone = param.getLoginValue();
|
|
|
- UserAuthLoginModel userAuthLoginModel = new UserAuthLoginModel();
|
|
|
- BeanUtils.copyProperties(param, userAuthLoginModel);
|
|
|
- ResultContent<LoginTokenModel> resultContent = commonLogin(userAuthLoginModel);
|
|
|
- if (resultContent.isFailed()) {
|
|
|
- return resultContent;
|
|
|
- }
|
|
|
- // web 端的登录用户数据验证
|
|
|
- UserAccount userAccount = userCountDao.findTopByLoginName(phone);
|
|
|
- Organization organization = organizationDao.findTopByOid(param.getOid());
|
|
|
- if (ObjectUtils.isEmpty(organization)) {
|
|
|
- return ResultContent.buildFail(String.format("oid不存在:%s", param.getOid()));
|
|
|
- }
|
|
|
- OrganizationUser organizationUser = organizationUserDao.findTopByOrganizationAndUserAndState(organization, userAccount, UserState.Normal);
|
|
|
- if (ObjectUtils.isEmpty(organizationUser)) {
|
|
|
- String msg = String.format("用户不属于该机构:%s", organization.getName());
|
|
|
- if (param.getLoginFromType() == LoginFromType.Platform) {
|
|
|
- msg = String.format("用户不属于平台端用户,登录失败:%s", organization.getName());
|
|
|
- } else if (param.getLoginFromType() == LoginFromType.School) {
|
|
|
- msg = String.format("用户不属于学校端用户,登录失败:%s", organization.getName());
|
|
|
- } else if (param.getLoginFromType() == LoginFromType.Shop) {
|
|
|
- msg = String.format("用户不属于商户端用户,登录失败:%s", organization.getName());
|
|
|
- }
|
|
|
- return ResultContent.buildFail(msg);
|
|
|
- }
|
|
|
- LoginTokenModel loginTokenModel = resultContent.getContent();
|
|
|
- LoginPlatformTokenModel tokenModel = new LoginPlatformTokenModel();
|
|
|
- com.zhongshu.card.server.core.util.BeanUtils.copyProperties(loginTokenModel, tokenModel);
|
|
|
- tokenModel.setPlatformOid(organization.getOid());
|
|
|
-
|
|
|
- // 查询用户信息
|
|
|
- OrganizationUserModel userModel = userAccountService.toOrgUserModel(organizationUser);
|
|
|
- tokenModel.setUserInfo(userModel);
|
|
|
-
|
|
|
- // 得到用户在企业的权限列表
|
|
|
- ResultContent<Set<String>> authContent = roleServiceImpl.getOrganizationAuth(organization.getOid(), userModel.getUserId());
|
|
|
- if (authContent.isSuccess()) {
|
|
|
- tokenModel.setAuths(authContent.getContent());
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(tokenModel);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 验证令牌是否有效
|
|
|
*
|