Browse Source

用户管理增加关联部门信息,用于居民端跳转工作端和数据端关联账号使用

feature/syp_points
liuchuang 5 years ago
parent
commit
d6fe76fd6b
  1. 10
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysUserDTO.java
  2. 76
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysUserDeptDTO.java
  3. 25
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysUserDeptInfoDTO.java
  4. 94
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysUserDeptController.java
  5. 46
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysUserDeptDao.java
  6. 73
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/SysUserDeptEntity.java
  7. 59
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/excel/SysUserDeptExcel.java
  8. 47
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/redis/SysUserDeptRedis.java
  9. 119
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysUserDeptService.java
  10. 134
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserDeptServiceImpl.java
  11. 26
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java
  12. 47
      esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysUserDao.xml
  13. 30
      esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysUserDeptDao.xml
  14. 4
      esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/FieldConstant.java

10
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysUserDTO.java

@ -109,4 +109,14 @@ public class SysUserDTO implements Serializable {
*/
private String scrip;
/**
* 关联部门ID
*/
private Long relationDeptId;
/**
* 关联部门名称
*/
private String relationDeptName;
}

76
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysUserDeptDTO.java

@ -0,0 +1,76 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@Data
public class SysUserDeptDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 部门ID
*/
private Long deptId;
/**
* 删除标识 0未删除 1删除
*/
private Integer delFlag;
/**
* 创建者
*/
private Long creator;
/**
* 创建时间
*/
private Date createDate;
/**
* 更新者
*/
private Long updater;
/**
* 更新时间
*/
private Date updateDate;
}

25
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/SysUserDeptInfoDTO.java

@ -0,0 +1,25 @@
package com.elink.esua.epdc.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Authorliuchuang
* @Date2020/7/29 18:48
*/
@Data
public class SysUserDeptInfoDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 关联部门ID
*/
private Long relationDeptId;
/**
* 关联部门名称
*/
private String relationDeptName;
}

94
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysUserDeptController.java

@ -0,0 +1,94 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.dto.SysUserDeptDTO;
import com.elink.esua.epdc.excel.SysUserDeptExcel;
import com.elink.esua.epdc.service.SysUserDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@RestController
@RequestMapping("sysuserdept")
public class SysUserDeptController {
@Autowired
private SysUserDeptService sysUserDeptService;
@GetMapping("page")
public Result<PageData<SysUserDeptDTO>> page(@RequestParam Map<String, Object> params){
PageData<SysUserDeptDTO> page = sysUserDeptService.page(params);
return new Result<PageData<SysUserDeptDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<SysUserDeptDTO> get(@PathVariable("id") String id){
SysUserDeptDTO data = sysUserDeptService.get(id);
return new Result<SysUserDeptDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody SysUserDeptDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
sysUserDeptService.save(dto);
return new Result();
}
@PutMapping
public Result update(@RequestBody SysUserDeptDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
sysUserDeptService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
sysUserDeptService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<SysUserDeptDTO> list = sysUserDeptService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, SysUserDeptExcel.class);
}
}

46
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysUserDeptDao.java

@ -0,0 +1,46 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO;
import com.elink.esua.epdc.entity.SysUserDeptEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@Mapper
public interface SysUserDeptDao extends BaseDao<SysUserDeptEntity> {
/**
*
* 根据用户ID获取用户关联部门信息
*
* @param userId
* @return com.elink.esua.epdc.entity.SysUserDeptEntity
* @author liuchuang
* @since 2020/7/29 18:43
*/
SysUserDeptInfoDTO selectUserDeptInfoByUserId(@Param("userId") Long userId);
}

73
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/entity/SysUserDeptEntity.java

