| | |
| | | |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | 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.mapper.UserGroupMapper; |
| | | import com.moral.api.service.GroupService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.utils.OperationLogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.ConvertUtils; |
| | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.context.request.RequestContextHolder; |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public Map<String, Object> addGroup(Group group, String token) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | | Integer orgId = (int) currentUserInfo.get("organizationId"); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization"); |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("group_name", group.getGroupName()) |
| | | .eq("organization_id", orgId) |
| | |
| | | } |
| | | group.setOrganizationId(orgId); |
| | | groupMapper.insert(group); |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String content = "添加了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return result; |
| | | } |
| | | |
| | |
| | | UpdateWrapper<UserGroup> deleteUserGroupWrapper = new UpdateWrapper<>(); |
| | | deleteUserGroupWrapper.set("is_delete", Constants.DELETE).eq("group_id", group.getId()); |
| | | userGroupMapper.update(null, deleteUserGroupWrapper); |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String content = "删除了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> updateGroup(Group group, String token) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(token); |
| | | Object organizationId = currentUserInfo.get("organizationId"); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization"); |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.ne("id", group.getId()) |
| | | .eq("group_name", group.getGroupName()) |
| | | .eq("is_delete", Constants.NOT_DELETE) |
| | | .eq("organization_id", organizationId); |
| | | .eq("organization_id", orgId); |
| | | if (groupMapper.selectOne(queryWrapper) != null) { |
| | | result.put("code", ResponseCodeEnum.GROUP_EXIST.getCode()); |
| | | result.put("msg", ResponseCodeEnum.GROUP_EXIST.getMsg()); |
| | | return result; |
| | | } |
| | | group.setOrganizationId((int) organizationId); |
| | | group.setOrganizationId(orgId); |
| | | groupMapper.updateById(group); |
| | | //日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | String content = "修改了组:" + group.getGroupName(); |
| | | OperationLogUtils.insertLog(request, content); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Page<Group> selectGroups(Map<String, Object> parameters) { |
| | | Map<String, Object> currentUserInfo = (Map<String, Object>) TokenUtils.getUserInfoByToken(parameters.get("token").toString()); |
| | | Object organizationId = currentUserInfo.get("organizationId"); |
| | | Map<String, Object> orgInfo = (Map<String, Object>) currentUserInfo.get("organization"); |
| | | Integer orgId = (Integer) orgInfo.get("id"); |
| | | QueryWrapper<Group> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("organization_id", organizationId) |
| | | queryWrapper.eq("organization_id", orgId) |
| | | .eq("is_delete", Constants.NOT_DELETE); |
| | | Object order = parameters.get("order"); |
| | | Object orderType = parameters.get("orderType"); |