Commit 14453f52 authored by 廖旭伟's avatar 廖旭伟

H5登录逻辑处理

parent 8de65dc3
...@@ -80,21 +80,21 @@ public class ApiLoginController extends BaseJsonBodyController { ...@@ -80,21 +80,21 @@ public class ApiLoginController extends BaseJsonBodyController {
} }
UserEntity userEntity = null; UserEntity userEntity = null;
try { try {
// if (ObjectUtils.isEmpty(loginForm.getCode())) { if (ObjectUtils.isEmpty(loginForm.getCode())) {
// throw new AppException("钉钉code不能为空!"); throw new AppException("钉钉code不能为空!");
// } }
// //根据code 查询钉钉用户id //根据code 查询钉钉用户id
// Rest<String> personRest = dingPersonService.getPersonByCode(loginForm.getCode()); Rest<String> personRest = dingPersonService.getPersonByCode(loginForm.getCode());
// if (personRest.getCode() != YesNoEnum.YES.getValue()) { if (personRest.getCode() != YesNoEnum.YES.getValue()) {
// throw new AppException(DING_AUTH_FAIL,String.format("获取钉钉用户异常,%s", personRest.getMsg())); throw new AppException(DING_AUTH_FAIL,String.format("获取钉钉用户异常,%s", personRest.getMsg()));
// } }
userEntity = userService.doLogin(loginName, password, ip); userEntity = userService.doLogin(loginName, password, ip);
//
// if (!ObjectUtils.isEmpty(loginForm.getCode())) { if (!ObjectUtils.isEmpty(loginForm.getCode())) {
// //更新绑定钉钉 //更新绑定钉钉
// userEntity.setDingUserId(loginForm.getCode()); userEntity.setDingUserId(loginForm.getCode());
// userService.getUserDao().update(userEntity); userService.getUserDao().update(userEntity);
// } }
StaffEntity staffEntity = null; StaffEntity staffEntity = null;
if(userEntity.getCustomerId()!=null){ if(userEntity.getCustomerId()!=null){
staffEntity = staffService.getCache(userEntity.getCustomerId().toString()); staffEntity = staffService.getCache(userEntity.getCustomerId().toString());
......
...@@ -41,6 +41,9 @@ import com.mortals.xhx.module.dingding.personal.service.IDingPersonService; ...@@ -41,6 +41,9 @@ import com.mortals.xhx.module.dingding.personal.service.IDingPersonService;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery; import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
import com.mortals.xhx.module.window.model.WindowOwnerEntity;
import com.mortals.xhx.module.window.model.WindowOwnerQuery;
import com.mortals.xhx.module.window.service.WindowOwnerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -52,6 +55,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -52,6 +55,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ErrorCode.*; import static com.mortals.xhx.common.key.ErrorCode.*;
...@@ -77,6 +81,8 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U ...@@ -77,6 +81,8 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
@Autowired @Autowired
private IDingPersonService dingPersonService; private IDingPersonService dingPersonService;
@Autowired
private WindowOwnerService windowOwnerService;
@RequestMapping("authlogin") @RequestMapping("authlogin")
...@@ -107,6 +113,32 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U ...@@ -107,6 +113,32 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
} }
data.put("id", userEntity.getId()); data.put("id", userEntity.getId());
if(userEntity!=null) {
StaffEntity staffEntity = null;
if (userEntity.getCustomerId() != null) {
staffEntity = staffService.getCache(userEntity.getCustomerId().toString());
}
if (staffEntity != null) {
WindowOwnerEntity windowOwnerEntity = windowOwnerService.selectOne(new WindowOwnerQuery().staffId(staffEntity.getId()));
if (windowOwnerEntity == null) {
userEntity.setUserType(1); //工作人员
} else {
if (windowOwnerEntity.getInspect() == 1) {
userEntity.setUserType(3); //具有巡检的窗口负责人
} else {
userEntity.setUserType(2); //普通窗口负责人
}
if (StringUtils.isNotEmpty(windowOwnerEntity.getStaffIds())) {
List<Long> staffIdList = Arrays.asList(windowOwnerEntity.getStaffIds().split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
windowOwnerEntity.setStaffCount(staffIdList.size());
} else {
windowOwnerEntity.setStaffCount(0);
}
windowOwnerEntity.setWindowOwnerDetailList(null);
data.put("windowOwner", windowOwnerEntity);
}
}
}
data.put("userType", userEntity.getUserType()); data.put("userType", userEntity.getUserType());
userEntity.setLoginTime(System.currentTimeMillis()); userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID()); userEntity.setToken(IdUtil.fastSimpleUUID());
...@@ -206,6 +238,32 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U ...@@ -206,6 +238,32 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
String token = authTokenService.getToken(request); String token = authTokenService.getToken(request);
data.put("id", user.getId()); data.put("id", user.getId());
data.put("token", token); data.put("token", token);
if(userEntity!=null) {
StaffEntity staffEntity = null;
if (userEntity.getCustomerId() != null) {
staffEntity = staffService.getCache(userEntity.getCustomerId().toString());
}
if (staffEntity != null) {
WindowOwnerEntity windowOwnerEntity = windowOwnerService.selectOne(new WindowOwnerQuery().staffId(staffEntity.getId()));
if (windowOwnerEntity == null) {
userEntity.setUserType(1); //工作人员
} else {
if (windowOwnerEntity.getInspect() == 1) {
userEntity.setUserType(3); //具有巡检的窗口负责人
} else {
userEntity.setUserType(2); //普通窗口负责人
}
if (StringUtils.isNotEmpty(windowOwnerEntity.getStaffIds())) {
List<Long> staffIdList = Arrays.asList(windowOwnerEntity.getStaffIds().split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
windowOwnerEntity.setStaffCount(staffIdList.size());
} else {
windowOwnerEntity.setStaffCount(0);
}
windowOwnerEntity.setWindowOwnerDetailList(null);
data.put("windowOwner", windowOwnerEntity);
}
}
}
data.put("userType", userEntity.getUserType()); data.put("userType", userEntity.getUserType());
ret.put(KEY_RESULT_DATA, data); ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment