| | |
| | | import com.ycl.exception.ApiException; |
| | | import com.ycl.service.depart.UmsDepartService; |
| | | import com.ycl.service.user.UmsRoleService; |
| | | import com.ycl.util.DingUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | @Autowired |
| | | private UmsDepartService umsDepartService; |
| | | |
| | | @Autowired |
| | | private DingUtil dingUtil; |
| | | |
| | | /** |
| | | * 获取用户信息 |
| | |
| | | public DingUserInfo getDingUserInfo(String code) { |
| | | // 判断ding 信息是否存在 |
| | | boolean hasDing = redisTemplate.hasKey("ding"); |
| | | String getToken = ""; |
| | | if (hasDing) { |
| | | log.info("redis正常有消息"); |
| | | String dingStr = redisTemplate.opsForValue().get("ding"); |
| | | JSONObject dingObj = JSONObject.parseObject(dingStr); |
| | | String getToken = dingObj.getString("token"); |
| | | getToken = dingObj.getString("token"); |
| | | |
| | | } else { |
| | | getToken = dingUtil.getToken(); |
| | | } |
| | | if (ObjectUtil.isEmpty(code) || ObjectUtil.isEmpty(getToken)) { |
| | | throw new ApiException("登录异常"); |
| | | } |
| | |
| | | String accId = DingEncodeUtil.getMD5(resObj.getString("employeeCode").getBytes()); |
| | | dingUserInfo.setUserId(Long.parseLong(accId)); |
| | | return dingUserInfo; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | |
| | | } |
| | | return resObj; |
| | | } |
| | | |
| | | /** |
| | | * 发送markdown消息 |
| | | * |
| | |
| | | } |
| | | return resObj; |
| | | } |
| | | |
| | | /** |
| | | * 发送链接消息 |
| | | * |
| | |
| | | redisTemplate.opsForValue().set("userJsonList", arr.toJSONString()); |
| | | return dingUserInfoList; |
| | | } |
| | | |
| | | /** |
| | | * 根据员工code 获取员工accountId |
| | | * |
| | |
| | | String jsonStr = JSONObject.toJSONString(jsonObject); |
| | | return jsonStr; |
| | | } |
| | | |
| | | /** |
| | | * 拼接要发送的消息 markdown消息 |
| | | * json对象 必须 {"msgtype":"markdown","markdown":{"title":"首屏会话透出的展示内容","text":"消息内容"}} |
| | |
| | | String jsonStr = JSONObject.toJSONString(jsonObject); |
| | | return jsonStr; |
| | | } |
| | | |
| | | /** |
| | | * 拼接要发送的消息 链接消息 |
| | | * |