|
|
@@ -11,6 +11,8 @@ import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
|
|
|
import com.github.microservice.core.util.net.IPUtil;
|
|
|
import com.zhongshu.card.client.model.org.GetPhoneModel;
|
|
|
import com.zhongshu.card.client.model.org.LoginParam;
|
|
|
+import com.zhongshu.card.client.model.org.LoginPlatformTokenModel;
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationUserModel;
|
|
|
import com.zhongshu.card.client.model.wechat.PhoneModel;
|
|
|
import com.zhongshu.card.client.model.wechat.WechatPhoneNumber;
|
|
|
import com.zhongshu.card.client.ret.ResultContent;
|
|
|
@@ -74,11 +76,16 @@ public class IndexService {
|
|
|
|
|
|
@Autowired
|
|
|
OrganizationUserDao organizationUserDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private OrganizationDao organizationDao;
|
|
|
|
|
|
@Autowired
|
|
|
WechatCUtil wechatCUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ UserAccountServiceImpl userAccountService;
|
|
|
+
|
|
|
/**
|
|
|
* 登录 只验证 用户名 和密码
|
|
|
*
|
|
|
@@ -96,6 +103,45 @@ public class IndexService {
|
|
|
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);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 登录--验证用户名和密码 + 是否在指定的机构
|
|
|
*
|
|
|
@@ -155,12 +201,18 @@ public class IndexService {
|
|
|
return resultContent;
|
|
|
}
|
|
|
|
|
|
- public ResultContent commonLogin(UserAuthLoginModel userAuthLoginModel) {
|
|
|
+ public ResultContent<LoginTokenModel> commonLogin(UserAuthLoginModel userAuthLoginModel) {
|
|
|
String phone = userAuthLoginModel.getLoginValue();
|
|
|
userAuthLoginModel.setDeviceIp(IPUtil.getRemoteIp(request));
|
|
|
userAuthLoginModel.setClientId(clientId);
|
|
|
userAuthLoginModel.setClientSecret(clientSecret);
|
|
|
userAuthLoginModel.setDeviceUserAgent(request.getHeader("user-agent"));
|
|
|
+ if (userAuthLoginModel.getAccessTokenTimeOut() == null) {
|
|
|
+ userAuthLoginModel.setAccessTokenTimeOut(259200l);
|
|
|
+ }
|
|
|
+ if (userAuthLoginModel.getRefreshTokenTimeOut() == null) {
|
|
|
+ userAuthLoginModel.setRefreshTokenTimeOut(31536000L);
|
|
|
+ }
|
|
|
|
|
|
com.github.microservice.auth.client.content.ResultContent<LoginTokenModel> resultContent = userService.login(userAuthLoginModel);
|
|
|
if (resultContent.getState() == com.github.microservice.auth.client.content.ResultState.Success) {
|