commit
This commit is contained in:
@@ -165,24 +165,35 @@ public class SysLoginController {
|
||||
@At(value = "/platform/wxwork/oauth2/callback", top = true)
|
||||
@Ok("re")
|
||||
@ApiOperation("企业微信登录回调")
|
||||
@Filters
|
||||
public String wxworkOAuth2(@Param("code") String code, @Param("redirect") String redirect, HttpServletRequest request) {
|
||||
if (StrUtil.isBlank(code)) {
|
||||
return ">>:/platform/home";
|
||||
}
|
||||
String token = redisService.get(RedisConstant.REDIS_KEY_WX_WORK_TOKEN);
|
||||
if (StrUtil.isBlank(token)) {
|
||||
return ">>:/platform/home";
|
||||
}
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=ACCESS_TOKEN&code=CODE";
|
||||
url = url.replace("ACCESS_TOKEN", token).replace("CODE", code);
|
||||
String response = HttpUtil.get(url);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(response);
|
||||
if (jsonObject.getInt("errcode") == 0) {
|
||||
String loginName = jsonObject.getStr("userid");
|
||||
sysUserService.checkThirdPlatformLoginName(loginName);
|
||||
Sys_user sysUser = sysUserService.loginByLoginName(loginName);
|
||||
return ">>:" + sysUserService.loginPlus(sysUser, LoginType.QI_YE_WECHAT, request);
|
||||
} else {
|
||||
try {
|
||||
if (StrUtil.isBlank(code)) {
|
||||
return ">>:/platform/home";
|
||||
}
|
||||
String token = redisService.get(RedisConstant.REDIS_KEY_WX_WORK_TOKEN);
|
||||
if (StrUtil.isBlank(token)) {
|
||||
log.error("企业微信 token 为空");
|
||||
return ">>:/platform/home";
|
||||
}
|
||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/auth/getuserinfo?access_token=ACCESS_TOKEN&code=CODE";
|
||||
url = url.replace("ACCESS_TOKEN", token).replace("CODE", code);
|
||||
String response = HttpUtil.get(url);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(response);
|
||||
if (jsonObject.getInt("errcode") == 0) {
|
||||
String loginName = jsonObject.getStr("userid");
|
||||
log.info("企业微信授权成功,userid: " + loginName);
|
||||
sysUserService.checkThirdPlatformLoginName(loginName);
|
||||
Sys_user sysUser = sysUserService.loginByLoginName(loginName);
|
||||
String result = sysUserService.loginPlus(sysUser, LoginType.QI_YE_WECHAT, request);
|
||||
log.info("企业微信登录成功,重定向到:" + result);
|
||||
return ">>:" + result;
|
||||
} else {
|
||||
log.error("企业微信授权失败:" + jsonObject);
|
||||
return ">>:/platform/home/500";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("企业微信登录异常", e);
|
||||
return ">>:/platform/home/500";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,8 @@ public class SysUnionController {
|
||||
@SaCheckPermission("sys.manager.union.partUnit")
|
||||
public Result branchUnionPartUnitTransferData(String unionId) {
|
||||
// List<Sys_unit> units = dao.query(Sys_unit.class, Cnd.where("unitLevel", "=", 2).asc("unitcode"));
|
||||
List<Sys_unit> units = dao.query(Sys_unit.class, Cnd.where("unitTypeCode", "=", "1").asc("unitcode"));
|
||||
// List<Sys_unit> units = dao.query(Sys_unit.class, Cnd.where("unitTypeCode", "=", "1").asc("unitcode"));
|
||||
List<Sys_unit> units = dao.query(Sys_unit.class, Cnd.where("unitLevel", "=", "3").asc("unitcode"));
|
||||
List<String> selectUnitIds = units.stream().filter(unit -> StrUtil.isNotBlank(unit.getUnionId()) && unit.getUnionId().equals(unionId)).map(Sys_unit::getId).toList();
|
||||
List<Sys_unit> matchUnits = units.stream().filter(unit -> StrUtil.isBlank(unit.getUnionId()) || (StrUtil.isNotBlank(unit.getUnionId()) && unit.getUnionId().equals(unionId))).toList();
|
||||
NutMap transferData = NutMap.NEW().addv("selectUnitIds", selectUnitIds).addv("allUnits", matchUnits);
|
||||
|
||||
@@ -295,7 +295,7 @@ public class SysUnitController {
|
||||
nodeList.add(new TreeNode<>(list.get(i).getId(), list.get(i).getParentId(), list.get(i).getName(), i)
|
||||
.setExtra(
|
||||
Map.of(
|
||||
"unitType", list.get(i).getUnitType(),
|
||||
// "unitType", list.get(i).getUnitType(),
|
||||
"unitTypeCode", list.get(i).getUnitTypeCode()
|
||||
)
|
||||
));
|
||||
@@ -315,6 +315,7 @@ public class SysUnitController {
|
||||
|
||||
return Result.success(treeList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Result.error();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +189,11 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
Sys_user u = new Sys_user();
|
||||
BeanUtils.copyProperties(source, u);
|
||||
|
||||
//单位id取前四位数(二级单位)
|
||||
if (u.getUnitId() != null && u.getUnitId().length() > 4) {
|
||||
u.setUnitId(u.getUnitId().substring(0, 4));
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
// 新增用户,初始化数据
|
||||
String salt = R.UU32();
|
||||
|
||||
Reference in New Issue
Block a user