去掉返回前端蜜柑信息

This commit is contained in:
wulin 2020-11-06 14:48:19 +08:00
parent d4738c4da3
commit 87d5df18bc
9 changed files with 180 additions and 18 deletions

View File

@ -249,9 +249,9 @@
</dependency>
<dependency>
<artifactId>taobao-sdk-java-auto_1479188381469</artifactId>
<groupId>dingtalk</groupId>
<version>20200811</version>
<groupId>com.aliyun</groupId>
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>

View File

@ -266,7 +266,7 @@ public class DingTalkUtil {
String token = dingTalkUtil.getAccessToken("856016278");
}
//发送钉钉消息
public String sendSingleActionCardMSG(String appid, StaffEntity staff, String title, String marDown,
String singleTitle, String singleUrl, String token) {
String msg = "OK";
@ -318,6 +318,59 @@ public class DingTalkUtil {
thirdMsgSendRecordService.insert(thirdMsgSendRecord);
return msg;
}
//发送待办任务
public String sendSingleWorkMSG(String appid, StaffEntity staff, String title, String marDown,
String singleTitle, String singleUrl, String token) {
String msg = "OK";
ThirdMsgSendRecord thirdMsgSendRecord = new ThirdMsgSendRecord();
thirdMsgSendRecord.setMsgType("work_msg");
thirdMsgSendRecord.setStaffId(staff.getId());
thirdMsgSendRecord.setMsgTitle(singleTitle);
thirdMsgSendRecord.setAppId(Long.parseLong(appid));
thirdMsgSendRecord.setHeadText(title);
thirdMsgSendRecord.setMsgContent(marDown);
thirdMsgSendRecord.setMsgUrl(singleUrl);
thirdMsgSendRecord.setStatus(0);
try{
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/workrecord/add");
OapiWorkrecordAddRequest req = new OapiWorkrecordAddRequest();
req.setUserid(staff.getEmployeeId());
req.setCreateTime(System.currentTimeMillis());
req.setTitle(singleTitle);
req.setUrl(singleUrl);
List<OapiWorkrecordAddRequest.FormItemVo> list2 = new ArrayList<OapiWorkrecordAddRequest.FormItemVo>();
OapiWorkrecordAddRequest.FormItemVo obj3 = new OapiWorkrecordAddRequest.FormItemVo();
list2.add(obj3);
obj3.setTitle(title);
obj3.setContent(marDown);
req.setFormItemList(list2);
OapiWorkrecordAddResponse rsp = client.execute(req, token);
logger.info("钉钉待办任务请求返回{}", rsp.getBody());
//插入数据库
JSONObject json = JSONObject.parseObject(rsp.getBody());
if(json.getIntValue("errcode") == 0){
thirdMsgSendRecord.setTaskId(json.getLong("record_id"));
thirdMsgSendRecord.setStatus(1);
}else{
thirdMsgSendRecord.setTaskId(0L);
thirdMsgSendRecord.setStatus(6);
thirdMsgSendRecord.setRemark(json.getString("errmsg"));
msg = thirdMsgSendRecord.getRemark();
}
}catch (ApiException e) {
e.printStackTrace();
thirdMsgSendRecord.setStatus(6);
thirdMsgSendRecord.setRemark(e.getErrMsg());
msg = thirdMsgSendRecord.getRemark();
}
thirdMsgSendRecordService.insert(thirdMsgSendRecord);
return msg;
}
public R getUserIdByCode(String code, String token) {
try {

View File

@ -157,7 +157,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
case 5:
return R.error(groupStaffs.getEvaluationGroup().getName() + "——初始化考核流程失败");
}
dingtalkBusiness.sendWorkMSGWithThread(staffSimpleInfos, WorkMsgTypeEnum.START_WORK.getType());
dingtalkBusiness.sendWorkMSGWithAsyn(staffSimpleInfos, WorkMsgTypeEnum.START_WORK.getType());
}
return R.ok("发起成功").put("data", flowStart);
@ -281,7 +281,7 @@ public class FlowStartServiceImpl extends ServiceImpl<FlowStartMapper, FlowStart
case 5:
return R.error(evaluationGroup.getName() + "——初始化考核流程失败");
}
dingtalkBusiness.sendWorkMSGWithThread(staffIds, WorkMsgTypeEnum.START_WORK.getType());
dingtalkBusiness.sendWorkMSGWithAsyn(staffIds, WorkMsgTypeEnum.START_WORK.getType());
}
return R.ok("发起成功").put("data", flowStart);
}

View File

