分页查询用户信息添加单位名称字段

This commit is contained in:
joylink_zhangsai 2020-11-30 17:51:22 +08:00
parent 5eddc4d8e0
commit dbfd391799
3 changed files with 62 additions and 4 deletions

View File

@ -44,4 +44,48 @@ public interface SysUserDAO extends MyBatisBaseDao<SysUser, Long, SysUserExample
" GROUP BY DATE(create_time);" + " GROUP BY DATE(create_time);" +
"</script>") "</script>")
List<DailyLiveQuantityVO> statisticsDailyRegister(@Param("beginDate") LocalDate beginDate, @Param("endDate") LocalDate endDate); List<DailyLiveQuantityVO> statisticsDailyRegister(@Param("beginDate") LocalDate beginDate, @Param("endDate") LocalDate endDate);
// @Results(value = {
// @Result(column = "id", property = "id"),
// @Result(column = "account", property = "account"),
// @Result(column = "name", property = "name"),
// @Result(column = "nickname", property = "nickname"),
// @Result(column = "avatar_path", property = "avatarPath"),
// @Result(column = "password", property = "password"),
// @Result(column = "mobile", property = "mobile"),
// @Result(column = "nationcode", property = "nationcode"),
// @Result(column = "email", property = "email"),
// @Result(column = "wx_id", property = "wxId"),
// @Result(column = "wx_union_id", property = "wxUnionId"),
// @Result(column = "wm_open_id", property = "wmOpenId"),
// @Result(column = "status", property = "status"),
// @Result(column = "roles", property = "roles"), //这行有问题
// @Result(column = "create_time", property = "createTime"),
// @Result(column = "company_id", property = "companyId"),
// @Result(column = "company.name", property = "companyName")
// })
// @Select("<script>" +
// "select\n" +
// " <if test=\"distinct\">\n" +
// " distinct\n" +
// " </if>\n" +
// " <include refid=\"Base_Column_List\" />\n" +
// " , company.name" +
// " from sys_user left join company on sys_user.company_id = company.id\n" +
// " <if test=\"_parameter != null\">\n" +
// " <include refid=\"Example_Where_Clause\" />\n" +
// " </if>\n" +
// " <if test=\"orderByClause != null\">\n" +
// " order by ${orderByClause}\n" +
// " </if>\n" +
// " <if test=\"limit != null\">\n" +
// " <if test=\"offset != null\">\n" +
// " limit ${offset}, ${limit}\n" +
// " </if>\n" +
// " <if test=\"offset == null\">\n" +
// " limit ${limit}\n" +
// " </if>\n" +
// " </if>" +
// "</script>")
// List<UserVO> selectUserWithCompanyName(SysUserExample example);
} }

View File

@ -13,6 +13,7 @@ import club.joylink.rtss.vo.SmsResponse;
import club.joylink.rtss.vo.UserQueryVO; import club.joylink.rtss.vo.UserQueryVO;
import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.VdCode; import club.joylink.rtss.vo.VdCode;
import club.joylink.rtss.vo.client.CompanyVO;
import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.UserConfigVO; import club.joylink.rtss.vo.client.UserConfigVO;
import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.map.MapVO;
@ -33,6 +34,7 @@ import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -83,6 +85,9 @@ public class SysUserService implements ISysUserService {
@Autowired @Autowired
private CompanyDAO companyDAO; private CompanyDAO companyDAO;
@Autowired
private ICompanyService iCompanyService;
@Override @Override
public UserVO findUserByAccountAndPassword(String account, String password) { public UserVO findUserByAccountAndPassword(String account, String password) {
SysUserExample example = new SysUserExample(); SysUserExample example = new SysUserExample();
@ -230,6 +235,13 @@ public class SysUserService implements ISysUserService {
} }
Page<SysUser> page = (Page<SysUser>) this.sysUserDAO.selectByExample(example); Page<SysUser> page = (Page<SysUser>) this.sysUserDAO.selectByExample(example);
List<UserVO> userVOS = UserVO.convert2VO(page.getResult()); List<UserVO> userVOS = UserVO.convert2VO(page.getResult());
Map<Integer, CompanyVO> companyMap = iCompanyService.queryOrganizations().stream()
.collect(Collectors.toMap(CompanyVO::getId, Function.identity()));
userVOS.forEach(user -> {
if (user.getCompanyId() != null) {
user.setCompanyName(companyMap.get(user.getCompanyId()).getName());
}
});
return PageVO.convert(page, userVOS); return PageVO.convert(page, userVOS);
} }

View File

@ -1,17 +1,17 @@
package club.joylink.rtss.vo; package club.joylink.rtss.vo;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.entity.SysUser;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.entity.SysUser;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.util.StringUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
@ -102,6 +102,8 @@ public class UserVO implements Serializable {
private Integer companyId; private Integer companyId;
private String companyName;
public UserVO() {} public UserVO() {}
public UserVO(SysUser sysUser) { public UserVO(SysUser sysUser) {