@ -0,0 +1,73 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("sys_user_dept")
public class SysUserDeptEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private Long userId;
/**
* 部门ID
*/
private Long deptId;
/**
* 删除标识 0未删除 1删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
private Integer delFlag;
/**
* 更新者
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
}

59
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/excel/SysUserDeptExcel.java

@ -0,0 +1,59 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@Data
public class SysUserDeptExcel {
@Excel(name = "id")
private String id;
@Excel(name = "用户ID")
private Long userId;
@Excel(name = "部门ID")
private Long deptId;
@Excel(name = "删除标识 0:未删除 1:删除")
private Integer delFlag;
@Excel(name = "创建者")
private Long creator;
@Excel(name = "创建时间")
private Date createDate;
@Excel(name = "更新者")
private Long updater;
@Excel(name = "更新时间")
private Date updateDate;
}

47
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/redis/SysUserDeptRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.redis;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@Component
public class SysUserDeptRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

119
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysUserDeptService.java

@ -0,0 +1,119 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.dto.SysUserDeptDTO;
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO;
import com.elink.esua.epdc.entity.SysUserDeptEntity;
import java.util.List;
import java.util.Map;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
public interface SysUserDeptService extends BaseService<SysUserDeptEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<SysUserDeptDTO>
* @author generator
* @date 2020-07-29
*/
PageData<SysUserDeptDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<SysUserDeptDTO>
* @author generator
* @date 2020-07-29
*/
List<SysUserDeptDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return SysUserDeptDTO
* @author generator
* @date 2020-07-29
*/
SysUserDeptDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2020-07-29
*/
void save(SysUserDeptDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2020-07-29
*/
void update(SysUserDeptDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2020-07-29
*/
void delete(String[] ids);
/**
*
* 保存/更新用户关联部门信息
*
* @param userId
* @param deptId
* @return void
* @author liuchuang
* @since 2020/7/29 15:56
*/
void saveOrUpdateUserDeptInfo(Long userId, Long deptId);
/**
*
* 根据用户ID获取用户关联部门信息
*
* @param userId
* @return com.elink.esua.epdc.dto.SysUserDeptInfoDTO
* @author liuchuang
* @since 2020/7/29 16:19
*/
SysUserDeptInfoDTO getUserDeptInfoByUserId(Long userId);
}

134
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserDeptServiceImpl.java

@ -0,0 +1,134 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.enums.DelFlagEnum;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dao.SysUserDeptDao;
import com.elink.esua.epdc.dto.SysUserDeptDTO;
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO;
import com.elink.esua.epdc.entity.SysUserDeptEntity;
import com.elink.esua.epdc.entity.SysUserEntity;
import com.elink.esua.epdc.redis.SysUserDeptRedis;
import com.elink.esua.epdc.service.SysUserDeptService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 用户部门关系表
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2020-07-29
*/
@Service
public class SysUserDeptServiceImpl extends BaseServiceImpl<SysUserDeptDao, SysUserDeptEntity> implements SysUserDeptService {
@Autowired
private SysUserDeptRedis sysUserDeptRedis;
@Override
public PageData<SysUserDeptDTO> page(Map<String, Object> params) {
IPage<SysUserDeptEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, SysUserDeptDTO.class);
}
@Override
public List<SysUserDeptDTO> list(Map<String, Object> params) {
List<SysUserDeptEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, SysUserDeptDTO.class);
}
private QueryWrapper<SysUserDeptEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<SysUserDeptEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public SysUserDeptDTO get(String id) {
SysUserDeptEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, SysUserDeptDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void save(SysUserDeptDTO dto) {
SysUserDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysUserDeptEntity.class);
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(SysUserDeptDTO dto) {
SysUserDeptEntity entity = ConvertUtils.sourceToTarget(dto, SysUserDeptEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdateUserDeptInfo(Long userId, Long deptId) {
if (null != userId && null != deptId) {
QueryWrapper<SysUserDeptEntity> wrapper = new QueryWrapper<>();
wrapper.eq(FieldConstant.USER_ID, userId)
.eq(FieldConstant.DEL_FLAG, DelFlagEnum.NORMAL.value());
SysUserDeptEntity userDeptEntity = baseDao.selectOne(wrapper);
if (null != userDeptEntity) {
userDeptEntity.setUserId(userId);
userDeptEntity.setDeptId(deptId);
updateById(userDeptEntity);
} else {
SysUserDeptEntity entity = new SysUserDeptEntity();
entity.setUserId(userId);
entity.setDeptId(deptId);
insert(entity);
}
}
}
@Override
public SysUserDeptInfoDTO getUserDeptInfoByUserId(Long userId) {
return baseDao.selectUserDeptInfoByUserId(userId);
}
}

26
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysUserServiceImpl.java

@ -26,6 +26,8 @@ import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.SysUserDao;
import com.elink.esua.epdc.dto.SysUserDTO;
import com.elink.esua.epdc.dto.SysUserDeptDTO;
import com.elink.esua.epdc.dto.SysUserDeptInfoDTO;
import com.elink.esua.epdc.dto.SysUserOpenIdFormDTO;
import com.elink.esua.epdc.dto.epdc.GridForLeaderRegisterDTO;
import com.elink.esua.epdc.dto.epdc.GridLeaderRegisterDTO;
@ -33,6 +35,7 @@ import com.elink.esua.epdc.dto.epdc.form.EpdcScripUserInfoFormDTO;
import com.elink.esua.epdc.entity.SysUserEntity;
import com.elink.esua.epdc.service.SysDeptService;
import com.elink.esua.epdc.service.SysRoleUserService;
import com.elink.esua.epdc.service.SysUserDeptService;
import com.elink.esua.epdc.service.SysUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -56,6 +59,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysUserDeptService sysUserDeptService;
@Override
public PageData<SysUserDTO> page(Map<String, Object> params) {
//转换成like
@ -95,7 +101,16 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
public SysUserDTO get(Long id) {
SysUserEntity entity = baseDao.getById(id);
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
SysUserDTO dto = ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
// 获取用户关联部门信息
SysUserDeptInfoDTO sysUserDeptInfoDto = sysUserDeptService.getUserDeptInfoByUserId(id);
if (null != sysUserDeptInfoDto) {
dto.setRelationDeptId(sysUserDeptInfoDto.getRelationDeptId());
dto.setRelationDeptName(sysUserDeptInfoDto.getRelationDeptName());
}
return dto;
}
@Override
@ -122,6 +137,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
//保存角色用户关系
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList());
// 保存/更新用户关联部门信息
sysUserDeptService.saveOrUpdateUserDeptInfo(entity.getId(), dto.getRelationDeptId());
}
@Override
@ -145,6 +164,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
//更新角色用户关系
sysRoleUserService.saveOrUpdate(entity.getId(), dto.getRoleIdList());
// 保存/更新用户关联部门信息
sysUserDeptService.saveOrUpdateUserDeptInfo(entity.getId(), dto.getRelationDeptId());
}
/**
@ -268,7 +290,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
public String getUserInfoByGridAndMobile(EpdcScripUserInfoFormDTO epdcScripUserInfoFormDTO) {
SysUserDTO userDTO = baseDao.selectOneUserInfoByGridAndMobile(epdcScripUserInfoFormDTO);
if(userDTO==null){
throw new RenException("根据信息无法获取到pc端用户");
throw new RenException("您的手机号未绑定账号信息");
}
String randomValue = String.valueOf((int)(Math.random()*(1000000-100000)+100000));
SysUserEntity userEntity = new SysUserEntity();

47
esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysUserDao.xml

@ -179,27 +179,30 @@
limit 1
</select>
<select id="selectOneUserInfoByScrip" resultType="com.elink.esua.epdc.dto.SysUserDTO">
select ID,
USERNAME,
PASSWORD,
REAL_NAME,
HEAD_URL,
GENDER,
EMAIL,
MOBILE,
DEPT_ID,
SUPER_ADMIN,
STATUS,
REMARK,
DEL_FLAG,
CREATOR,
CREATE_DATE,
UPDATER,
UPDATE_DATE,
USER_TAG_KEY,
OPEN_ID,
scrip
from sys_user
where del_flag='0' and scrip = #{scrip}
select u.ID,
u.USERNAME,
u.PASSWORD,
u.REAL_NAME,
u.HEAD_URL,
u.GENDER,
u.EMAIL,
u.MOBILE,
u.DEPT_ID,
u.SUPER_ADMIN,
u.STATUS,
u.REMARK,
u.DEL_FLAG,
u.CREATOR,
u.CREATE_DATE,
u.UPDATER,
u.UPDATE_DATE,
u.USER_TAG_KEY,
u.OPEN_ID,
u.scrip
from sys_user u
LEFT JOIN sys_user_dept ud ON u.id = ud.user_id AND ud.del_flag = '0'
where u.del_flag='0' and ud.dept_id=#{gridId} and u.mobile = #{mobile}
order by u.CREATE_DATE desc
limit 1;
</select>
</mapper>

30
esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysUserDeptDao.xml

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.dao.SysUserDeptDao">
<resultMap type="com.elink.esua.epdc.entity.SysUserDeptEntity" id="sysUserDeptMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
<result property="delFlag" column="del_flag"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/>
</resultMap>
<select id="selectUserDeptInfoByUserId" resultType="com.elink.esua.epdc.dto.SysUserDeptInfoDTO">
SELECT
d.id relationDeptId,
d.`name` relationDeptName
FROM
sys_user_dept ud
LEFT JOIN sys_dept d ON d.id = ud.dept_id
AND d.del_flag = 0
WHERE
ud.del_flag = 0
AND ud.user_id = #{userId}
</select>
</mapper>

4
esua-epdc/epdc-commons/epdc-commons-tools/src/main/java/com/elink/esua/epdc/commons/tools/constant/FieldConstant.java

@ -49,6 +49,10 @@ public interface FieldConstant {
String GRID_ID = "GRID_ID";
String GRID_ID_HUMP = "gridId";
String USER_ID = "USER_ID";
String USER_ID_HUMP = "userId";
String DEPT_ID = "DEPT_ID";
String DEPT_ID_HUMP = "deptId";
}

Loading…
Cancel
Save