Commit 5074daec by chentianzhong

AdminFeignClient 获取人员信以及相关调整,列表增加根据查询参数判断是否获取人员信息(目前仅放出头像)

parent 97be4aa0
package com.zq.email.dto;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.sql.Timestamp;
/**
* @author Zheng Jie
* @date 2019年10月24日20:48:53
*/
@Getter
@Setter
public class BaseDTO implements Serializable {
private String createBy;
private String updatedBy;
private Timestamp createTime;
private Timestamp updateTime;
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
Field[] fields = this.getClass().getDeclaredFields();
try {
for (Field f : fields) {
f.setAccessible(true);
builder.append(f.getName(), f.get(this)).append("\n");
}
} catch (Exception e) {
builder.append("toString builder encounter an error");
}
return builder.toString();
}
}
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zq.email.dto.admin;
import lombok.Data;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-6-10 16:32:18
*/
@Data
public class DeptSmallDto implements Serializable {
private Long id;
private String name;
}
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zq.email.dto.admin;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-6-10 16:32:18
*/
@Data
@NoArgsConstructor
public class JobSmallDto implements Serializable {
private Long id;
private String name;
}
\ No newline at end of file
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.zq.email.dto.admin;
import lombok.Data;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Data
public class RoleSmallDto implements Serializable {
private Long id;
private String name;
private Integer level;
private String dataScope;
}
package com.zq.email.dto.admin;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zq.email.dto.BaseDTO;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
/**
* @author Zheng Jie
* @date 2018-11-23
*/
@Getter
@Setter
public class UserDto extends BaseDTO implements Serializable {
private Long id;
private Set<RoleSmallDto> roles;
private Set<JobSmallDto> jobs;
private DeptSmallDto dept;
private Long deptId;
private String username;
private String nickName;
private String email;
private String phone;
private String gender;
private String avatarName;
private String avatarPath;
@JsonIgnore
private String password;
private Integer enabled;
private Boolean isAdmin = false;
private Boolean isApiUser;
private String apiKey;
private Date pwdResetTime;
private String areaId;
private String cityName;
private String pCode;
private String orgCode;
private String courtCode;
private String courtName;
private String courtIdent;
private String photo;
private Integer isReceiver;
private String postDeptFile;
private Integer isLinux;
private Integer isPwdChange;
private Integer infoHidden;
private Integer enableArchive;
}
......@@ -9,6 +9,7 @@ import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zq.email.dto.admin.UserDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
......@@ -75,5 +76,10 @@ public class EmailPerson implements Serializable {
@TableField(exist = false)
private List<EmailPerson> receiverList;
//发送人信息
@TableField(exist = false)
private UserDto sender;
}
......@@ -7,6 +7,7 @@ import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.SystemInfo;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.feign.fallback.AdminFeignFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -29,9 +30,21 @@ public interface AdminFeignClient {
@GetMapping("/oauth/getUserInfoByToken")
ResultVo<OnlineUserDto> getUserInfoByToken(@RequestParam String token);
@GetMapping("/users/getUserById/{userId}")
@AnonymousAccess
CustomerUserVo getUserById(@PathVariable Long userId);
@ApiOperation("根据用户ID查询用户信息,jpa")
@PostMapping("/users/findById")
ResultVo<UserDto> findById(@RequestParam Long userId);
@ApiOperation("根据用户名(邮箱)查询用户信息,jpa")
@PostMapping("/users/findByUsername")
ResultVo<UserDto> findByUsername(@RequestParam Long username);
@ApiOperation("根据用户标识(人员标识)查询用户信息,jpa")
@PostMapping("/users/findByPCode/{pCode}")
ResultVo<UserDto> findByPCode(@RequestParam("pcode") String pcode);
@ApiOperation("根据部门查询用户信息,jpa")
@PostMapping("/users/findByDeptIds")
ResultVo<List<UserDto>> findByDeptIds(@RequestParam("deptIds") List<Long> deptIds);
@GetMapping(value = "/users/getUserByDeptId/{deptId}")
ResultVo<List<CustomerUserVo>> getUserByDeptId(@PathVariable(value="deptId") Long deptId);
......@@ -45,9 +58,6 @@ public interface AdminFeignClient {
@GetMapping("/systemInfo/getBySystemTag/{systemTag}")
ResultVo<SystemInfo> getBySystemTag(@PathVariable String systemTag);
@ApiOperation("根据人员标识查询用户")
@AnonymousAccess
@GetMapping("/users/getBypCode/{pCode}")
ResultVo<CustomerUserVo> getBypCode(@PathVariable String pCode);
}
......@@ -5,6 +5,7 @@ import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.SystemInfo;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.feign.AdminFeignClient;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -35,34 +36,42 @@ public class AdminFeignFallbackFactory implements FallbackFactory<AdminFeignClie
@Override
public ResultVo<OnlineUserDto> getUserInfoByToken(String token) {
LOG.error("getUserInfoByToken 失败");
return ResultVo.fail(401, "获取人员token失败");
return ResultVo.fail("获取人员token失败");
}
@Override
public CustomerUserVo getUserById(Long userId) {
LOG.error("根据userId获取人员信息失败");
return null;
public ResultVo<UserDto> findById(Long userId) {
return ResultVo.fail("admin服务调用异常-->findById异常");
}
@Override
public ResultVo<List<CustomerUserVo>> getUserByDeptId(Long deptId) {
LOG.error("根据deptId获取部门人员信息失败");
return null;
public ResultVo<UserDto> findByUsername(Long username) {
return ResultVo.fail("admin服务调用异常-->findByUsername异常");
}
@Override
public ResultVo<DeptSimpleDto> getByDeptId(Long deptId) {
return null;
public ResultVo<UserDto> findByPCode(String pcode) {
return ResultVo.fail("admin服务调用异常-->findByPCode异常");
}
@Override
public ResultVo<SystemInfo> getBySystemTag(String systemTag) {
return null;
public ResultVo<List<UserDto>> findByDeptIds(List<Long> deptIds) {
return ResultVo.fail("admin服务调用异常-->findByDeptIds异常");
}
@Override
public ResultVo<CustomerUserVo> getBypCode(String pCode) {
return null;
public ResultVo<List<CustomerUserVo>> getUserByDeptId(Long deptId) {
return ResultVo.fail("admin服务调用异常-->getUserByDeptId异常");
}
@Override
public ResultVo<DeptSimpleDto> getByDeptId(Long deptId) {
return ResultVo.fail("admin服务调用异常-->getByDeptId异常");
}
@Override
public ResultVo<SystemInfo> getBySystemTag(String systemTag) {
return ResultVo.fail("admin服务调用异常-->getBySystemTag异常");
}
......
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zq.email.vo.*;
......@@ -35,7 +36,7 @@ public interface IEmailContentService extends IService<EmailContent> {
List<DeptSimpleDto> findReceiveDeptByContentId(Long contentId);
List<CustomerUserVo> findReceiverByContentId(Long contentId);
List<UserDto> findReceiverByContentId(Long contentId);
List<Long> findRecentlySendEmail(Integer num);
......
......@@ -5,6 +5,7 @@ import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.entity.EmailPerson;
import com.baomidou.mybatisplus.extension.service.IService;
......@@ -42,7 +43,7 @@ public interface IEmailPersonService extends IService<EmailPerson> {
EmailPerson saveEmailSender(CustomerUserVo userVo, EmailContent content, Long folderId, Integer isSend);
//保存收件人
void saveEmailReceiver(List<CustomerUserVo> receiverList, EmailContent content, Long folderId, Integer isPerson, Integer isSend);
void saveEmailReceiver(List<UserDto> receiverList, EmailContent content, Long folderId, Integer isPerson, Integer isSend);
//移动邮件到文件夹
void moveEmailFolder(EmailFolderMoveVo vo);
......@@ -91,7 +92,7 @@ public interface IEmailPersonService extends IService<EmailPerson> {
ResultVo getUserPolice();
//最近联系人
List<CustomerUserVo> recentlyContacts(List<Long> recentlySendEmail);
List<UserDto> recentlyContacts(List<Long> recentlySendEmail);
//
EmailPerson getByIdAndSendTime(Long personId, LocalDateTime sendTime);
......
......@@ -10,6 +10,7 @@ import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.OnlineUserDto;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.DeptSimpleDto;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.enums.EmailDegreeEnum;
import com.zq.email.enums.RemindEnum;
......@@ -183,16 +184,17 @@ public class EmailContentServiceImpl extends ServiceImpl<EmailContentMapper, Ema
}
@Override
public List<CustomerUserVo> findReceiverByContentId(Long contentId) {
List<CustomerUserVo> userVoList = new ArrayList<>();
public List<UserDto> findReceiverByContentId(Long contentId) {
List<UserDto> userVoList = new ArrayList<>();
EmailContent content = this.getById(contentId);
if (StrUtil.isNotBlank(content.getUserList())){
String[] userIds = content.getUserList().split(",");
for (String userId : userIds) {
CustomerUserVo userById = adminFeignClient.getUserById(Long.valueOf(userId));
if (userById!=null){
userVoList.add(userById);
}
ResultVo<UserDto> userDtoResultVo = adminFeignClient.findById(Long.valueOf(userId));
log.error("findReceiverByContentId --> (userId = {"+userId+"}) 获取个人信息信息失败");
AssertUtils.isTrue(userDtoResultVo.isSuccess() && userDtoResultVo.getData()!=null, "获取个人信息失败!");
UserDto data = userDtoResultVo.getData();
userVoList.add(data);
}
}
......
......@@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
import com.zq.common.vo.CustomerUserVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.dto.SystemInfo;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.entity.EmailContent;
import com.zq.email.feign.MessageFeignClient;
import lombok.extern.slf4j.Slf4j;
......@@ -30,14 +31,14 @@ public class MsgUtil {
//发送消息和代办
@Async
public void sendMsg(String sender, EmailContent content, List<CustomerUserVo> userVoList, SystemInfo systemInfo, Integer folderId) {
public void sendMsg(String sender, EmailContent content, List<UserDto> userVoList, SystemInfo systemInfo, Integer folderId) {
Map<String, Object> params = new HashMap<>();
params .put("systemTag", EmailConstant.SYSTEM_TAG);
params .put("sender", sender);
params .put("nickName", sender);
params .put("title","您有一封新邮件提醒");
params .put("content", "请查收我的邮件!主题:"+content.getTitle()+"。");
params.put("userIdList", userVoList.stream().map(e->e.getUserId()).collect(Collectors.toList()));
params.put("userIdList", userVoList.stream().map(e->e.getId()).collect(Collectors.toList()));
params .put("businessId", content.getId());
params.put("jumpUrl", systemInfo.getHomeUrl() + "/#/detail?folderId="+folderId+"&contentId=" + content.getId());
log.debug("---发送内部消息打印内容: {}", JSONUtil.toJsonStr(params));
......
......@@ -10,6 +10,7 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zq.common.vo.CustomerUserVo;
import com.zq.common.vo.ResultVo;
import com.zq.email.dto.admin.UserDto;
import com.zq.email.properties.SmsProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
......@@ -38,10 +39,10 @@ public class SmsUtil {
* @return
*/
@Async
public void sendBatchSms(List<CustomerUserVo> userVoList, String content, Long contentId) {
public void sendBatchSms(List<UserDto> userVoList, String content, Long contentId) {
String regex = "^1[3-9]\\d{9}";
StringBuffer sb = new StringBuffer();
for (CustomerUserVo userVo : userVoList) {
for (UserDto userVo : userVoList) {
if (userVo!=null && StrUtil.isNotBlank(userVo.getPhone()) && userVo.getPhone().matches(regex)){
sb.append(userVo.getPhone()).append(",");
}
......
package com.zq.email.vo;
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.zq.common.vo.PageReqVo;
import com.zq.email.constants.EmailConstant;
import com.zq.email.enums.EmailFolderEnum;
......@@ -74,5 +75,7 @@ public class EmailReqVo extends PageReqVo {
private Integer searchRange = 0;
@ApiModelProperty("0未读 1已读")
private Integer isRead;
@ApiModelProperty("是否获取人员头像")
private Boolean isSenderPhoto = false;
}
......@@ -51,4 +51,8 @@ public class EmailSearchReqVo extends PageReqVo {
@ApiModelProperty("当前人员id :前端不用传")
private Long userId;
@ApiModelProperty("是否获取人员头像")
private Boolean isSenderPhoto = false;
}
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