用户管理
This commit is contained in:
parent
a1445e792d
commit
5ea53387a5
@ -17,6 +17,8 @@ package com.aircraft.modules.security.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.aircraft.modules.security.service.dto.LoginUserDto;
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.aircraft.modules.system.service.EmEmployeesService;
|
||||
import com.aircraft.utils.enums.UserTypeEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -27,6 +29,7 @@ import com.aircraft.modules.system.domain.User;
|
||||
import com.aircraft.modules.system.service.DataService;
|
||||
import com.aircraft.modules.system.service.RoleService;
|
||||
import com.aircraft.modules.system.service.UserService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
@ -43,6 +46,8 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
private final RoleService roleService;
|
||||
private final DataService dataService;
|
||||
private final UserCacheManager userCacheManager;
|
||||
@Lazy
|
||||
private final EmEmployeesService emEmployeesService;
|
||||
|
||||
@Override
|
||||
public JwtUserDto loadUserByUsername(String username) {
|
||||
@ -57,12 +62,38 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
}
|
||||
// 获取用户的权限
|
||||
List<AuthorityDto> authorities = roleService.buildPermissions(user);
|
||||
EmEmployees emEmployees = null;
|
||||
if (user.getUserType()==1) {
|
||||
emEmployees = emEmployeesService.findByUserId(user.getId());
|
||||
}
|
||||
// 初始化JwtUserDto
|
||||
jwtUserDto = new JwtUserDto(BeanUtil.copyProperties(user, LoginUserDto.class), UserTypeEnum.getByValue(user.getUserType()),dataService.getDeptIds(user), authorities);
|
||||
jwtUserDto = new JwtUserDto(BeanUtil.copyProperties(user, LoginUserDto.class), UserTypeEnum.getByValue(user.getUserType()),dataService.getDeptIds(user), authorities,emEmployees);
|
||||
// 添加缓存数据
|
||||
userCacheManager.addUserCache(username, jwtUserDto);
|
||||
}
|
||||
}
|
||||
return jwtUserDto;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public JwtUserDto loadEmEmployeesByUsername(String username) {
|
||||
// JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
|
||||
// if(jwtUserDto == null){
|
||||
// User user = userService.getLoginData(username);
|
||||
// if (user == null) {
|
||||
// throw new BadRequestException("用户不存在");
|
||||
// } else {
|
||||
// if (!user.getEnabled()) {
|
||||
// throw new BadRequestException("账号未激活!");
|
||||
// }
|
||||
// // 获取用户的权限
|
||||
// List<AuthorityDto> authorities = roleService.buildPermissions(user);
|
||||
// // 初始化JwtUserDto
|
||||
// jwtUserDto = new JwtUserDto(BeanUtil.copyProperties(user, LoginUserDto.class), UserTypeEnum.getByValue(user.getUserType()),dataService.getDeptIds(user), authorities);
|
||||
// // 添加缓存数据
|
||||
// userCacheManager.addUserCache(username, jwtUserDto);
|
||||
// }
|
||||
// }
|
||||
// return jwtUserDto;
|
||||
// }
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ package com.aircraft.modules.security.service.dto;
|
||||
|
||||
import com.aircraft.modules.system.domain.CnCustomer;
|
||||
import com.aircraft.modules.system.domain.Dept;
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.aircraft.utils.enums.UserTypeEnum;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -49,7 +50,8 @@ public class JwtUserDto implements UserDetails {
|
||||
@ApiModelProperty(value = "角色")
|
||||
private final List<AuthorityDto> authorities;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "飞行员端信息")
|
||||
private final EmEmployees emEmployees;
|
||||
|
||||
public JwtUserDto createcnCustomerJwtUserDto(CnCustomer cnCustomer){
|
||||
LoginUserDto userDto = new LoginUserDto();
|
||||
@ -60,7 +62,7 @@ public class JwtUserDto implements UserDetails {
|
||||
userDto.setPassword(null);
|
||||
userDto.setEnabled(true);
|
||||
userDto.setIsAdmin(false);
|
||||
return new JwtUserDto(userDto, UserTypeEnum.CUSTOMER,new ArrayList<>(),new ArrayList<>());
|
||||
return new JwtUserDto(userDto, UserTypeEnum.CUSTOMER,new ArrayList<>(),new ArrayList<>(),null);
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class EmAreaController {
|
||||
@ApiOperation(value = "删除区域")
|
||||
@RequestMapping(value = "{id}", method = {RequestMethod.DELETE})
|
||||
@ApiImplicitParam(name = "id", value = "区域ID", required = true, paramType = "path")
|
||||
public ResponseEntity<Object> delete(@PathVariable final Integer id) {
|
||||
public ResponseEntity<Object> delete(@PathVariable final Long id) {
|
||||
try {
|
||||
EmArea area = entityService.getById(id);
|
||||
List<EmScenic> emScenics = emScenicService.findByAreaId(id);
|
||||
|
@ -16,21 +16,43 @@
|
||||
package com.aircraft.modules.system.controller;
|
||||
|
||||
import com.aircraft.annotation.Log;
|
||||
import com.aircraft.annotation.rest.AnonymousPostMapping;
|
||||
import com.aircraft.config.properties.RsaProperties;
|
||||
import com.aircraft.exception.BadRequestException;
|
||||
import com.aircraft.modules.security.config.CaptchaConfig;
|
||||
import com.aircraft.modules.security.config.LoginProperties;
|
||||
import com.aircraft.modules.security.config.SecurityProperties;
|
||||
import com.aircraft.modules.security.security.TokenProvider;
|
||||
import com.aircraft.modules.security.service.OnlineUserService;
|
||||
import com.aircraft.modules.security.service.UserDetailsServiceImpl;
|
||||
import com.aircraft.modules.security.service.dto.AuthUserDto;
|
||||
import com.aircraft.modules.security.service.dto.JwtUserDto;
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.aircraft.modules.system.domain.vo.EmEmployeesDetailVo;
|
||||
import com.aircraft.modules.system.domain.vo.EmEmployeesVo;
|
||||
import com.aircraft.modules.system.service.EmEmployeesService;
|
||||
import com.aircraft.modules.system.domain.dto.EmEmployeesQueryCriteria;
|
||||
import com.aircraft.utils.PageResult;
|
||||
import com.aircraft.utils.RedisUtils;
|
||||
import com.aircraft.utils.RsaUtils;
|
||||
import com.aircraft.utils.StringUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
@ -41,59 +63,106 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "员工管理")
|
||||
@Api(tags = "飞行员管理")
|
||||
@RequestMapping("/api/emEmployees")
|
||||
public class EmEmployeesController {
|
||||
|
||||
private final EmEmployeesService emEmployeesService;
|
||||
private final SecurityProperties properties;
|
||||
private final RedisUtils redisUtils;
|
||||
private final OnlineUserService onlineUserService;
|
||||
private final TokenProvider tokenProvider;
|
||||
private final LoginProperties loginProperties;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
private final UserDetailsServiceImpl userDetailsService;
|
||||
// private final EmEmployeesService emEmployeesService;
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('emEmployees:list')")
|
||||
public void exportEmEmployees(HttpServletResponse response, EmEmployeesQueryCriteria criteria) throws IOException {
|
||||
emEmployeesService.download(emEmployeesService.queryAll(criteria), response);
|
||||
// @ApiOperation("导出数据")
|
||||
// @GetMapping(value = "/download")
|
||||
// @PreAuthorize("@el.check('emEmployees:list')")
|
||||
// public void exportEmEmployees(HttpServletResponse response, EmEmployeesQueryCriteria criteria) throws IOException {
|
||||
// emEmployeesService.download(emEmployeesService.queryAll(criteria), response);
|
||||
// }
|
||||
//
|
||||
// @GetMapping
|
||||
// @ApiOperation("查询员工管理")
|
||||
// @PreAuthorize("@el.check('emEmployees:list')")
|
||||
// public ResponseEntity<PageResult<EmEmployees>> queryEmEmployees(EmEmployeesQueryCriteria criteria){
|
||||
// Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
// return new ResponseEntity<>(emEmployeesService.queryAll(criteria,page),HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
// @PostMapping
|
||||
// @Log("新增员工管理")
|
||||
// @ApiOperation("新增员工管理")
|
||||
// @PreAuthorize("@el.check('emEmployees:add')")
|
||||
// public ResponseEntity<Object> createEmEmployees(@Validated @RequestBody EmEmployeesVo resources){
|
||||
// emEmployeesService.create(resources);
|
||||
// return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
// }
|
||||
//
|
||||
// @PutMapping
|
||||
// @Log("修改员工管理")
|
||||
// @ApiOperation("修改员工管理")
|
||||
// @PreAuthorize("@el.check('emEmployees:edit')")
|
||||
// public ResponseEntity<Object> updateEmEmployees(@Validated @RequestBody EmEmployeesVo resources){
|
||||
// emEmployeesService.update(resources);
|
||||
// return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
// }
|
||||
//
|
||||
// @DeleteMapping
|
||||
// @Log("删除员工管理")
|
||||
// @ApiOperation("删除员工管理")
|
||||
// @PreAuthorize("@el.check('emEmployees:del')")
|
||||
// public ResponseEntity<Object> deleteEmEmployees(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
|
||||
// emEmployeesService.deleteAll(ids);
|
||||
// return new ResponseEntity<>(HttpStatus.OK);
|
||||
// }
|
||||
|
||||
// @GetMapping("findByPage")
|
||||
// @ApiOperation("分页查询员工管理")
|
||||
// public ResponseEntity<PageResult<EmEmployeesDetailVo>> findByPage(final EmEmployeesDetailVo example, final Page page){
|
||||
// PageResult<EmEmployeesDetailVo> records = emEmployeesService.page(example,page);
|
||||
// return new ResponseEntity<>(records,HttpStatus.OK);
|
||||
// }
|
||||
|
||||
@Log("用户登录")
|
||||
@ApiOperation("登录授权")
|
||||
@AnonymousPostMapping(value = "/login")
|
||||
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
// 密码解密
|
||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||
// 查询验证码
|
||||
String code = redisUtils.get(authUser.getUuid(), String.class);
|
||||
// 清除验证码
|
||||
redisUtils.del(authUser.getUuid());
|
||||
if (StringUtils.isBlank(code)) {
|
||||
throw new BadRequestException("验证码不存在或已过期");
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询员工管理")
|
||||
@PreAuthorize("@el.check('emEmployees:list')")
|
||||
public ResponseEntity<PageResult<EmEmployees>> queryEmEmployees(EmEmployeesQueryCriteria criteria){
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(emEmployeesService.queryAll(criteria,page),HttpStatus.OK);
|
||||
if (StringUtils.isBlank(authUser.getCode()) || !authUser.getCode().equalsIgnoreCase(code)) {
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增员工管理")
|
||||
@ApiOperation("新增员工管理")
|
||||
@PreAuthorize("@el.check('emEmployees:add')")
|
||||
public ResponseEntity<Object> createEmEmployees(@Validated @RequestBody EmEmployeesVo resources){
|
||||
emEmployeesService.create(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
// 获取用户信息
|
||||
JwtUserDto jwtUser = userDetailsService.loadUserByUsername(authUser.getUsername());
|
||||
// 验证用户密码
|
||||
if (!passwordEncoder.matches(password, jwtUser.getPassword())) {
|
||||
throw new BadRequestException("登录密码错误");
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改员工管理")
|
||||
@ApiOperation("修改员工管理")
|
||||
@PreAuthorize("@el.check('emEmployees:edit')")
|
||||
public ResponseEntity<Object> updateEmEmployees(@Validated @RequestBody EmEmployeesVo resources){
|
||||
emEmployeesService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
// 生成令牌
|
||||
String token = tokenProvider.createToken(jwtUser);
|
||||
// 返回 token 与 用户信息
|
||||
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
|
||||
put("token", properties.getTokenStartWith() + token);
|
||||
put("user", jwtUser);
|
||||
}};
|
||||
if (loginProperties.isSingleLogin()) {
|
||||
// 踢掉之前已经登录的token
|
||||
onlineUserService.kickOutForUsername(authUser.getUsername());
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除员工管理")
|
||||
@ApiOperation("删除员工管理")
|
||||
@PreAuthorize("@el.check('emEmployees:del')")
|
||||
public ResponseEntity<Object> deleteEmEmployees(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
|
||||
emEmployeesService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
// 保存在线信息
|
||||
onlineUserService.save(jwtUser, token, request);
|
||||
// 返回登录信息
|
||||
return ResponseEntity.ok(authInfo);
|
||||
}
|
||||
|
||||
@GetMapping("findByPage")
|
||||
@ApiOperation("分页查询员工管理")
|
||||
public ResponseEntity<PageResult<EmEmployeesDetailVo>> findByPage(final EmEmployeesDetailVo example, final Page page){
|
||||
PageResult<EmEmployeesDetailVo> records = emEmployeesService.page(example,page);
|
||||
return new ResponseEntity<>(records,HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@ -4,8 +4,10 @@ package com.aircraft.modules.system.controller;
|
||||
import com.aircraft.annotation.Log;
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.aircraft.modules.system.domain.EmScenic;
|
||||
import com.aircraft.modules.system.domain.User;
|
||||
import com.aircraft.modules.system.service.EmEmployeesService;
|
||||
import com.aircraft.modules.system.service.EmScenicService;
|
||||
import com.aircraft.modules.system.service.UserService;
|
||||
import com.aircraft.utils.PageResult;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -46,7 +48,7 @@ public class EmScenicController {
|
||||
@Autowired
|
||||
private EmScenicService entityService;
|
||||
@Autowired
|
||||
private EmEmployeesService employeesService;
|
||||
private UserService userService;
|
||||
|
||||
@Log("分页查询景区")
|
||||
@ApiOperation(value = "分页查询景区", notes = "分页查询景区")
|
||||
@ -61,13 +63,13 @@ public class EmScenicController {
|
||||
@ApiOperation(value = "删除景区")
|
||||
@RequestMapping(value = "{id}", method = {RequestMethod.DELETE})
|
||||
@ApiImplicitParam(name = "id", value = "景区ID", required = true, paramType = "path")
|
||||
public ResponseEntity<Object> delete(@PathVariable final Integer id) {
|
||||
public ResponseEntity<Object> delete(@PathVariable final Long id) {
|
||||
try {
|
||||
EmScenic scenic = entityService.getById(id);
|
||||
if (null == scenic) {
|
||||
throw new RuntimeException("没有找到id对应对象");
|
||||
}
|
||||
List<EmEmployees> fdBaseUsers = employeesService.findByScenicId(id);
|
||||
List<User> fdBaseUsers = userService.findByScenicId(id);
|
||||
if (null != fdBaseUsers && !fdBaseUsers.isEmpty()) {
|
||||
throw new RuntimeException("部门里面还存在用户,无法删除");
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class EmArea extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
|
@ -42,15 +42,9 @@ public class EmEmployees extends BaseEntity {
|
||||
@ApiModelProperty(value = "姓名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "性别")
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "电话")
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "所属部门ID")
|
||||
private Long departmentId;
|
||||
|
||||
@ApiModelProperty(value = "员工状态")
|
||||
private String status;
|
||||
|
||||
@ -60,18 +54,6 @@ public class EmEmployees extends BaseEntity {
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Timestamp updateTime;
|
||||
|
||||
@ApiModelProperty(value = "区域id")
|
||||
private Integer areaId;
|
||||
|
||||
@ApiModelProperty(value = "景区id")
|
||||
private Integer scenicId;
|
||||
|
||||
@ApiModelProperty(value = "飞行资质")
|
||||
private String qualification;
|
||||
|
||||
@ApiModelProperty(value = "飞行资质附件")
|
||||
private String qualificationAttachment;
|
||||
|
||||
@ApiModelProperty(value = "userid")
|
||||
private Long userid;
|
||||
|
||||
|
@ -21,12 +21,12 @@ public class EmScenic extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 区域id
|
||||
*/
|
||||
private Integer areaId;
|
||||
private Long areaId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
|
@ -104,6 +104,26 @@ public class User extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(value = "最后修改密码的时间", hidden = true)
|
||||
private Date pwdResetTime;
|
||||
|
||||
@ApiModelProperty(value = "区域id")
|
||||
private Long areaId;
|
||||
|
||||
@ApiModelProperty(value = "景区id")
|
||||
private Long scenicId;
|
||||
|
||||
@ApiModelProperty(value = "飞行资质")
|
||||
private String qualification;
|
||||
|
||||
@ApiModelProperty(value = "飞行资质附件")
|
||||
private String qualificationAttachment;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "区域名称")
|
||||
private String areaName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "景区名称")
|
||||
private String scenicName;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||
@Data
|
||||
public class AreaTreeVo implements Serializable {
|
||||
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
@ -25,7 +25,7 @@ public interface EmScenicMapper extends BaseMapper<EmScenic> {
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
EmScenic findByAreaIdAndName(@Param("areaId") Integer areaId, @Param("name") String name);
|
||||
EmScenic findByAreaIdAndName(@Param("areaId") Long areaId, @Param("name") String name);
|
||||
|
||||
/**
|
||||
* 景区按区域统计数量
|
||||
|
@ -109,7 +109,8 @@ public class UserController {
|
||||
public ResponseEntity<Object> createUser(@Validated @RequestBody User resources){
|
||||
checkLevel(resources);
|
||||
// 默认密码 123456
|
||||
resources.setPassword(passwordEncoder.encode("123456"));
|
||||
// resources.setPassword(passwordEncoder.encode("123456"));
|
||||
resources.setPassword(passwordEncoder.encode(resources.getPassword()));
|
||||
userService.create(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
@ -55,4 +55,6 @@ public interface EmAreaService extends IService<EmArea> {
|
||||
List<EmArea> findByIdIn(List<Integer> collect);
|
||||
|
||||
Map<Long, String> getNameMapByIds(List<Long> regionIds);
|
||||
|
||||
EmArea findById(Long areaId);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import com.aircraft.modules.system.domain.dto.EmEmployeesQueryCriteria;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.aircraft.modules.system.domain.vo.EmEmployeesDetailVo;
|
||||
import com.aircraft.modules.system.domain.vo.EmEmployeesVo;
|
||||
@ -50,44 +51,51 @@ public interface EmEmployeesService extends IService<EmEmployees> {
|
||||
*/
|
||||
List<EmEmployees> queryAll(EmEmployeesQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources /
|
||||
*/
|
||||
void create(EmEmployeesVo resources);
|
||||
// /**
|
||||
// * 创建
|
||||
// * @param resources /
|
||||
// */
|
||||
// void create(EmEmployeesVo resources);
|
||||
//
|
||||
// /**
|
||||
// * 编辑
|
||||
// * @param resources /
|
||||
// */
|
||||
// void update(EmEmployeesVo resources);
|
||||
//
|
||||
// /**
|
||||
// * 多选删除
|
||||
// * @param ids /
|
||||
// */
|
||||
// void deleteAll(List<Long> ids);
|
||||
//
|
||||
// /**
|
||||
// * 导出数据
|
||||
// * @param all 待导出的数据
|
||||
// * @param response /
|
||||
// * @throws IOException /
|
||||
// */
|
||||
// void download(List<EmEmployees> all, HttpServletResponse response) throws IOException;
|
||||
//
|
||||
// /**
|
||||
// * 分页查询
|
||||
// * @param example
|
||||
// * @param page
|
||||
// * @return
|
||||
// */
|
||||
// PageResult<EmEmployeesDetailVo> page(EmEmployeesDetailVo example, Page page);
|
||||
//
|
||||
// /**
|
||||
// * 获取景区下的用户
|
||||
// * @param id
|
||||
// * @return
|
||||
// */
|
||||
// List<EmEmployees> findByScenicId(Long id);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources /
|
||||
*/
|
||||
void update(EmEmployeesVo resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<EmEmployees> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param example
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
PageResult<EmEmployeesDetailVo> page(EmEmployeesDetailVo example, Page page);
|
||||
|
||||
/**
|
||||
* 获取景区下的用户
|
||||
* 根据userid查找用户
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<EmEmployees> findByScenicId(Integer id);
|
||||
EmEmployees findByUserId(Long id);
|
||||
}
|
@ -33,7 +33,7 @@ public interface EmScenicService extends IService<EmScenic> {
|
||||
*/
|
||||
PageResult<EmScenic> page(EmScenic example, IPage page);
|
||||
|
||||
List<EmScenic> findByAreaId(Integer id);
|
||||
List<EmScenic> findByAreaId(Long id);
|
||||
|
||||
/**
|
||||
* 查询区域下景区名称
|
||||
@ -41,7 +41,7 @@ public interface EmScenicService extends IService<EmScenic> {
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
EmScenic findByAreaIdAndName(Integer areaId, String name);
|
||||
EmScenic findByAreaIdAndName(Long areaId, String name);
|
||||
|
||||
/**
|
||||
* 景区按区域统计数量
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.aircraft.modules.system.service;
|
||||
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.aircraft.modules.system.domain.User;
|
||||
@ -136,4 +137,11 @@ public interface UserService extends IService<User> {
|
||||
|
||||
void delCaches(Long id, String username);
|
||||
|
||||
/**
|
||||
* 获取景区下的用户
|
||||
* @param areaId
|
||||
* @return
|
||||
*/
|
||||
List<User> findByScenicId(Long areaId);
|
||||
|
||||
}
|
||||
|
@ -101,6 +101,13 @@ public class EmAreaServiceImpl extends ServiceImpl<EmAreaMapper, EmArea> impleme
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmArea findById(Long areaId) {
|
||||
QueryWrapper<EmArea> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(EmArea::getId, areaId);
|
||||
return this.baseMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询
|
||||
*
|
||||
|
@ -33,6 +33,7 @@ import com.aircraft.modules.system.domain.dto.EmEmployeesQueryCriteria;
|
||||
import com.aircraft.modules.system.mapper.EmEmployeesMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -50,11 +51,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
public class EmEmployeesServiceImpl extends ServiceImpl<EmEmployeesMapper, EmEmployees> implements EmEmployeesService {
|
||||
|
||||
private final EmEmployeesMapper emEmployeesMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final UserRoleMapper userRoleMapper;
|
||||
private final RedisUtils redisUtils;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public PageResult<EmEmployees> queryAll(EmEmployeesQueryCriteria criteria, Page<Object> page){
|
||||
@ -66,121 +62,123 @@ public class EmEmployeesServiceImpl extends ServiceImpl<EmEmployeesMapper, EmEmp
|
||||
return emEmployeesMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void create(EmEmployeesVo resources) {
|
||||
// if (userMapper.findByUsername(resources.getUsername()) != null) {
|
||||
// throw new EntityExistException(User.class, "username", resources.getUsername());
|
||||
// }
|
||||
// User user = new User();
|
||||
// BeanUtils.copyProperties(resources, user);
|
||||
// user.setNickName(resources.getName());
|
||||
// user.setEnabled(true);
|
||||
// userMapper.insert(user);
|
||||
// // 保存用户角色
|
||||
// userRoleMapper.insertData(user.getId(), resources.getRoles());
|
||||
// EmEmployees emEmployees = new EmEmployees();
|
||||
// BeanUtils.copyProperties(resources, emEmployees);
|
||||
// emEmployees.setDelFlag(0);
|
||||
// emEmployees.setStatus("1");
|
||||
// emEmployees.setUserid(user.getId());
|
||||
// emEmployeesMapper.insert(resources);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void update(EmEmployeesVo resources) {
|
||||
// User user1 = userMapper.findByUsername(resources.getUsername());
|
||||
// EmEmployees emEmployees = getById(resources.getId());
|
||||
// emEmployees.copy(resources);
|
||||
// // 如果用户的角色改变
|
||||
// if (!resources.getRoles().equals(resources.getRoles())) {
|
||||
// redisUtils.del(CacheKey.DATA_USER + resources.getId());
|
||||
// redisUtils.del(CacheKey.MENU_USER + resources.getId());
|
||||
// redisUtils.del(CacheKey.ROLE_AUTH + resources.getId());
|
||||
// redisUtils.del(CacheKey.ROLE_USER + resources.getId());
|
||||
// }
|
||||
// user1.setUsername(resources.getUsername());
|
||||
// user1.setRoles(resources.getRoles());
|
||||
// user1.setPhone(resources.getPhone());
|
||||
// user1.setNickName(resources.getName());
|
||||
// user1.setGender(resources.getGender());
|
||||
// userMapper.updateById(user1);
|
||||
// // 清除缓存
|
||||
// userService.delCaches(user1.getId(), user1.getUsername());
|
||||
// emEmployeesMapper.updateById(emEmployees);
|
||||
// // 更新用户角色
|
||||
// userRoleMapper.deleteByUserId(resources.getId());
|
||||
// userRoleMapper.insertData(resources.getId(), resources.getRoles());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public void deleteAll(List<Long> ids) {
|
||||
// Set<Long> userIds = new HashSet<>();
|
||||
// for (Long id : ids) {
|
||||
// EmEmployees emEmployees = getById(id);
|
||||
// emEmployees.setDelFlag(1);
|
||||
// emEmployeesMapper.updateById(emEmployees);
|
||||
// // 清理缓存
|
||||
// User user = userService.getById(emEmployees.getUserid());
|
||||
// userService.delCaches(user.getId(), user.getUsername());
|
||||
// userIds.add(emEmployees.getUserid());
|
||||
// }
|
||||
// userMapper.deleteBatchIds(ids);
|
||||
// // 删除用户角色
|
||||
// userRoleMapper.deleteByUserIds(userIds);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void download(List<EmEmployees> all, HttpServletResponse response) throws IOException {
|
||||
// List<Map<String, Object>> list = new ArrayList<>();
|
||||
// for (EmEmployees emEmployees : all) {
|
||||
// Map<String,Object> map = new LinkedHashMap<>();
|
||||
// map.put("姓名", emEmployees.getName());
|
||||
// map.put("电话", emEmployees.getPhone());
|
||||
// map.put("员工状态", emEmployees.getStatus());
|
||||
// map.put("创建时间", emEmployees.getCreateTime());
|
||||
// map.put("更新时间", emEmployees.getUpdateTime());
|
||||
// map.put("userid", emEmployees.getUserid());
|
||||
// list.add(map);
|
||||
// }
|
||||
// FileUtil.downloadExcel(list, response);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public PageResult<EmEmployeesDetailVo> page(EmEmployeesDetailVo example, Page page) {
|
||||
// page.setOptimizeCountSql(false);
|
||||
// return PageUtil.toPage(this.baseMapper.findByExample(buildWrapper(example),page));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 构建查询
|
||||
// *
|
||||
// * @param example
|
||||
// * @return
|
||||
// */
|
||||
// private QueryWrapper<EmEmployeesDetailVo> buildWrapper(EmEmployeesDetailVo example) {
|
||||
// String name = example.getName();
|
||||
// QueryWrapper<EmEmployeesDetailVo> wrapper = new QueryWrapper<>();
|
||||
// wrapper.lambda()
|
||||
// .like(StringUtils.isNotEmpty(name), EmEmployees::getName, name);
|
||||
// return wrapper;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<EmEmployees> findByScenicId(Long areaId) {
|
||||
// QueryWrapper<EmEmployees> wrapper = new QueryWrapper<>();
|
||||
// wrapper.lambda()
|
||||
// .eq(EmEmployees::getAreaId, areaId)
|
||||
// .eq(EmEmployees::getDelFlag, 0);
|
||||
// return super.list(wrapper);
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(EmEmployeesVo resources) {
|
||||
if (userMapper.findByUsername(resources.getUsername()) != null) {
|
||||
throw new EntityExistException(User.class, "username", resources.getUsername());
|
||||
}
|
||||
User user = new User();
|
||||
BeanUtils.copyProperties(resources, user);
|
||||
user.setNickName(resources.getName());
|
||||
user.setEnabled(true);
|
||||
userMapper.insert(user);
|
||||
// 保存用户角色
|
||||
userRoleMapper.insertData(user.getId(), resources.getRoles());
|
||||
EmEmployees emEmployees = new EmEmployees();
|
||||
BeanUtils.copyProperties(resources, emEmployees);
|
||||
emEmployees.setDelFlag(0);
|
||||
emEmployees.setStatus("1");
|
||||
emEmployees.setUserid(user.getId());
|
||||
emEmployeesMapper.insert(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(EmEmployeesVo resources) {
|
||||
User user1 = userMapper.findByUsername(resources.getUsername());
|
||||
EmEmployees emEmployees = getById(resources.getId());
|
||||
emEmployees.copy(resources);
|
||||
// 如果用户的角色改变
|
||||
if (!resources.getRoles().equals(resources.getRoles())) {
|
||||
redisUtils.del(CacheKey.DATA_USER + resources.getId());
|
||||
redisUtils.del(CacheKey.MENU_USER + resources.getId());
|
||||
redisUtils.del(CacheKey.ROLE_AUTH + resources.getId());
|
||||
redisUtils.del(CacheKey.ROLE_USER + resources.getId());
|
||||
}
|
||||
user1.setUsername(resources.getUsername());
|
||||
user1.setRoles(resources.getRoles());
|
||||
user1.setPhone(resources.getPhone());
|
||||
user1.setNickName(resources.getName());
|
||||
user1.setGender(resources.getGender());
|
||||
userMapper.updateById(user1);
|
||||
// 清除缓存
|
||||
userService.delCaches(user1.getId(), user1.getUsername());
|
||||
emEmployeesMapper.updateById(emEmployees);
|
||||
// 更新用户角色
|
||||
userRoleMapper.deleteByUserId(resources.getId());
|
||||
userRoleMapper.insertData(resources.getId(), resources.getRoles());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(List<Long> ids) {
|
||||
Set<Long> userIds = new HashSet<>();
|
||||
for (Long id : ids) {
|
||||
EmEmployees emEmployees = getById(id);
|
||||
emEmployees.setDelFlag(1);
|
||||
emEmployeesMapper.updateById(emEmployees);
|
||||
// 清理缓存
|
||||
User user = userService.getById(emEmployees.getUserid());
|
||||
userService.delCaches(user.getId(), user.getUsername());
|
||||
userIds.add(emEmployees.getUserid());
|
||||
}
|
||||
userMapper.deleteBatchIds(ids);
|
||||
// 删除用户角色
|
||||
userRoleMapper.deleteByUserIds(userIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<EmEmployees> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (EmEmployees emEmployees : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("姓名", emEmployees.getName());
|
||||
map.put("性别", emEmployees.getGender());
|
||||
map.put("电话", emEmployees.getPhone());
|
||||
map.put("所属部门ID", emEmployees.getDepartmentId());
|
||||
map.put("员工状态", emEmployees.getStatus());
|
||||
map.put("创建时间", emEmployees.getCreateTime());
|
||||
map.put("更新时间", emEmployees.getUpdateTime());
|
||||
map.put("区域id", emEmployees.getAreaId());
|
||||
map.put("景区id", emEmployees.getScenicId());
|
||||
map.put("飞行资质", emEmployees.getQualification());
|
||||
map.put("飞行资质附件", emEmployees.getQualificationAttachment());
|
||||
map.put("userid", emEmployees.getUserid());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<EmEmployeesDetailVo> page(EmEmployeesDetailVo example, Page page) {
|
||||
page.setOptimizeCountSql(false);
|
||||
return PageUtil.toPage(this.baseMapper.findByExample(buildWrapper(example),page));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建查询
|
||||
*
|
||||
* @param example
|
||||
* @return
|
||||
*/
|
||||
private QueryWrapper<EmEmployeesDetailVo> buildWrapper(EmEmployeesDetailVo example) {
|
||||
String name = example.getName();
|
||||
QueryWrapper<EmEmployeesDetailVo> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
.like(StringUtils.isNotEmpty(name), EmEmployees::getName, name);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmEmployees> findByScenicId(Integer areaId) {
|
||||
public EmEmployees findByUserId(Long id) {
|
||||
QueryWrapper<EmEmployees> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
.eq(EmEmployees::getAreaId, areaId)
|
||||
.eq(EmEmployees::getDelFlag, 0);
|
||||
return super.list(wrapper);
|
||||
.eq(EmEmployees::getUserid,id);
|
||||
return this.baseMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
}
|
@ -3,11 +3,13 @@ package com.aircraft.modules.system.service.impl;
|
||||
import com.aircraft.modules.system.domain.EmArea;
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.aircraft.modules.system.domain.EmScenic;
|
||||
import com.aircraft.modules.system.domain.User;
|
||||
import com.aircraft.modules.system.domain.vo.AreaNumStatisVo;
|
||||
import com.aircraft.modules.system.mapper.EmScenicMapper;
|
||||
import com.aircraft.modules.system.service.EmAreaService;
|
||||
import com.aircraft.modules.system.service.EmEmployeesService;
|
||||
import com.aircraft.modules.system.service.EmScenicService;
|
||||
import com.aircraft.modules.system.service.UserService;
|
||||
import com.aircraft.utils.PageResult;
|
||||
import com.aircraft.utils.PageUtil;
|
||||
import com.aircraft.utils.StringUtils;
|
||||
@ -38,7 +40,7 @@ public class EmScenicServiceImpl extends ServiceImpl<EmScenicMapper, EmScenic> i
|
||||
private EmAreaService areaService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmEmployeesService employeesService;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public List<EmScenic> list(EmScenic example) {
|
||||
@ -50,7 +52,7 @@ public class EmScenicServiceImpl extends ServiceImpl<EmScenicMapper, EmScenic> i
|
||||
IPage<EmScenic> emScenicIPage = this.page(page,buildWrapper(example));
|
||||
if (emScenicIPage.getRecords() != null&& !emScenicIPage.getRecords().isEmpty()) {
|
||||
for (EmScenic record : emScenicIPage.getRecords()) {
|
||||
List<EmEmployees> fdBaseUsers = employeesService.findByScenicId(record.getId());
|
||||
List<User> fdBaseUsers = userService.findByScenicId(record.getId());
|
||||
record.setPeopleNum(fdBaseUsers.size());
|
||||
}
|
||||
}
|
||||
@ -58,7 +60,7 @@ public class EmScenicServiceImpl extends ServiceImpl<EmScenicMapper, EmScenic> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmScenic> findByAreaId(Integer areaId) {
|
||||
public List<EmScenic> findByAreaId(Long areaId) {
|
||||
QueryWrapper<EmScenic> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
.eq(EmScenic::getAreaId, areaId)
|
||||
@ -67,7 +69,7 @@ public class EmScenicServiceImpl extends ServiceImpl<EmScenicMapper, EmScenic> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmScenic findByAreaIdAndName(Integer areaId, String name) {
|
||||
public EmScenic findByAreaIdAndName(Long areaId, String name) {
|
||||
return this.baseMapper.findByAreaIdAndName(areaId, name);
|
||||
}
|
||||
|
||||
@ -92,7 +94,7 @@ public class EmScenicServiceImpl extends ServiceImpl<EmScenicMapper, EmScenic> i
|
||||
private QueryWrapper<EmScenic> buildWrapper(EmScenic example) {
|
||||
QueryWrapper<EmScenic> wrapper = new QueryWrapper<>();
|
||||
|
||||
Integer areaId = example.getAreaId();
|
||||
Long areaId = example.getAreaId();
|
||||
String name = example.getName();
|
||||
Integer createId = example.getCreateId();
|
||||
|
||||
|
@ -15,6 +15,11 @@
|
||||
*/
|
||||
package com.aircraft.modules.system.service.impl;
|
||||
|
||||
import com.aircraft.modules.system.domain.EmEmployees;
|
||||
import com.aircraft.modules.system.service.EmAreaService;
|
||||
import com.aircraft.modules.system.service.EmEmployeesService;
|
||||
import com.aircraft.modules.system.service.EmScenicService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -32,6 +37,7 @@ import com.aircraft.modules.system.mapper.UserMapper;
|
||||
import com.aircraft.modules.system.mapper.UserRoleMapper;
|
||||
import com.aircraft.modules.system.service.UserService;
|
||||
import com.aircraft.utils.*;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -58,11 +64,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
private final RedisUtils redisUtils;
|
||||
private final UserCacheManager userCacheManager;
|
||||
private final OnlineUserService onlineUserService;
|
||||
private final EmAreaService areaService;
|
||||
private final EmScenicService scenicService;
|
||||
@Lazy
|
||||
private final EmEmployeesService employeesService;
|
||||
|
||||
@Override
|
||||
public PageResult<User> queryAll(UserQueryCriteria criteria, Page<Object> page) {
|
||||
criteria.setOffset(page.offset());
|
||||
List<User> users = userMapper.findAll(criteria);
|
||||
for (User user : users) {
|
||||
if (user.getAreaId() != null) {
|
||||
user.setAreaName(areaService.findById(user.getAreaId()).getName());
|
||||
}
|
||||
if (user.getScenicId() != null) {
|
||||
user.setScenicName(scenicService.findByAreaIdAndName(user.getScenicId(), user.getAreaName()).getName());
|
||||
}
|
||||
}
|
||||
Long total = userMapper.countAll(criteria);
|
||||
return PageUtil.toPage(users, total);
|
||||
}
|
||||
@ -79,6 +97,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
User user = redisUtils.get(key, User.class);
|
||||
if (user == null) {
|
||||
user = getById(id);
|
||||
if (user.getAreaId() != null) {
|
||||
user.setAreaName(areaService.findById(user.getAreaId()).getName());
|
||||
}
|
||||
if (user.getScenicId() != null) {
|
||||
user.setScenicName(scenicService.findByAreaIdAndName(user.getScenicId(), user.getAreaName()).getName());
|
||||
}
|
||||
redisUtils.set(key, user, 1, TimeUnit.DAYS);
|
||||
}
|
||||
return user;
|
||||
@ -98,6 +122,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
throw new EntityExistException(User.class, "phone", resources.getPhone());
|
||||
}
|
||||
save(resources);
|
||||
if (resources.getUserType()==1){
|
||||
EmEmployees emEmployees = new EmEmployees();
|
||||
emEmployees.setDelFlag(0);
|
||||
emEmployees.setPhone(resources.getPhone());
|
||||
emEmployees.setName(resources.getNickName());
|
||||
employeesService.save(emEmployees);
|
||||
}
|
||||
// 保存用户岗位
|
||||
userJobMapper.insertData(resources.getId(), resources.getJobs());
|
||||
// 保存用户角色
|
||||
@ -146,6 +177,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
user.setNickName(resources.getNickName());
|
||||
user.setGender(resources.getGender());
|
||||
saveOrUpdate(user);
|
||||
if (resources.getUserType()==1){
|
||||
EmEmployees emEmployees = employeesService.findByUserId(resources.getId());
|
||||
emEmployees.setPhone(resources.getPhone());
|
||||
emEmployees.setName(resources.getNickName());
|
||||
employeesService.saveOrUpdate(emEmployees);
|
||||
}
|
||||
// 清除缓存
|
||||
delCaches(user.getId(), user.getUsername());
|
||||
// 更新用户岗位
|
||||
@ -178,6 +215,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
for (Long id : ids) {
|
||||
// 清理缓存
|
||||
User user = getById(id);
|
||||
if (user.getUserType()==1){
|
||||
EmEmployees emEmployees = employeesService.findByUserId(id);
|
||||
employeesService.removeById(emEmployees.getId());
|
||||
}
|
||||
delCaches(user.getId(), user.getUsername());
|
||||
}
|
||||
userMapper.deleteBatchIds(ids);
|
||||
@ -283,6 +324,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
flushCache(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByScenicId(Long areaId) {
|
||||
QueryWrapper<User> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda()
|
||||
.eq(User::getAreaId, areaId)
|
||||
.eq(User::getDelFlag, 0);
|
||||
return super.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理 登陆时 用户缓存信息
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user