jinpengyong
2021-06-24 ec95e52c6f84c0a6cbdcbaecc2465b00ede6696d
screen-api/src/main/java/com/moral/api/service/impl/UserGroupServiceImpl.java
@@ -5,7 +5,6 @@
import java.util.Map;
import java.util.Objects;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.moral.api.entity.UserGroup;
import com.moral.api.mapper.GroupMapper;
@@ -20,6 +19,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -45,6 +45,9 @@
    @Autowired
    private GroupMapper groupMapper;
    @Autowired
    private OperationLogUtils operationLogUtils;
    @Override
    @Transactional
    public void allotGroups(Map<String, Object> parameters) {
@@ -59,7 +62,7 @@
        deleteWrapper.eq("user_id", userId);
        userGroupMapper.delete(deleteWrapper);
        List<String> groups = new ArrayList<>();
        if (groupIds != null && !groupIds.isEmpty()) {
        if (!ObjectUtils.isEmpty(groupIds)) {
            groupIds.forEach(groupId -> {
                groups.add(groupMapper.selectById(groupId).getGroupName());
                UserGroup userGroup = new UserGroup();
@@ -72,17 +75,7 @@
        //日志
        String account = userMapper.selectById((Integer) parameters.get("userId")).getAccount();
        String content = "给用户:" + account + "分配了组:" + groups.toString();
        OperationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE);
    }
    @Override
    public List<Integer> getGroupIds(Integer userId) {
        QueryWrapper<UserGroup> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId).eq("is_delete", Constants.NOT_DELETE);
        List<UserGroup> userGroups = userGroupMapper.selectList(queryWrapper);
        List<Integer> groupIds = new ArrayList<>();
        userGroups.forEach(userGroup -> groupIds.add(userGroup.getGroupId()));
        return groupIds;
        String content = "给用户:" + account + "分配了组:" + groups;
        operationLogUtils.insertLog(request, content, Constants.UPDATE_OPERATE_TYPE);
    }
}