Commit 11d411c4 authored by Shen's avatar Shen

1. 新增添加/修改机构管理员接口“addMechanism”

2. 优化用户删除
parent 92513729
package io.hmit.modules.serviceOrder.dao;
import io.hmit.common.dao.BaseDao;
import io.hmit.modules.serviceOrder.entity.PensionOrganizationUserEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 机构人员关系
*
* @author Shen Yuanfeng syf0412@vip.qq.com
* @since 1.0.0 2021-05-17
*/
@Mapper
public interface PensionOrganizationUserDao extends BaseDao<PensionOrganizationUserEntity> {
Long findUserOrgId(Long userId);
void deleteByUserIds(Long[] ids);
}
\ No newline at end of file
package io.hmit.modules.serviceOrder.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 机构人员关系
*
* @author Shen Yuanfeng syf0412@vip.qq.com
* @since 1.0.0 2021-05-17
*/
@Data
@ApiModel(value = "机构人员关系")
public class PensionOrganizationUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "机构ID")
private Long organizationId;
@ApiModelProperty(value = "用户ID")
private Long userId;
@ApiModelProperty(value = "服务人员ID")
private Long serviceId;
@ApiModelProperty(value = "创建者")
private Long creator;
@ApiModelProperty(value = "创建时间")
private Date createDate;
}
\ No newline at end of file
package io.hmit.modules.serviceOrder.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 机构人员关系
*
* @author Shen Yuanfeng syf0412@vip.qq.com
* @since 1.0.0 2021-05-17
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("pension_organization_user")
public class PensionOrganizationUserEntity {
private static final long serialVersionUID = 1L;
@TableId
private Long id;
/**
* 机构ID
*/
private Long organizationId;
/**
* 用户ID
*/
private Long userId;
/**
* 服务人员ID
*/
private Long serviceId;
/**
* 创建者
*/
private Long creator;
/**
* 创建时间
*/
private Date createDate;
}
\ No newline at end of file
package io.hmit.modules.serviceOrder.service;
import io.hmit.common.service.CrudService;
import io.hmit.modules.serviceOrder.dto.PensionOrganizationUserDTO;
import io.hmit.modules.serviceOrder.entity.PensionOrganizationUserEntity;
/**
* 机构人员关系
*
* @author Shen Yuanfeng syf0412@vip.qq.com
* @since 1.0.0 2021-05-17
*/
public interface PensionOrganizationUserService extends CrudService<PensionOrganizationUserEntity, PensionOrganizationUserDTO> {
Long findUserOrgId(Long userId);
void deleteByUserIds(Long[] ids);
}
\ No newline at end of file
package io.hmit.modules.serviceOrder.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.modules.serviceOrder.dao.PensionOrganizationUserDao;
import io.hmit.modules.serviceOrder.dto.PensionOrganizationUserDTO;
import io.hmit.modules.serviceOrder.entity.PensionOrganizationUserEntity;
import io.hmit.modules.serviceOrder.service.PensionOrganizationUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 机构人员关系
*
* @author Shen Yuanfeng syf0412@vip.qq.com
* @since 1.0.0 2021-05-17
*/
@Service
public class PensionOrganizationUserServiceImpl extends CrudServiceImpl<PensionOrganizationUserDao, PensionOrganizationUserEntity, PensionOrganizationUserDTO> implements PensionOrganizationUserService {
@Override
public QueryWrapper<PensionOrganizationUserEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get("id");
QueryWrapper<PensionOrganizationUserEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
return wrapper;
}
@Autowired
private PensionOrganizationUserDao pensionOrganizationUserDao;
@Override
public Long findUserOrgId(Long userId) {
return pensionOrganizationUserDao.findUserOrgId(userId);
}
@Override
public void deleteByUserIds(Long[] ids) {
pensionOrganizationUserDao.deleteByUserIds(ids);
}
}
\ No newline at end of file
...@@ -16,8 +16,13 @@ import io.hmit.modules.security.password.PasswordUtils; ...@@ -16,8 +16,13 @@ import io.hmit.modules.security.password.PasswordUtils;
import io.hmit.modules.security.user.SecurityUser; import io.hmit.modules.security.user.SecurityUser;
import io.hmit.modules.security.user.UserDetail; import io.hmit.modules.security.user.UserDetail;
import io.hmit.modules.serviceOrder.dto.PensionOrganizationDTO; import io.hmit.modules.serviceOrder.dto.PensionOrganizationDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrganizationUserDTO;
import io.hmit.modules.serviceOrder.dto.RoleUserDTO;
import io.hmit.modules.serviceOrder.service.PensionOrganizationService; import io.hmit.modules.serviceOrder.service.PensionOrganizationService;
import io.hmit.modules.serviceOrder.service.PensionOrganizationUserService;
import io.hmit.modules.serviceOrder.service.RoleUserService;
import io.hmit.modules.sys.dto.PasswordDTO; import io.hmit.modules.sys.dto.PasswordDTO;
import io.hmit.modules.sys.dto.SysMechanismUserDTO;
import io.hmit.modules.sys.dto.SysUserDTO; import io.hmit.modules.sys.dto.SysUserDTO;
import io.hmit.modules.sys.excel.SysUserExcel; import io.hmit.modules.sys.excel.SysUserExcel;
import io.hmit.modules.sys.service.SysRoleUserService; import io.hmit.modules.sys.service.SysRoleUserService;
...@@ -27,6 +32,7 @@ import io.swagger.annotations.ApiImplicitParam; ...@@ -27,6 +32,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
...@@ -52,6 +58,8 @@ public class SysUserController { ...@@ -52,6 +58,8 @@ public class SysUserController {
private SysRoleUserService sysRoleUserService; private SysRoleUserService sysRoleUserService;
@Autowired @Autowired
private PensionOrganizationService pensionOrganizationService; private PensionOrganizationService pensionOrganizationService;
@Autowired
private PensionOrganizationUserService pensionOrganizationUserService;
@GetMapping("page") @GetMapping("page")
@ApiOperation("分页") @ApiOperation("分页")
...@@ -82,6 +90,10 @@ public class SysUserController { ...@@ -82,6 +90,10 @@ public class SysUserController {
//用户角色列表 //用户角色列表
List<Long> roleIdList = sysRoleUserService.getRoleIdList(id); List<Long> roleIdList = sysRoleUserService.getRoleIdList(id);
data.setRoleIdList(roleIdList); data.setRoleIdList(roleIdList);
//用户机构id
try {
data.setOrgId(pensionOrganizationUserService.findUserOrgId(id));
}catch (Exception ignore){}
return new Result<SysUserDTO>().ok(data); return new Result<SysUserDTO>().ok(data);
} }
...@@ -133,6 +145,26 @@ public class SysUserController { ...@@ -133,6 +145,26 @@ public class SysUserController {
return new Result(); return new Result();
} }
@PutMapping("/addMechanism")
@ApiOperation("添加机构管理员")
@LogOperation("添加机构管理员")
public Result saveMechanism(@RequestBody SysMechanismUserDTO dto) {
sysUserService.addMechanism(dto);
return new Result();
}
@PostMapping("/addMechanism")
@ApiOperation("添加机构管理员")
@LogOperation("添加机构管理员")
public Result updateMechanism(@RequestBody SysMechanismUserDTO dto) {
sysUserService.addMechanism(dto);
return new Result();
}
@PutMapping @PutMapping
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
......
package io.hmit.modules.sys.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.hmit.common.validator.group.AddGroup;
import io.hmit.common.validator.group.DefaultGroup;
import io.hmit.common.validator.group.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 用户管理
*
* @author zsh 408538940@qq.com
* @since 1.0.0
*/
@Data
@ApiModel(value = "机构管理员")
public class SysMechanismUserDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@Null(message = "{id.null}", groups = AddGroup.class)
@NotNull(message = "{id.require}", groups = UpdateGroup.class)
private Long id;
@ApiModelProperty(value = "用户名", required = true)
@NotBlank(message = "{sysuser.username.require}", groups = DefaultGroup.class)
private String username;
@ApiModelProperty(value = "密码", required = true)
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
@NotBlank(message = "{sysuser.password.require}", groups = AddGroup.class)
private String password;
@ApiModelProperty(value = "姓名", required = true)
@NotBlank(message = "{sysuser.realname.require}", groups = DefaultGroup.class)
private String realName;
@ApiModelProperty(value = "头像")
private String headUrl;
@ApiModelProperty(value = "性别 0:男 1:女 2:保密", required = true)
@Range(min = 0, max = 2, message = "{sysuser.gender.range}", groups = DefaultGroup.class)
private Integer gender;
@ApiModelProperty(value = "邮箱")
@Email(message = "{sysuser.email.error}", groups = DefaultGroup.class)
private String email;
@ApiModelProperty(value = "手机号", required = true)
private String mobile;
@ApiModelProperty(value = "状态 0:停用 1:正常", required = true)
@Range(min = 0, max = 1, message = "{sysuser.status.range}", groups = DefaultGroup.class)
private Integer status;
@JsonInclude(value= JsonInclude.Include.NON_NULL)
@ApiModelProperty(value = "机构Id", required = true)
private Long orgId;
@JsonInclude(value= JsonInclude.Include.NON_NULL)
@ApiModelProperty(value = "角色Id", required = true)
private Long roleId;
}
\ No newline at end of file
package io.hmit.modules.sys.dto; package io.hmit.modules.sys.dto;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import io.hmit.common.validator.group.AddGroup; import io.hmit.common.validator.group.AddGroup;
...@@ -33,6 +34,7 @@ public class SysUserDTO implements Serializable { ...@@ -33,6 +34,7 @@ public class SysUserDTO implements Serializable {
@ApiModelProperty(value = "id") @ApiModelProperty(value = "id")
@Null(message = "{id.null}", groups = AddGroup.class) @Null(message = "{id.null}", groups = AddGroup.class)
@NotNull(message = "{id.require}", groups = UpdateGroup.class) @NotNull(message = "{id.require}", groups = UpdateGroup.class)
@TableId
private Long id; private Long id;
@ApiModelProperty(value = "用户名", required = true) @ApiModelProperty(value = "用户名", required = true)
......
...@@ -3,7 +3,7 @@ package io.hmit.modules.sys.service; ...@@ -3,7 +3,7 @@ package io.hmit.modules.sys.service;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO; import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
/** /**
* @Description : TODO * @Description : 模板消息推送
* @Author : Shen Yuanfeng * @Author : Shen Yuanfeng
* @Date : 2021/5/17 13:33 * @Date : 2021/5/17 13:33
*/ */
......
...@@ -2,6 +2,7 @@ package io.hmit.modules.sys.service; ...@@ -2,6 +2,7 @@ package io.hmit.modules.sys.service;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.service.BaseService; import io.hmit.common.service.BaseService;
import io.hmit.modules.sys.dto.SysMechanismUserDTO;
import io.hmit.modules.sys.dto.SysUserDTO; import io.hmit.modules.sys.dto.SysUserDTO;
import io.hmit.modules.sys.entity.SysUserEntity; import io.hmit.modules.sys.entity.SysUserEntity;
...@@ -42,4 +43,6 @@ public interface SysUserService extends BaseService<SysUserEntity> { ...@@ -42,4 +43,6 @@ public interface SysUserService extends BaseService<SysUserEntity> {
* 根据部门ID,查询用户数 * 根据部门ID,查询用户数
*/ */
int getCountByDeptId(Long deptId); int getCountByDeptId(Long deptId);
void addMechanism(SysMechanismUserDTO dto);
} }
...@@ -8,14 +8,21 @@ import io.hmit.common.utils.ConvertUtils; ...@@ -8,14 +8,21 @@ import io.hmit.common.utils.ConvertUtils;
import io.hmit.modules.security.password.PasswordUtils; import io.hmit.modules.security.password.PasswordUtils;
import io.hmit.modules.security.user.SecurityUser; import io.hmit.modules.security.user.SecurityUser;
import io.hmit.modules.security.user.UserDetail; import io.hmit.modules.security.user.UserDetail;
import io.hmit.modules.serviceOrder.dto.PensionOrganizationUserDTO;
import io.hmit.modules.serviceOrder.dto.RoleUserDTO;
import io.hmit.modules.serviceOrder.service.PensionOrganizationUserService;
import io.hmit.modules.serviceOrder.service.RoleUserService;
import io.hmit.modules.sys.dao.SysUserDao; import io.hmit.modules.sys.dao.SysUserDao;
import io.hmit.modules.sys.dto.SysMechanismUserDTO;
import io.hmit.modules.sys.dto.SysUserDTO; import io.hmit.modules.sys.dto.SysUserDTO;
import io.hmit.modules.sys.entity.SysRoleUserEntity;
import io.hmit.modules.sys.entity.SysUserEntity; import io.hmit.modules.sys.entity.SysUserEntity;
import io.hmit.modules.sys.enums.SuperAdminEnum; import io.hmit.modules.sys.enums.SuperAdminEnum;
import io.hmit.modules.sys.service.SysDeptService; import io.hmit.modules.sys.service.SysDeptService;
import io.hmit.modules.sys.service.SysRoleUserService; import io.hmit.modules.sys.service.SysRoleUserService;
import io.hmit.modules.sys.service.SysUserService; import io.hmit.modules.sys.service.SysUserService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -37,6 +44,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit ...@@ -37,6 +44,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
private SysRoleUserService sysRoleUserService; private SysRoleUserService sysRoleUserService;
@Autowired @Autowired
private SysDeptService sysDeptService; private SysDeptService sysDeptService;
@Autowired
private PensionOrganizationUserService pensionOrganizationUserService;
@Override @Override
public PageData<SysUserDTO> page(Map<String, Object> params) { public PageData<SysUserDTO> page(Map<String, Object> params) {
...@@ -135,6 +144,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit ...@@ -135,6 +144,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
//删除角色用户关系 //删除角色用户关系
sysRoleUserService.deleteByUserIds(ids); sysRoleUserService.deleteByUserIds(ids);
pensionOrganizationUserService.deleteByUserIds(ids);
} }
@Override @Override
...@@ -151,4 +162,30 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit ...@@ -151,4 +162,30 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return baseDao.getCountByDeptId(deptId); return baseDao.getCountByDeptId(deptId);
} }
@Override
public void addMechanism(SysMechanismUserDTO dto) {
SysUserEntity sysUserEntity = new SysUserEntity();
BeanUtils.copyProperties(dto,sysUserEntity);
String password = PasswordUtils.encode(dto.getPassword());
sysUserEntity.setPassword(password);
if (null != dto.getId()) {
updateById(sysUserEntity);
} else {
sysUserEntity.setSuperAdmin(0);
insert(sysUserEntity);
//添加用户角色
Long roleId = 1369897144375357442L; //TODO 临时写死机构角色,多选角色数组再修改
SysRoleUserEntity sysRoleUserEntity = new SysRoleUserEntity();
sysRoleUserEntity.setUserId(sysUserEntity.getId());
sysRoleUserEntity.setRoleId(roleId);
// roleUserDTO.setRoleId(dto.getRoleId());
sysRoleUserService.insert(sysRoleUserEntity);
//添加用户机构关系
PensionOrganizationUserDTO pensionOrganizationUserDTO = new PensionOrganizationUserDTO();
pensionOrganizationUserDTO.setOrganizationId(dto.getOrgId());
pensionOrganizationUserDTO.setUserId(sysUserEntity.getId());
pensionOrganizationUserService.save(pensionOrganizationUserDTO);
}
}
} }
...@@ -72,11 +72,11 @@ mybatis-plus: ...@@ -72,11 +72,11 @@ mybatis-plus:
call-setters-on-nulls: true call-setters-on-nulls: true
jdbc-type-for-null: 'null' jdbc-type-for-null: 'null'
QR: QR:
download-path: D:/upload/pension/ # download-path: D:/upload/pension/
# download-path: /home/websoft/java_jar/pension_service/myfile/ download-path: /home/websoft/java_jar/pension_service/myfile/
# download-path: /home/resourse/bsqzc/ D:/123/ /home/websoft/java_jar/pension_service/myfile/ # download-path: /home/resourse/bsqzc/ D:/123/ /home/websoft/java_jar/pension_service/myfile/
domain: 192.168.10.61:8088 # domain: 192.168.10.61:8088
# domain: byyl.zjhmit.com domain: byyladmin.zjhmit.com
wechat: wechat:
......
<?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="io.hmit.modules.serviceOrder.dao.PensionOrganizationUserDao">
<resultMap type="io.hmit.modules.serviceOrder.entity.PensionOrganizationUserEntity" id="pensionOrganizationUserMap">
<result property="id" column="id"/>
<result property="organizationId" column="organization_id"/>
<result property="userId" column="user_id"/>
<result property="serviceId" column="service_id"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
</resultMap>
<select id="findUserOrgId" resultType="Long">
SELECT organization_id FROM pension_organization_user WHERE user_id = #{userId}
</select>
<delete id="deleteByUserIds">
delete from pension_organization_user where user_id in
<foreach item="userId" collection="array" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
<?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="io.hmit.modules.serviceOrder.dao.PensionOrganizationUserDao">
<resultMap type="io.hmit.modules.serviceOrder.entity.PensionOrganizationUserEntity" id="pensionOrganizationUserMap">
<result property="id" column="id"/>
<result property="organizationId" column="organization_id"/>
<result property="userId" column="user_id"/>
<result property="serviceId" column="service_id"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
</resultMap>
</mapper>
\ No newline at end of file
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