@ -193,13 +193,9 @@ public class DingtalkBusiness {
return sendWorkMSGByEntity(appid, fromStaffEntity, toStaffEntity, workMsgTypeEnum, "https://www.baidu.com");
}
public String sendWorkMSGWithAsyn(List<Long> toStaffids, int type) {
List<StaffSimpleInfo> staffSimpleInfos = staffService.selectStaffSimpleInfos(toStaffids);
return sendWorkMSGWithThread(staffSimpleInfos, type);
}
public String sendWorkMSGWithThread(List<StaffSimpleInfo> toStaffids, int type) {
public String sendWorkMSGWithAsyn(List<StaffSimpleInfo> toStaffids, int type) {
if(toStaffids.get(0).getEmployeeId() == null || toStaffids.get(0).getEmployeeId().length() == 0){
//查询第三方id
@ -324,7 +320,7 @@ public class DingtalkBusiness {
StaffEntity entity = new StaffEntity();
entity.setId(info.getId());
entity.setEmployeeId(info.getEmployeeId());
dingTalkUtil.sendSingleActionCardMSG(appid, entity, workMsgTypeEnum.getTitle(),
dingTalkUtil.sendSingleWorkMSG(appid, entity, workMsgTypeEnum.getTitle(),
content, workMsgTypeEnum.getBtnText(), url, token);
}else{
logger.info("ThreadSendMessage token无效"); ;

View File

@ -310,7 +310,7 @@ public class AssessManagerServiceImpl implements AssessManagerService {
//通知评分
try {
dingtalkBusiness.sendWorkMSGWithThread(toStaffids, WorkMsgTypeEnum.START_SCORE.getType());
dingtalkBusiness.sendWorkMSGWithAsyn(toStaffids, WorkMsgTypeEnum.START_SCORE.getType());
} catch (Exception e) {
log.error("通知评分异常:",e);
}

View File

@ -19,12 +19,14 @@ import com.lz.common.validator.group.AddGroup;
import com.lz.common.validator.group.UpdateGroup;
import com.lz.modules.app.entity.UserEntity;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.entity.SysUserEntityDto;
import com.lz.modules.sys.form.PasswordForm;
import com.lz.modules.sys.service.SysUserRoleService;
import com.lz.modules.sys.service.SysUserService;
import org.apache.commons.lang.ArrayUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -67,7 +69,10 @@ public class SysUserController extends AbstractController {
*/
@GetMapping("/info")
public R info() {
return R.ok().put("user", getUser());
SysUserEntity sysUserEntity = getUser();
SysUserEntityDto entityDto = new SysUserEntityDto();
BeanUtils.copyProperties(sysUserEntity, entityDto);
return R.ok().put("user", entityDto);
}
/**

View File

@ -49,12 +49,19 @@ public class SysUserEntity implements Serializable {
@NotBlank(message="工号不能为空", groups = AddGroup.class)
private String userNo;
/**
* 用户名
*/
@NotBlank(message="账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String username;
/**
* 头像
*/
@TableField(exist = false)
private String avatar;
/**
* 密码
*/

View File

@ -0,0 +1,97 @@
/**
* Copyright (c) 2020 fumeiai All rights reserved.
*
*
*
* 版权所有侵权必究
*/
package com.lz.modules.sys.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lz.common.validator.group.AddGroup;
import com.lz.common.validator.group.UpdateGroup;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 系统用户
*
* @author Mark sunlightcs@gmail.com
*/
@Data
@TableName("sys_user")
public class SysUserEntityDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
@TableId
private Long userId;
/**
* 员工姓名
*/
@NotBlank(message="员工姓名不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String realName;
/**
* 员工工号
*/
@NotBlank(message="工号不能为空", groups = AddGroup.class)
private String userNo;
/**
* 头像
*/
@TableField(exist = false)
private String avatar;
/**
* 用户名
*/
@NotBlank(message="账号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String username;
/**
* 手机号
*/
@NotBlank(message="手机号不能为空", groups = {AddGroup.class, UpdateGroup.class})
private String mobile;
// /**
// * 邮箱
// */
// @NotBlank(message="邮箱不能为空", groups = {AddGroup.class, UpdateGroup.class})
@Email(message="邮箱格式不正确", groups = {AddGroup.class, UpdateGroup.class})
private String email;
/**
* 状态 0禁用 1正常
*/
private Integer status;
private int type ;// 0 表示系统用户1 表示普通员工
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
}

View File

@ -11,6 +11,7 @@ package com.lz.modules.sys.oauth2;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.sys.entity.SysUserEntity;
import com.lz.modules.sys.entity.SysUserEntityDto;
import com.lz.modules.sys.entity.SysUserTokenEntity;
import com.lz.modules.sys.service.ShiroService;
import org.apache.shiro.authc.*;
@ -71,16 +72,19 @@ public class OAuth2Realm extends AuthorizingRealm {
//查询用户信息
SysUserEntity user = null;
StaffEntity staffEntity = staffService.selectStaffById(tokenEntity.getUserId());
if(tokenEntity.getType() == 0){ //如果是系统用户
user = shiroService.queryUser(tokenEntity.getUserId());
if(staffEntity != null){
user.setAvatar(staffEntity.getAvatar());
}
}else{
user = new SysUserEntity();//如果是普通用户
StaffEntity staffEntity = staffService.selectStaffById(tokenEntity.getUserId());
user.setPassword(staffEntity.getPassword());
user = new SysUserEntity();
user.setMobile(staffEntity.getMobile());
user.setAvatar(staffEntity.getAvatar());
user.setUserId(staffEntity.getId());
user.setEmail(staffEntity.getEmail());
user.setSalt(staffEntity.getSalt());
user.setStatus(1);
user.setType(1);
user.setUsername(staffEntity.getMobile());