Commit 6953f494 by guojuxing

管理员数据转移

parent 6d00b384
......@@ -106,6 +106,14 @@ public interface TabUserDataShowMapper {
@Param("userDataSceneType") Integer userDataSceneType);
/**
* 统计业务方
* @param userDataBusinessId
* @param userDataSceneType
* @return
*/
int count(@Param("userDataBusinessId") String userDataBusinessId, @Param("userDataSceneType") Integer userDataSceneType);
/**
* 分页查询
* @param dataType
* @param userId
......
......@@ -19,6 +19,14 @@ public interface UserDataShowService {
void saveUserData(UserDataShowSaveDTO data);
/**
* 同一个业务方只能有一个businessId
* @param userDataBusinessId
* @param userDataSceneType
* @return
*/
boolean isRepeat(String userDataBusinessId, Integer userDataSceneType);
/**
* 编辑名称
* @param userDataBusinessId
* @param userDataBusinessName
......
......@@ -36,6 +36,15 @@ public class UserDataShowServiceImpl implements UserDataShowService{
}
@Override
public boolean isRepeat(String userDataBusinessId, Integer userDataSceneType) {
int count = tabUserDataShowMapper.count(userDataBusinessId, userDataSceneType);
if (count > 0) {
return true;
}
return false;
}
@Override
public void editUserDataBusinessName(String userDataBusinessId, String userDataBusinessName, Integer userDataSceneType) {
tabUserDataShowMapper.editUserDataBusinessName(userDataBusinessId, userDataBusinessName, userDataSceneType);
}
......
......@@ -68,6 +68,10 @@ public class UserResourceServiceImpl implements UserResourceService {
@Override
public List<Integer> listUserId(List<Integer> resourceIdList, Integer enterpriseId) {
return tabSysUserResourceMapper.listUserId(resourceIdList, enterpriseId);
List<Integer> list = tabSysUserResourceMapper.listUserId(resourceIdList, enterpriseId);
if (CollectionUtils.isNotEmpty(list)) {
return list;
}
return Collections.emptyList();
}
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
*
......@@ -54,6 +55,10 @@ public class UserRoleServiceImpl implements UserRoleService{
@Override
public List<Integer> listUserId(List<Integer> roleIdList, Integer enterpriseId) {
return tabSysUserRoleMapper.listUserId(roleIdList, enterpriseId);
List<Integer> list = tabSysUserRoleMapper.listUserId(roleIdList, enterpriseId);
if (CollectionUtils.isNotEmpty(list)) {
return list;
}
return Collections.emptyList();
}
}
......@@ -605,18 +605,7 @@ public class UserApiServiceImpl implements UserApiService {
if (tabUser == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "用户ID输入有误,无此数据");
}
TabSysUser admin = userService.getUserByEnterpriseId(tabUser.getEnterpriseId());
List<Integer> transferUserList = queryCouldTransferUserList(userId, tabUser.getEnterpriseId());
if (CollectionUtils.isEmpty(transferUserList)) {
//只有超管
Page<UserDTO> tempPage = new Page<>();
List<UserDTO> tempList = new ArrayList<>(1);
tempList.add(EntityUtil.changeEntityNew(UserDTO.class, admin));
tempPage.setResult(tempList);
tempPage.setTotalCount(1);
return ServiceResponse.success(tempPage);
}
UserListQO params = new UserListQO();
params.setUserIdList(transferUserList);
......@@ -626,11 +615,6 @@ public class UserApiServiceImpl implements UserApiService {
com.github.pagehelper.Page page = userService.pageUserForTransfer(params);
Page<UserDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page);
//第一页加上超管数据
if (pageNum == null || pageNum == 1) {
List<UserDTO> temp = resultPage.getResult();
temp.add(0, EntityUtil.changeEntityNew(UserDTO.class, admin));
}
return ServiceResponse.success(resultPage);
}
......@@ -671,6 +655,7 @@ public class UserApiServiceImpl implements UserApiService {
* @return
*/
private List<Integer> queryCouldTransferUserList(Integer userId, Integer enterpriseId) {
TabSysUser admin = userService.getUserByEnterpriseId(enterpriseId);
//前置条件 权限集和资源组大于等于的管理员(包括超管)
//角色集
List<UserRoleDTO> userRoleDTOList = userRoleService.listUserRoleByUserId(userId);
......@@ -691,6 +676,11 @@ public class UserApiServiceImpl implements UserApiService {
//取交集,因为是并且关系
userIdListByRole.retainAll(userIdListByResource);
//超管ID
userIdListByRole.add(admin.getUserId());
//删除转移的用户
userIdListByRole.remove(userId);
return userIdListByRole;
}
......
......@@ -4,6 +4,7 @@ import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDataShowSaveDTO;
import com.gic.auth.service.UserDataShowApiService;
import com.gic.auth.service.UserDataShowService;
import com.gic.enterprise.error.ErrorCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
......@@ -19,6 +20,9 @@ public class UserDataShowApiServiceImpl implements UserDataShowApiService{
private UserDataShowService userDataShowService;
@Override
public ServiceResponse<Void> saveUserData(UserDataShowSaveDTO data) {
if (userDataShowService.isRepeat(data.getUserDataBusinessId(), data.getUserDataSceneType())) {
return ServiceResponse.failure(ErrorCode.DATA_EXISTS.getCode(), "业务ID已经存在");
}
userDataShowService.saveUserData(data);
return ServiceResponse.success();
}
......
......@@ -17,7 +17,7 @@ import com.gic.auth.service.UserMoveService;
* @author guojuxing

* @date 2021/1/7 2:50 PM

*/
@Service("UserMoveApiService")
@Service("userMoveApiService")
public class UserMoveApiServiceImpl implements UserMoveApiService{
@Autowired
private UserMoveService userMoveService;
......
......@@ -359,7 +359,7 @@
</if>
GROUP BY user_id
order by create_time desc
order by super_admin desc
</select>
......
......@@ -153,7 +153,7 @@
</select>
<select id="listUserId" resultType="int">
select user_id from tab_sys_user_resource where ${@com.gic.auth.constant.DeleteFlagConstants@NORMAL_STATUS}
select user_id from tab_sys_user_resource where delete_flag = ${@com.gic.auth.constant.DeleteFlagConstants@NORMAL_STATUS}
and enterprise_id = #{enterpriseId}
and resource_id in
<foreach collection="resourceIdList" index="index" item="item" open="(" separator="," close=")">
......
......@@ -171,6 +171,14 @@
and user_data_scene_type = #{userDataSceneType}
</update>
<select id="count" resultType="int">
select count(1) from tab_user_data_show
where delete_flag = ${@com.gic.auth.constant.DeleteFlagConstants@NORMAL_STATUS}
and user_data_scene_type = #{userDataSceneType}
and user_data_business_id = #{userDataBusinessId}
</select>
<select id="page" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_user_data_show
......
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