Commit ac7eb10b authored by 赵啸非's avatar 赵啸非

添加h5钉钉用户授权登录与注册绑定

parent b78c26c8
package com.mortals.xhx.busiz.h5.web;
package com.mortals.xhx.busiz;
import cn.hutool.json.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.service.ICacheService;
import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService;
import com.mortals.xhx.base.system.idgenerator.service.impl.IdgeneratorServiceImpl;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.module.staff.service.StaffService;
import com.mortals.xhx.module.workman.model.WorkmanEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 设备
*
......@@ -23,7 +33,15 @@ public class TestController {
@Autowired
private IdgeneratorService idgeneratorService;
// @GetMapping("webservice")@GetMapping("idGens")
@Autowired
private ICacheService cacheService;
@Autowired
private StaffService staffService;
@Autowired
private UserService userService;
// @GetMapping("webservice")@GetMapping("idGens")
// public String idGens() {
// log.info("测试id生成");
//
......@@ -38,9 +56,26 @@ public class TestController {
return "ok";
}
//
//
@GetMapping("updatePersons")
public String updatePersons() {
log.info("更新用户手机号码");
cacheService.select(1);
Map<String, String> map = cacheService.hgetAll("com:mortals:xhx:module:workman:model:WorkmanEntity");
cacheService.select(14);
Map<String, WorkmanEntity> userMap = new HashMap<>();
map.entrySet().stream().forEach(item -> {
String value = item.getValue();
WorkmanEntity workmanEntity = JSONObject.parseObject(value, WorkmanEntity.class);
userMap.put(workmanEntity.getName(), workmanEntity);
});
return "ok";
}
public static void main(String[] args) {
......
......@@ -45,7 +45,9 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.mortals.xhx.common.key.ErrorCode.*;
......@@ -160,6 +162,15 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
throw new AppException(String.format("员工未与系统用户绑定,staffId:%s", staffEntity.getId()));
userEntity.setDingUserId(req.getOpenId());
// userService.update(userEntity);
Map<String, Object> condition = new HashMap<>(1);
condition.put("id", userEntity.getId());
Map<String, Object> data1 = new HashMap<>(1);
data1.put("dingUserId", req.getOpenId());
userService.getUserDao().update(data1, condition);
JSONObject data = new JSONObject();
data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType());
......@@ -187,7 +198,7 @@ public class DingTalkLoginController extends BaseCRUDJsonBodyMappingController<U
}
@RequestMapping("logout")
public void logout(HttpServletRequest request, HttpServletResponse response) {
public void logout(HttpServletRequest request, HttpServletResponse response) {
recordSysLog(request, "退出登录");
super.removeCurrUser(request);
this.deleteBlackCookie(request, response);
......
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