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

H5登录逻辑处理

parent 8de65dc3
......@@ -80,21 +80,21 @@ public class ApiLoginController extends BaseJsonBodyController {
}
UserEntity userEntity = null;
try {
// if (ObjectUtils.isEmpty(loginForm.getCode())) {
// throw new AppException("钉钉code不能为空!");
// }
// //根据code 查询钉钉用户id
// Rest<String> personRest = dingPersonService.getPersonByCode(loginForm.getCode());
// if (personRest.getCode() != YesNoEnum.YES.getValue()) {
// throw new AppException(DING_AUTH_FAIL,String.format("获取钉钉用户异常,%s", personRest.getMsg()));
// }
if (ObjectUtils.isEmpty(loginForm.getCode())) {
throw new AppException("钉钉code不能为空!");
}
//根据code 查询钉钉用户id
Rest<String> personRest = dingPersonService.getPersonByCode(loginForm.getCode());
if (personRest.getCode() != YesNoEnum.YES.getValue()) {
throw new AppException(DING_AUTH_FAIL,String.format("获取钉钉用户异常,%s", personRest.getMsg()));
}
userEntity = userService.doLogin(loginName, password, ip);
//
// if (!ObjectUtils.isEmpty(loginForm.getCode())) {
// //更新绑定钉钉
// userEntity.setDingUserId(loginForm.getCode());
// userService.getUserDao().update(userEntity);
// }
if (!ObjectUtils.isEmpty(loginForm.getCode())) {
//更新绑定钉钉
userEntity.setDingUserId(loginForm.getCode());
userService.getUserDao().update(userEntity);
}
StaffEntity staffEntity = null;
if(userEntity.getCustomerId()!=null){
staffEntity = staffService.getCache(userEntity.getCustomerId().toString());
......
......@@ -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.StaffQuery;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
......@@ -52,6 +55,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import static com.mortals.xhx.common.key.ErrorCode.*;
......@@ -77,6 +81,8 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
@Autowired
private IDingPersonService dingPersonService;
@Autowired
private WindowOwnerService windowOwnerService;
@RequestMapping("authlogin")
......@@ -107,6 +113,32 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
}
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());
userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID());
......@@ -206,6 +238,32 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
String token = authTokenService.getToken(request);
data.put("id", user.getId());
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());
ret.put(KEY_RESULT_DATA, data);
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