Commit b8606b96 by 邓实川

dto返回企业主、子账号列表

parent 4726ae20
......@@ -8,10 +8,11 @@
package cn.timer.api.controller.qyzx;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -29,6 +30,7 @@ import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enums.SysRoleType;
import cn.timer.api.dto.qyzx.QyzxAuthDto;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
......@@ -116,23 +118,35 @@ public class Auth {
@GetMapping(value = "/getAll")
@ApiOperation(value = "获取全部账号信息", httpMethod = "GET", notes = "接口发布说明")
public Result<List<YgglMainEmp>> getAll(@CurrentUser UserBean userBean) {
public Result<List<QyzxAuthDto>> getAll(@CurrentUser UserBean userBean) {
List<Integer> roles = new ArrayList<Integer>();
roles.add(SysRoleType.U_TYPE_ADMIN.getType());
roles.add(SysRoleType.U_TYPE_C_ADMIN.getType());
List<QyzxEmpEntAsso> list = QyzxEmpEntAsso.builder().build().selectList(
new LambdaQueryWrapper<QyzxEmpEntAsso>().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode())
.in(QyzxEmpEntAsso::getUserType, roles).select(QyzxEmpEntAsso::getEmpNum));
List<YgglMainEmp> ygs = new ArrayList<YgglMainEmp>();
List<QyzxAuthDto> ygs = new ArrayList<QyzxAuthDto>();
List<Integer> empNums = list.stream().map(QyzxEmpEntAsso::getEmpNum).collect(Collectors.toList());
for (Integer empNum : empNums) {
YgglMainEmp yg = YgglMainEmp.builder().build()
.selectOne(new LambdaQueryWrapper<YgglMainEmp>().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
.eq(YgglMainEmp::getEmpNum, empNum)
.select(YgglMainEmp::getName, YgglMainEmp::getPhone, YgglMainEmp::getEmpNum));
QyzxEmpEntAsso qyzxEmpEntAsso = QyzxEmpEntAsso.builder().build()
.selectOne(new LambdaQueryWrapper<QyzxEmpEntAsso>()
.eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode()).eq(QyzxEmpEntAsso::getEmpNum, empNum)
.select(QyzxEmpEntAsso::getUserType));
QyzxAuthDto dto = new QyzxAuthDto();
dto.setEmpNum(empNum);
dto.setName(yg.getName());
dto.setPhone(yg.getPhone());
if (qyzxEmpEntAsso != null)
dto.setUserType(qyzxEmpEntAsso.getUserType());
if (yg != null)
ygs.add(yg);
ygs.add(dto);
}
Collections.sort(ygs, Comparator.comparing(QyzxAuthDto::getUserType));
return ResultUtil.data(ygs, "查询成功");
}
......
/**
* Title: QyzxAuthDto.java
* Description:
* @author dsc
* @date 2020年6月19日
* @version 1.0
*/
package cn.timer.api.dto.qyzx;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Title: QyzxAuthDto.java
*
* @Description:
* @author dsc
* @date 2020年6月19日
* @version 1.0
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class QyzxAuthDto {
private Integer empNum;
private String name;
private String phone;
private Integer userType;
}
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