增加员工相关接口
This commit is contained in:
parent
4d9fd22446
commit
6ef8b2124b
@ -0,0 +1,135 @@
|
|||||||
|
package com.lz.modules.equipment.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.lz.common.utils.R;
|
||||||
|
import com.lz.common.utils.RedisUtils;
|
||||||
|
import com.lz.common.utils.StringUtil;
|
||||||
|
import com.lz.modules.app.annotation.Login;
|
||||||
|
import com.lz.modules.app.entity.StaffEntity;
|
||||||
|
import com.lz.modules.app.service.StaffService;
|
||||||
|
import com.lz.modules.equipment.entity.EquipmentInfo;
|
||||||
|
import com.lz.modules.equipment.entity.SpecialApplyInfo;
|
||||||
|
import com.lz.modules.equipment.entity.model.FindByNameModel;
|
||||||
|
import com.lz.modules.equipment.entity.model.FindEmployeeResModel;
|
||||||
|
import com.lz.modules.equipment.entity.model.FindEquipmentResModel;
|
||||||
|
import com.lz.modules.equipment.entity.model.FindEquipmentsByNameModel;
|
||||||
|
import com.lz.modules.equipment.service.IEquipmentInfoService;
|
||||||
|
import com.lz.modules.equipment.service.SpecialApplyInfoService;
|
||||||
|
import com.lz.modules.sys.controller.AbstractController;
|
||||||
|
import com.lz.modules.sys.oauth2.TokenGenerator;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: djc
|
||||||
|
* @Desc:
|
||||||
|
* @Date: 2020/7/24 17:21
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("api")
|
||||||
|
@Api(value = "员工相关接口", tags = { "Employees" })
|
||||||
|
public class EmployeeController extends AbstractController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StaffService staffService;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtils redisUtils;
|
||||||
|
@Autowired
|
||||||
|
private SpecialApplyInfoService specialApplyInfoService;
|
||||||
|
@Autowired
|
||||||
|
private IEquipmentInfoService iEquipmentInfoService;
|
||||||
|
|
||||||
|
@PostMapping("findEmployeeByName")
|
||||||
|
public R findEmployeeByName(@RequestBody @ApiParam FindByNameModel nameModel){
|
||||||
|
List<FindEmployeeResModel> data = new ArrayList<>();
|
||||||
|
Page<StaffEntity> employeesInfoPage = staffService.selectPage(
|
||||||
|
new Page<>(nameModel.getCurrPage(), nameModel.getPageSize()),
|
||||||
|
new EntityWrapper<StaffEntity>()
|
||||||
|
.eq("is_delete",0)
|
||||||
|
.like(StringUtil.isNotBlank(nameModel.getName()),"name",nameModel.getName()));
|
||||||
|
if(CollectionUtils.isEmpty(employeesInfoPage.getRecords())){
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
employeesInfoPage.getRecords().stream().forEach(employeesInfo -> {
|
||||||
|
FindEmployeeResModel model = new FindEmployeeResModel();
|
||||||
|
BeanUtils.copyProperties(employeesInfo,model);
|
||||||
|
model.setUserId(employeesInfo.getId());
|
||||||
|
data.add(model);
|
||||||
|
});
|
||||||
|
Page<FindEmployeeResModel> list = new Page<>();
|
||||||
|
list.setTotal(employeesInfoPage.getPages());
|
||||||
|
//list.setTotal(employeesInfoPage.getTotal());
|
||||||
|
//list.setSize(employeesInfoPage.getSize());
|
||||||
|
//long pages = list.getPages();
|
||||||
|
list.setRecords(data);
|
||||||
|
return R.ok().put("data", list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("findSpecialApplyByName")
|
||||||
|
public R findSpecialApplyByName(@RequestBody @ApiParam FindByNameModel nameModel){
|
||||||
|
List<FindEmployeeResModel> data = new ArrayList<>();
|
||||||
|
Page<SpecialApplyInfo> specialApplyInfoPage = specialApplyInfoService.selectPage(
|
||||||
|
new Page<>(nameModel.getCurrPage(), nameModel.getPageSize()),
|
||||||
|
new EntityWrapper<SpecialApplyInfo>()
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.like(StringUtil.isNotBlank(nameModel.getName()), "type_desc", nameModel.getName()));
|
||||||
|
|
||||||
|
if(CollectionUtils.isEmpty(specialApplyInfoPage.getRecords())){
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
specialApplyInfoPage.getRecords().stream().forEach(specialApplyInfo -> {
|
||||||
|
FindEmployeeResModel model = new FindEmployeeResModel();
|
||||||
|
model.setUserId(specialApplyInfo.getId());
|
||||||
|
model.setName(specialApplyInfo.getTypeDesc());
|
||||||
|
data.add(model);
|
||||||
|
});
|
||||||
|
Page<FindEmployeeResModel> list = new Page<>();
|
||||||
|
list.setTotal(specialApplyInfoPage.getPages());
|
||||||
|
list.setRecords(data);
|
||||||
|
return R.ok().put("data", list);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("findUsersEquipmentsByName")
|
||||||
|
public R findUsersEquipmentsByName(@RequestBody @ApiParam FindEquipmentsByNameModel nameModel){
|
||||||
|
Page<FindEquipmentResModel> data = new Page<>();
|
||||||
|
Page<EquipmentInfo> equipmentInfoPage = iEquipmentInfoService.selectPage(
|
||||||
|
new Page<>(nameModel.getCurrPage(), nameModel.getPageSize()),
|
||||||
|
new EntityWrapper<EquipmentInfo>()
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.eq(nameModel.isEmployee(), "user_id", nameModel.getUserId())
|
||||||
|
.eq(!nameModel.isEmployee(), "sai_id", nameModel.getUserId()));
|
||||||
|
|
||||||
|
List<EquipmentInfo> records = equipmentInfoPage.getRecords();
|
||||||
|
if(CollectionUtils.isEmpty(records)){
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
List<FindEquipmentResModel> list = records.stream().map(info -> {
|
||||||
|
FindEquipmentResModel model = new FindEquipmentResModel();
|
||||||
|
BeanUtils.copyProperties(info, model);
|
||||||
|
return model;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
data.setTotal(equipmentInfoPage.getPages());
|
||||||
|
data.setRecords(list);
|
||||||
|
return R.ok().put("data", data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.lz.modules.equipment.entity.model;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: djc
|
||||||
|
* @Desc:
|
||||||
|
* @Date: 2020/7/28 17:56
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "查找用户信息响应")
|
||||||
|
public class FindEmployeeResModel {
|
||||||
|
//员工姓名
|
||||||
|
@ApiModelProperty(value = "员工姓名", name = "name")
|
||||||
|
private String name;
|
||||||
|
//员工id
|
||||||
|
@ApiModelProperty(value = "员工id", name = "userId")
|
||||||
|
private Long userId;
|
||||||
|
//职务
|
||||||
|
@ApiModelProperty(value = "职务", name = "job")
|
||||||
|
private String job;
|
||||||
|
//一级部门
|
||||||
|
@ApiModelProperty(value = "一级部门", name = "oneDepartment")
|
||||||
|
private String oneDepartment;
|
||||||
|
//二级部门
|
||||||
|
@ApiModelProperty(value = "二级部门", name = "twoDepartment")
|
||||||
|
private String twoDepartment;
|
||||||
|
//三级部门
|
||||||
|
@ApiModelProperty(value = "三级部门", name = "threeDepartment")
|
||||||
|
private String threeDepartment;
|
||||||
|
@ApiModelProperty(value = "手机号", name = "phone")
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user