Commit d2a9ca2d by guojuxing

账号分组接口:添加日志操作

parent ab05befc
......@@ -87,4 +87,6 @@ public interface TabSysAccountGroupMapper {
* @return java.util.List<com.gic.auth.entity.TabSysAccountGroup>


 */
List<TabSysAccountGroup> listAccountGroupByEnterpriseId(@Param("enterpriseId") Integer enterpriseId);
List<TabSysAccountGroup> listByIdList(@Param("list") List<Integer> accountGroupIdList);
}
\ No newline at end of file
......@@ -66,6 +66,8 @@ public interface AccountGroupService {
* @return com.gic.auth.entity.TabSysAccountGroup


 */
TabSysAccountGroup getById(Integer accountGroupId);
List<TabSysAccountGroup> listByIdList(List<Integer> accountGroupIdList);
/**
* 查询列表
* @Title: listAccountGroupByEnterpriseId

......
......@@ -54,6 +54,11 @@ public class AccountGroupServiceImpl implements AccountGroupService{
}
@Override
public List<TabSysAccountGroup> listByIdList(List<Integer> accountGroupIdList) {
return null;
}
@Override
public List<TabSysAccountGroup> listAccountGroupByEnterpriseId(Integer enterpriseId) {
return tabSysAccountGroupMapper.listAccountGroupByEnterpriseId(enterpriseId);
}
......
......@@ -2,6 +2,7 @@ package com.gic.auth.service.outer.impl;
import java.util.*;
import com.gic.auth.constant.SignConstants;
import com.gic.auth.dto.AccountGroupListDTO;
import com.gic.auth.dto.AccountGroupRelDTO;
import com.gic.auth.entity.TabSysCollaborator;
......@@ -110,7 +111,7 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService {
@Transactional(rollbackFor = Exception.class)
@Override
public ServiceResponse<Void> deleteByAccountGroupId(Integer accountGroupId) {
public ServiceResponse<AccountGroupDTO> deleteByAccountGroupId(Integer accountGroupId) {
TabSysAccountGroup record = accountGroupService.getById(accountGroupId);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组id有误,查无数据");
......@@ -119,17 +120,17 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService {
accountGroupService.updateStatusByAccountGroupId(accountGroupId);
//删除组员分组关系数据
accountGroupRelService.deleteByAccountGroupId(accountGroupId);
return ServiceResponse.success();
return ServiceResponse.success(EntityUtil.changeEntityNew(AccountGroupDTO.class, record));
}
@Override
public ServiceResponse<Void> sort(Integer accountGroupId, Integer sort) {
public ServiceResponse<AccountGroupDTO> sort(Integer accountGroupId, Integer sort) {
TabSysAccountGroup record = accountGroupService.getById(accountGroupId);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "账号分组id有误,查无数据");
}
accountGroupService.setSort(record, sort);
return ServiceResponse.success();
return ServiceResponse.success(EntityUtil.changeEntityNew(AccountGroupDTO.class, record));
}
@Override
......@@ -178,12 +179,13 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService {
@Transactional(rollbackFor = Exception.class)
@Override
public ServiceResponse<Void> saveAccountGroupRelFetch(List<AccountGroupMemberDTO> list) {
public ServiceResponse<String> saveAccountGroupRelFetch(List<AccountGroupMemberDTO> list) {
if (CollectionUtils.isNotEmpty(list)) {
//逻辑删除之前的数据,先删后增
//accountGroupRelService.deleteByAccountGroupId(list.get(0).getAccountGroupId());
//暂时不删除,因为是批量新增部分,而不是全部,所以不需要删除之前的数据
List<AccountGroupRelDTO> result = new ArrayList<>(list.size());
StringBuilder operationObject = new StringBuilder();
Date now = new Date();
for (AccountGroupMemberDTO dto : list) {
AccountGroupRelDTO temp = new AccountGroupRelDTO();
......@@ -201,22 +203,31 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService {
temp.setType(dto.getType());
temp.setEnterpriseId(dto.getEnterpriseId());
result.add(temp);
operationObject.append(dto.getMemberName()).append(SignConstants.COMMA);
}
accountGroupRelService.insertFetch(result);
TabSysAccountGroup accountGroup = accountGroupService.getById(list.get(0).getAccountGroupId());
if (accountGroup != null) {
operationObject.append("-分组到-").append(accountGroup.getAccountGroupName());
}
return ServiceResponse.success(operationObject.toString());
}
return ServiceResponse.success();
return ServiceResponse.success("无数据");
}
@Transactional(rollbackFor = Exception.class)
@Override
public ServiceResponse<Void> groupingOfUser(List<Integer> userIdList, List<Integer> accountGroupId,
public ServiceResponse<String> groupingOfUser(List<Integer> userIdList, List<Integer> accountGroupId,
Integer enterpriseId) {
return grouping(userIdList, accountGroupId, enterpriseId, AccountGroupMemberTypeEnum.ADMIN.getCode());
}
@Transactional(rollbackFor = Exception.class)
@Override
public ServiceResponse<Void> groupingOfCollaborator(List<Integer> collaboratorIdList, List<Integer> accountGroupId,
public ServiceResponse<String> groupingOfCollaborator(List<Integer> collaboratorIdList, List<Integer> accountGroupId,
Integer enterpriseId) {
return grouping(collaboratorIdList, accountGroupId, enterpriseId,
AccountGroupMemberTypeEnum.COLLABORATOR.getCode());
......@@ -307,7 +318,7 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService {
return result;
}
private ServiceResponse<Void> grouping(List<Integer> userIdList, List<Integer> accountGroupId, Integer enterpriseId,
private ServiceResponse<String> grouping(List<Integer> userIdList, List<Integer> accountGroupId, Integer enterpriseId,
int type) {
//先删除
accountGroupRelService.deleteByUserId(userIdList, type);
......@@ -327,6 +338,21 @@ public class AccountGroupApiServiceImpl implements AccountGroupApiService {
}
accountGroupRelService.insertFetch(result);
}
return ServiceResponse.success();
//获取日志操作对象内容
List<TabSysUser> userList = userService.listUserByIdList(userIdList);
StringBuilder sb = new StringBuilder();
if (CollectionUtils.isNotEmpty(userIdList)) {
for (TabSysUser user : userList) {
sb.append(user.getUserName()).append(SignConstants.COMMA);
}
sb.append("-分组到-");
List<TabSysAccountGroup> groupList = accountGroupService.listByIdList(accountGroupId);
if (CollectionUtils.isNotEmpty(groupList)) {
for (TabSysAccountGroup group : groupList) {
sb.append(group.getAccountGroupName()).append(SignConstants.COMMA);
}
}
}
return ServiceResponse.success(sb.toString());
}
}
......@@ -141,4 +141,16 @@
and enterprise_id = #{enterpriseId}
order by sort
</select>
<select id="listByIdList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
from tab_sys_account_group
where status = 1
<if test="list != null and list.size() > 0">
and account_group_id in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -57,12 +57,14 @@ public class AccountGroupController {
@RequestMapping("/save")
public RestResponse saveAccountGroup(AccountGroupDTO dto) {
dto.setEnterpriseId(UserDetailUtils.getUserDetail().getEnterpriseId());
return ResultControllerUtils.commonResult(accountGroupApiService.save(dto));
return ResultControllerUtils.operationResult(accountGroupApiService.save(dto),
ResultControllerUtils.LOG_NEW + "账号分组", dto.getAccountGroupName());
}
@RequestMapping("/edit")
public RestResponse editAccountGroup(AccountGroupDTO dto) {
return ResultControllerUtils.commonResult(accountGroupApiService.update(dto));
return ResultControllerUtils.operationResult(accountGroupApiService.update(dto),
ResultControllerUtils.LOG_EDIT + "账号分组", dto.getAccountGroupName());
}
@RequestMapping("/list")
......@@ -81,12 +83,17 @@ public class AccountGroupController {
@RequestMapping("/delete")
public RestResponse deleteAccountGroup(Integer accountGroupId) {
return ResultControllerUtils.commonResult(accountGroupApiService.deleteByAccountGroupId(accountGroupId));
ServiceResponse<AccountGroupDTO> result = accountGroupApiService.deleteByAccountGroupId(accountGroupId);
String operationObject = result.isSuccess() ? result.getResult().getAccountGroupName() : null;
return ResultControllerUtils.operationResult(result, ResultControllerUtils.LOG_DELETE + "账号分组",
operationObject);
}
@RequestMapping("/sort")
public RestResponse sortAccountGroup(Integer accountGroupId, Integer sort) {
return ResultControllerUtils.commonResult(accountGroupApiService.sort(accountGroupId, sort));
ServiceResponse<AccountGroupDTO> result = accountGroupApiService.sort(accountGroupId, sort);
String operationObject = result.isSuccess() ? result.getResult().getAccountGroupName() : null;
return ResultControllerUtils.operationResult(result, ResultControllerUtils.LOG_SORT + "账号分组", operationObject);
}
/**
......@@ -150,11 +157,15 @@ public class AccountGroupController {
}
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
if (type.intValue() == AccountGroupMemberTypeEnum.ADMIN.getCode()) {
return ResultControllerUtils
.commonResult(accountGroupApiService.groupingOfUser(userIdList, accountGroupIdList, enterpriseId));
ServiceResponse<String> result = accountGroupApiService.groupingOfUser(userIdList, accountGroupIdList,
enterpriseId);
String operationObject = result.isSuccess() ? result.getResult() : null;
return ResultControllerUtils.operationResult(result, "账号分组批量分组组员", operationObject);
} else if (type.intValue() == AccountGroupMemberTypeEnum.COLLABORATOR.getCode()) {
return ResultControllerUtils.commonResult(
accountGroupApiService.groupingOfCollaborator(userIdList, accountGroupIdList, enterpriseId));
ServiceResponse<String> result = accountGroupApiService.groupingOfCollaborator(userIdList,
accountGroupIdList, enterpriseId);
String operationObject = result.isSuccess() ? result.getResult() : null;
return ResultControllerUtils.operationResult(result, "账号分组批量分组组员", operationObject);
}
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "组员类型错误");
}
......@@ -176,7 +187,8 @@ public class AccountGroupController {
temp.setEnterpriseId(enterpriseId);
}
}
return ResultControllerUtils
.commonResult(accountGroupApiService.saveAccountGroupRelFetch(list));
ServiceResponse<String> result = accountGroupApiService.saveAccountGroupRelFetch(list);
String operationObject = result.isSuccess() ? result.getResult() : null;
return ResultControllerUtils.operationResult(result, "添加组员", operationObject);
}
}
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