Commit 43bc1a7d by zhiwj

Merge branch 'developer' of…

Merge branch 'developer' of http://115.159.76.241/base_platform_enterprise/gic-platform-auth into developer
parents 8a164c4d 9b496dd6
package com.gic.auth.constant;
/**
* 账号分组组员类型
* @ClassName: MenuTypeEnum

* @Description: 

* @author guojuxing

* @date 2019/9/17 11:05 AM

*/
public enum AccountGroupMemberTypeEnum {
ADMIN(1, "管理员"),
COLLABORATOR(2, "协作人");
private int code;
private String message;
private AccountGroupMemberTypeEnum(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.Date;
/**
* 账号分组组员关联
* @ClassName: AccountGroupRelDTO

* @Description: 

* @author guojuxing

* @date 2019/10/31 9:32 AM

*/
public class AccountGroupRelDTO implements Serializable{
private static final long serialVersionUID = -6909938575008627379L;
/**
* ID
*/
private Integer accountGroupRelId;
/**
* 账号分组ID
*/
private Integer accountGroupId;
/**
* 用户ID/协作人ID
*/
private Integer userId;
/**
*
*/
private Integer enterpriseId;
/**
* 1:有效 0:无效
*/
private Integer status;
/**
* 1:管理员 2:协作人
*/
private Integer type;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public Integer getAccountGroupRelId() {
return accountGroupRelId;
}
public void setAccountGroupRelId(Integer accountGroupRelId) {
this.accountGroupRelId = accountGroupRelId;
}
public Integer getAccountGroupId() {
return accountGroupId;
}
public void setAccountGroupId(Integer accountGroupId) {
this.accountGroupId = accountGroupId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
......@@ -115,6 +115,10 @@ public class UserDTO implements Serializable{
* 1:是编辑操作,并且没修改过密码 2:与1相反
*/
private Integer operPasswordType;
/**
* 账号分组,可以多选,用英文逗号隔开
*/
private String accountGroupIds;
public Integer getUserId() {
return userId;
......@@ -251,4 +255,12 @@ public class UserDTO implements Serializable{
public void setOperPasswordType(Integer operPasswordType) {
this.operPasswordType = operPasswordType;
}
public String getAccountGroupIds() {
return accountGroupIds;
}
public void setAccountGroupIds(String accountGroupIds) {
this.accountGroupIds = accountGroupIds;
}
}
......@@ -120,4 +120,16 @@ public interface UserApiService {
ServiceResponse<List<UserDTO>> listUserByIdList(List<Integer> userIdList);
ServiceResponse<UserDetail> getUserDetail(String token);
/**
* 移除对应的分组
* @Title: removeAccountGroup

* @Description:

 * @author guojuxing
* @param accountGroupId
* @param userId

* @param type
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


 */
ServiceResponse<Void> removeAccountGroup(Integer accountGroupId, Integer userId, Integer type);
}
package com.gic.auth.dao.mapper;
import com.gic.auth.dto.AccountGroupRelDTO;
import com.gic.auth.entity.TabSysAccountGroupRel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabSysAccountGroupRelMapper {
/**
* 根据主键删除
*
* @param accountGroupRelId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer accountGroupRelId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabSysAccountGroupRel record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabSysAccountGroupRel record);
/**
* 根据主键查询
*
* @param accountGroupRelId 主键
* @return 实体对象
*/
TabSysAccountGroupRel selectByPrimaryKey(Integer accountGroupRelId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabSysAccountGroupRel record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabSysAccountGroupRel record);
/**
* 逻辑删除分组下的组员关联
* @Title: deleteByAccountGroupId

* @Description:

 * @author guojuxing
* @param accountGroupId

* @return void


 */
void deleteByAccountGroupId(@Param("accountGroupId") Integer accountGroupId);
/**
* 批量插入
* @Title: insertForeach

* @Description:

 * @author guojuxing
* @param list

* @return void


 */
void insertForeach(@Param("list") List<AccountGroupRelDTO> list);
/**
* 逻辑删除用户分组关联
* @Title: deleteByUserId

* @Description:

 * @author guojuxing
* @param userId

* @return void


 */
void deleteByUserId(@Param("userId") Integer userId,@Param("type") Integer type);
/**
* 查询用户分组列表数据
* @Title: listByUserId

* @Description:

 * @author guojuxing
* @param userId

* @return java.util.List<com.gic.auth.entity.TabSysAccountGroupRel>


 */
List<TabSysAccountGroupRel> listByUserId(@Param("userId") Integer userId, @Param("type") Integer type);
/**
* 逻辑删除用户对应分组数据
* @Title: deleteByAccountGroupIdAndUserId

* @Description:

 * @author guojuxing
* @param userId
* @param accountGroupId
* @param type

* @return void


 */
void deleteByAccountGroupIdAndUserId(@Param("userId")Integer userId,@Param("accountGroupId") Integer accountGroupId,@Param("type") Integer type);
}
\ No newline at end of file
package com.gic.auth.entity;
import java.util.Date;
/**
* tab_sys_account_group_rel
*/
public class TabSysAccountGroupRel {
/**
* ID
*/
private Integer accountGroupRelId;
/**
* 账号分组ID
*/
private Integer accountGroupId;
/**
* 用户ID/协作人ID
*/
private Integer userId;
/**
*
*/
private Integer enterpriseId;
/**
* 1:有效 0:无效
*/
private Integer status;
/**
* 1:管理员 2:协作人
*/
private Integer type;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public Integer getAccountGroupRelId() {
return accountGroupRelId;
}
public void setAccountGroupRelId(Integer accountGroupRelId) {
this.accountGroupRelId = accountGroupRelId;
}
public Integer getAccountGroupId() {
return accountGroupId;
}
public void setAccountGroupId(Integer accountGroupId) {
this.accountGroupId = accountGroupId;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.gic.auth.service;
import com.gic.auth.dto.AccountGroupRelDTO;
import com.gic.auth.entity.TabSysAccountGroupRel;
import java.util.List;
/**
* 账号分组组员关联
* @ClassName: AccountGroupRelService

* @Description: 

* @author guojuxing

* @date 2019/10/31 9:35 AM

*/
public interface AccountGroupRelService {
/**
* 批量新增
* @Title: insertFetch

* @Description:

 * @author guojuxing
* @param list

* @return void


 */
void insertFetch(List<AccountGroupRelDTO> list);
/**
* 逻辑删除分组下的关联
* @Title: deleteByAccountGroupId

* @Description:

 * @author guojuxing
* @param accountGroupId

* @return void


 */
void deleteByAccountGroupId(Integer accountGroupId);
/**
* 逻辑删除用户分组关联
* @Title: deleteByUserId

* @Description:

 * @author guojuxing
* @param userId

* @param type
* @return void


 */
void deleteByUserId(Integer userId, Integer type);
/**
* 用户所在分组列表数据
* @Title: listByUserId

* @Description:

 * @author guojuxing
* @param userId

* @param type
* @return java.util.List<com.gic.auth.entity.TabSysAccountGroupRel>


 */
List<TabSysAccountGroupRel> listByUserId(Integer userId, Integer type);
/**
* 删除用户对应分组数据
* @Title: deleteByAccountGroupIdAndUserId

* @Description:

 * @author guojuxing
* @param userId
* @param accountGroupId
* @param type

* @return void


 */
void deleteByAccountGroupIdAndUserId(Integer userId, Integer accountGroupId, Integer type);
}
package com.gic.auth.service.impl;
import com.gic.auth.constant.AccountGroupMemberTypeEnum;
import com.gic.auth.dao.mapper.TabSysAccountGroupRelMapper;
import com.gic.auth.dto.AccountGroupRelDTO;
import com.gic.auth.entity.TabSysAccountGroupRel;
import com.gic.auth.service.AccountGroupRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service("accountGroupRelService")
public class AccountGroupRelServiceImpl implements AccountGroupRelService{
@Autowired
private TabSysAccountGroupRelMapper tabSysAccountGroupRelMapper;
@Override
public void insertFetch(List<AccountGroupRelDTO> list) {
tabSysAccountGroupRelMapper.insertForeach(list);
}
@Override
public void deleteByAccountGroupId(Integer accountGroupId) {
tabSysAccountGroupRelMapper.deleteByAccountGroupId(accountGroupId);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void deleteByUserId(Integer userId, Integer type) {
if (type == null) {
type = AccountGroupMemberTypeEnum.ADMIN.getCode();
}
tabSysAccountGroupRelMapper.deleteByUserId(userId, type);
}
@Override
public List<TabSysAccountGroupRel> listByUserId(Integer userId, Integer type) {
if (type == null) {
type = AccountGroupMemberTypeEnum.ADMIN.getCode();
}
return tabSysAccountGroupRelMapper.listByUserId(userId, type);
}
@Override
public void deleteByAccountGroupIdAndUserId(Integer userId, Integer accountGroupId, Integer type) {
if (type == null) {
type = AccountGroupMemberTypeEnum.ADMIN.getCode();
}
tabSysAccountGroupRelMapper.deleteByAccountGroupIdAndUserId(userId, accountGroupId, type);
}
}
package com.gic.auth.service.outer.impl;
import com.gic.auth.entity.TabSysAccountGroup;
import com.gic.auth.service.AccountGroupRelService;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.error.ErrorCode;
import org.apache.commons.collections.CollectionUtils;
......@@ -21,6 +22,8 @@ import java.util.List;
public class AccountGroupApiServiceImpl implements AccountGroupApiService{
@Autowired
private AccountGroupService accountGroupService;
@Autowired
private AccountGroupRelService accountGroupRelService;
@Override
public ServiceResponse<Integer> save(AccountGroupDTO dto) {
//参数校验
......@@ -75,8 +78,8 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService{
}
//逻辑删除分组
accountGroupService.updateStatusByAccountGroupId(accountGroupId);
//todo 删除组员分组关系数据
//删除组员分组关系数据
accountGroupRelService.deleteByAccountGroupId(accountGroupId);
return ServiceResponse.success();
}
......
......@@ -154,7 +154,7 @@ public class MenuApiServiceImpl implements MenuApiService {
saveHasBuyAppMenu(appList);
List<String> projectList = new ArrayList<>(appList.size());
for (ApplicationDTO app : appList) {
projectList.add(app.getModuleCode());
projectList.add(app.getApplicationId().toString());
}
List<MenuDTO> menuList = EntityUtil.changeEntityListNew(MenuDTO.class,
menuService.selectByProjectList(projectList));
......@@ -543,22 +543,18 @@ public class MenuApiServiceImpl implements MenuApiService {
if (appListResponse.isSuccess()) {
List<ApplicationDTO> appList = appListResponse.getResult();
for (ApplicationDTO app : appList) {
if (StringUtils.isBlank(app.getModuleCode())) {
//没有唯一code,则不存数据
continue;
}
if (appMenu.containsKey(app.getApplicationId().toString())) {
//如果已存在,则更新版本信息
MenuDTO menuDTO = new MenuDTO();
menuDTO.setMenuName(app.getName());
menuDTO.setProject(app.getModuleCode());
menuDTO.setProject(app.getApplicationId().toString());
setMenuVersion(app.getPropDTOList(), menuDTO);
menuDTO.setMenuId(appMenu.get(app.getApplicationId().toString()).getMenuId());
menuService.updatePage(menuDTO);
} else {
MenuDTO menuDTO = new MenuDTO();
menuDTO.setMenuName(app.getName());
menuDTO.setProject(app.getModuleCode());
menuDTO.setProject(app.getApplicationId().toString());
setMenuVersion(app.getPropDTOList(), menuDTO);
setNormalFieldValue(menuDTO);
menuService.savePage(menuDTO);
......
package com.gic.auth.service.outer.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.gic.auth.entity.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.dto.UserListDTO;
import com.gic.auth.dto.UserResourceDTO;
import com.gic.auth.dto.UserRoleDTO;
import com.gic.auth.entity.TabSysResource;
import com.gic.auth.entity.TabSysRole;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.constant.AccountGroupMemberTypeEnum;
import com.gic.auth.dto.*;
import com.gic.auth.qo.UserListQO;
import com.gic.auth.service.*;
import com.gic.auth.utils.ValidSplitUtils;
......@@ -18,19 +25,8 @@ import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.AutoCreatePasswordUtils;
import com.gic.enterprise.utils.UserDetail;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.redis.data.util.RedisUtil;
import com.gic.store.utils.valid.ValidUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author guojx
......@@ -52,6 +48,10 @@ public class UserApiServiceImpl implements UserApiService {
private ResourceService resourceService;
@Autowired
private RoleService roleService;
@Autowired
private AccountGroupRelService accountGroupRelService;
@Autowired
private AccountGroupService accountGroupService;
@Transactional(rollbackFor = Exception.class)
@Override
......@@ -79,8 +79,8 @@ public class UserApiServiceImpl implements UserApiService {
//默认是普通管理员
userDTO.setSuperAdmin(0);
}
//超级管理员不能创建多条,需要判断控制
if (userDTO.getSuperAdmin().intValue() == 1) {
//超级官员
TabSysUser adminUser = userService.getUserByEnterpriseId(userDTO.getEnterpriseId());
if (adminUser != null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已存在超级管理员,重复创建");
......@@ -102,9 +102,13 @@ public class UserApiServiceImpl implements UserApiService {
userRoleService.deleteByUserId(userId);
userResourceService.deleteByUserId(userId);
//如果账号分组有数据,则需要维护分组数据
if (StringUtils.isNotBlank(userDTO.getAccountGroupIds())) {
accountGroupRelService.deleteByUserId(userId, AccountGroupMemberTypeEnum.ADMIN.getCode());
}
ServiceResponse<Integer> response = saveRole(userId, userDTO.getEnterpriseId(), userDTO.getUserRoleIds(),
userDTO.getUserResourceIds());
userDTO.getUserResourceIds(), userDTO.getAccountGroupIds());
if (response.isSuccess()) {
return response;
} else {
......@@ -170,9 +174,13 @@ public class UserApiServiceImpl implements UserApiService {
userRoleService.deleteByUserId(userDTO.getUserId());
userResourceService.deleteByUserId(userDTO.getUserId());
//如果账号分组有数据,则需要维护分组数据
if (StringUtils.isNotBlank(userDTO.getAccountGroupIds())) {
accountGroupRelService.deleteByUserId(userDTO.getUserId(), AccountGroupMemberTypeEnum.ADMIN.getCode());
}
ServiceResponse response = saveRole(userDTO.getUserId(), userDTO.getEnterpriseId(), userDTO.getUserRoleIds(),
userDTO.getUserResourceIds());
userDTO.getUserResourceIds(), userDTO.getAccountGroupIds());
if (response.isSuccess()) {
return response;
} else {
......@@ -218,7 +226,6 @@ public class UserApiServiceImpl implements UserApiService {
for (UserRoleDTO userRoleDTO : userRoleDTOList) {
userRoleStr.append(userRoleDTO.getRoleId()).append(",");
}
String userRoleResult = userRoleStr.toString();
if (StringUtils.isBlank(userRoleResult)) {
result.setUserRoleIds("");
......@@ -237,6 +244,20 @@ public class UserApiServiceImpl implements UserApiService {
} else {
result.setUserResourceIds(userResourceResult.substring(0, userResourceResult.length() - 1));
}
//账号分组
List<TabSysAccountGroupRel> tabSysAccountGroupRelList = accountGroupRelService.listByUserId(userId, AccountGroupMemberTypeEnum.ADMIN.getCode());
StringBuilder accountGroupIdStr = new StringBuilder();
if (CollectionUtils.isNotEmpty(tabSysAccountGroupRelList)) {
for (TabSysAccountGroupRel accountGroupRel : tabSysAccountGroupRelList) {
accountGroupIdStr.append(accountGroupRel.getAccountGroupId()).append(",");
}
}
String accountGroupIdResult = accountGroupIdStr.toString();
if (StringUtils.isBlank(accountGroupIdResult)) {
result.setAccountGroupIds("");
} else {
result.setAccountGroupIds(accountGroupIdResult.substring(0, accountGroupIdResult.length() - 1));
}
return ServiceResponse.success(result);
}
......@@ -250,6 +271,8 @@ public class UserApiServiceImpl implements UserApiService {
userRoleService.deleteByUserId(userId);
//删除资源关联
userResourceService.deleteByUserId(userId);
//删除账号分组关联
accountGroupRelService.deleteByUserId(userId, AccountGroupMemberTypeEnum.ADMIN.getCode());
userService.delete(userId);
return ServiceResponse.success();
}
......@@ -326,6 +349,20 @@ public class UserApiServiceImpl implements UserApiService {
return ServiceResponse.success((UserDetail) cache);
}
@Override
public ServiceResponse<Void> removeAccountGroup(Integer accountGroupId, Integer userId, Integer type) {
TabSysUser tabUser = userService.getUserById(userId);
if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误,无此数据");
}
TabSysAccountGroup tabSysAccountGroup = accountGroupService.getById(accountGroupId);
if (tabSysAccountGroup == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组ID输入有误,无此数据");
}
accountGroupRelService.deleteByAccountGroupIdAndUserId(userId, accountGroupId, type);
return ServiceResponse.success();
}
/**
* 保存关联数据,角色关联、资源关联
* @Title: saveRole

......@@ -338,9 +375,10 @@ public class UserApiServiceImpl implements UserApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>


 */
private ServiceResponse<Integer> saveRole(Integer userId, Integer enterpriseId, String userRoleIds,
String userResourceIds) {
String userResourceIds, String accountGroupIds) {
String[] userRoleIdArr;
String[] userResourceIdArr;
String[] accountGroupIdArr;
ServiceResponse<String[]> userRoleValid = ValidSplitUtils.validStr(userRoleIds);
if (userRoleValid.isSuccess()) {
userRoleIdArr = userRoleValid.getResult();
......@@ -385,6 +423,34 @@ public class UserApiServiceImpl implements UserApiService {
return result;
}
}
//账号分组用户关联数据维护
if (StringUtils.isNotBlank(accountGroupIds)) {
ServiceResponse<String[]> accountGroupIdValid = ValidSplitUtils.validStr(userResourceIds);
if (accountGroupIdValid.isSuccess()) {
accountGroupIdArr = accountGroupIdValid.getResult();
} else {
return ServiceResponse.failure(accountGroupIdValid.getCode(), accountGroupIdValid.getMessage());
}
List<AccountGroupRelDTO> accountGroupRelDTOList = new ArrayList<>();
Date now = new Date();
for (String accountGroup : accountGroupIdArr) {
int accountGroupId = Integer.parseInt(accountGroup);
TabSysAccountGroup tabSysAccountGroup = accountGroupService.getById(accountGroupId);
if (tabSysAccountGroup == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组有误,无此数据");
}
AccountGroupRelDTO accountGroupRelDTO = new AccountGroupRelDTO();
accountGroupRelDTO.setType(AccountGroupMemberTypeEnum.ADMIN.getCode());
accountGroupRelDTO.setUserId(userId);
accountGroupRelDTO.setAccountGroupId(accountGroupId);
accountGroupRelDTO.setCreateTime(now);
accountGroupRelDTO.setUpdateTime(now);
accountGroupRelDTO.setEnterpriseId(enterpriseId);
accountGroupRelDTO.setStatus(1);
accountGroupRelDTOList.add(accountGroupRelDTO);
}
accountGroupRelService.insertFetch(accountGroupRelDTOList);
}
return ServiceResponse.success(userId);
}
......
<?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.gic.auth.dao.mapper.TabSysAccountGroupRelMapper">
<resultMap id="BaseResultMap" type="com.gic.auth.entity.TabSysAccountGroupRel">
<id column="account_group_rel_id" jdbcType="INTEGER" property="accountGroupRelId" />
<result column="account_group_id" jdbcType="INTEGER" property="accountGroupId" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
account_group_rel_id, account_group_id, user_id, enterprise_id, status, type, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_account_group_rel
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_sys_account_group_rel
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.auth.entity.TabSysAccountGroupRel">
insert into tab_sys_account_group_rel (account_group_rel_id, account_group_id,
user_id, enterprise_id, status,
type, create_time, update_time
)
values (#{accountGroupRelId,jdbcType=INTEGER}, #{accountGroupId,jdbcType=INTEGER},
#{userId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.auth.entity.TabSysAccountGroupRel">
insert into tab_sys_account_group_rel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="accountGroupRelId != null">
account_group_rel_id,
</if>
<if test="accountGroupId != null">
account_group_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="status != null">
status,
</if>
<if test="type != null">
type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="accountGroupRelId != null">
#{accountGroupRelId,jdbcType=INTEGER},
</if>
<if test="accountGroupId != null">
#{accountGroupId,jdbcType=INTEGER},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.auth.entity.TabSysAccountGroupRel">
update tab_sys_account_group_rel
<set>
<if test="accountGroupId != null">
account_group_id = #{accountGroupId,jdbcType=INTEGER},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="type != null">
type = #{type,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.auth.entity.TabSysAccountGroupRel">
update tab_sys_account_group_rel
set account_group_id = #{accountGroupId,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
type = #{type,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where account_group_rel_id = #{accountGroupRelId,jdbcType=INTEGER}
</update>
<update id="deleteByAccountGroupId">
update tab_sys_account_group_rel
set status = 0
where status = 1
and account_group_id = #{accountGroupId}
</update>
<insert id="insertForeach" parameterType="java.util.List">
insert into tab_sys_account_group_rel (account_group_rel_id, account_group_id,
user_id, enterprise_id, status,
type, create_time, update_time
)
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.accountGroupRelId},
#{item.accountGroupId},
#{item.userId},
#{item.enterpriseId},
#{item.status},
#{item.type},
#{item.createTime},
#{item.updateTime}
)
</foreach>
</insert>
<update id="deleteByUserId">
update tab_sys_account_group_rel
set status = 0
where status = 1
and user_id = #{userId}
and type = #{type}
</update>
<select id="listByUserId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_account_group_rel
where user_id = #{userId}
and status = 1
and type = #{type}
</select>
<update id="deleteByAccountGroupIdAndUserId">
update tab_sys_account_group_rel
set status = 0
where status = 1
and user_id = #{userId}
and account_group_id = #{accountGroupId}
and type = #{type}
</update>
</mapper>
\ No newline at end of file
......@@ -87,4 +87,19 @@ public class UserController {
return ResultControllerUtils.commonResult(userApiService.listUser(params));
}
/**
* 逻辑删除用户对应分组数据
* @Title: removeUserAccountGroup

* @Description:

 * @author guojuxing
* @param type
* @param accountGroupId
* @param userId

* @return com.gic.commons.webapi.reponse.RestResponse


 */
@RequestMapping("/remove-user-account-group")
public RestResponse removeUserAccountGroup(Integer type, Integer accountGroupId, Integer userId) {
return ResultControllerUtils.commonResult(userApiService.removeAccountGroup(accountGroupId, userId, type));
}
}
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