package com.tbs.graduateInfoMana.admin.sys.supertube.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tbs.graduateInfoMana.admin.sys.supertube.dto.OrganizationAuthDTO;
import com.tbs.graduateInfoMana.admin.sys.supertube.dto.OrganizationDTO;
import com.tbs.graduateInfoMana.admin.sys.supertube.execl.OrganInfoExcel;
import com.tbs.graduateInfoMana.admin.sys.supertube.execl.OrganMemberInfoExcel;
import com.tbs.graduateInfoMana.admin.sys.supertube.mapper.OrganizationListMapper;
import com.tbs.graduateInfoMana.admin.sys.supertube.mapper.OrganizationMapper;
import com.tbs.graduateInfoMana.admin.sys.supertube.mapper.OrganizationMemberMapper;
import com.tbs.graduateInfoMana.admin.sys.supertube.model.Organization;
import com.tbs.graduateInfoMana.admin.sys.supertube.model.OrganizationList;
import com.tbs.graduateInfoMana.admin.sys.supertube.model.OrganizationMember;
import com.tbs.graduateInfoMana.admin.sys.supertube.query.OrganizationQuery;
import com.tbs.graduateInfoMana.admin.sys.supertube.service.ManaOrganizationListService;
import com.tbs.graduateInfoMana.admin.sys.supertube.service.ManaOrganizationMemberService;
import com.tbs.graduateInfoMana.admin.sys.supertube.service.ManaOrganizationService;
import com.tbs.graduateInfoMana.common.constant.RedisConstant;
import com.tbs.graduateInfoMana.common.enums.OrganizationLevEnum;
import com.tbs.graduateInfoMana.common.enums.OrganizationMemberTypeEnum;
import com.tbs.graduateInfoMana.common.enums.StatusCodeEnum;
import com.tbs.graduateInfoMana.common.enums.YesOrNoEnum;
import com.tbs.graduateInfoMana.common.exception.BusinessException;
import com.tbs.graduateInfoMana.common.model.SysUser;
import com.tbs.graduateInfoMana.common.server.RedisService;
import com.tbs.graduateInfoMana.common.server.impl.BaseServiceImpl;
import com.tbs.graduateInfoMana.common.user.service.SysUserService;
import com.tbs.graduateInfoMana.common.utrl.*;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@Slf4j
@Service
public class ManaOrganizationServiceImpl extends BaseServiceImpl<OrganizationMapper, Organization> implements ManaOrganizationService {
@Resource
private OrganizationListMapper organizationListMapper;
@Resource
private ManaOrganizationListService organizationListService;
@Resource
private OrganizationMemberMapper organizationMemberMapper;
@Resource
private ManaOrganizationMemberService organizationMemberService;
@Resource
private RedisService redisService;
@Override
@Transactional(rollbackFor = {Exception.class})
public Result saveOrUpdateOrgan(SysUser sysUser, OrganizationDTO organizationDTO) {
if (organizationDTO == null || organizationDTO.getOrgaLev() == null ||
organizationDTO.getOrgaCode() == null || organizationDTO.getOrgaName() == null) {
return Result.error("参数不能为空!!!!!");
}
if (organizationDTO.getOrgaLev() == OrganizationLevEnum.SCHOOL.getCode()) {
if (organizationDTO.getRegionCode() == null || organizationDTO.getAddress() == null) {
return Result.error("参数不能为空!!!!!");
}
}
if (organizationDTO.getOrgaLev() > OrganizationLevEnum.MAJOR.getCode() || organizationDTO.getOrgaLev() < 0) {
return Result.error("参数错误!");
}
//判断添加等级,6级需要超管才允许添加
if (organizationDTO.getOrgaLev() <= OrganizationLevEnum.SCHOOL.getCode()) {
//判断是否为超管
if (!this.isSupertube(sysUser)) {
return Result.error("权限不足!");
}
} else {
if (organizationDTO.getParentOrgaId() == null) {
return Result.error("参数不能为空!!!!!");
}
Organization parentOrgan = baseMapper.selectById(organizationDTO.getParentOrgaId());
if (parentOrgan.getOrgaLev() + 1 != organizationDTO.getOrgaLev()) {
return Result.error("架构等级错误!!!!!");
}
//判断是否为管理员
if (!this.checkOrganAuth(sysUser, organizationDTO.getParentOrgaId())) {
return Result.error("权限不足!");
}
}
if (!ValidatorUtil.isBetweenSize(organizationDTO.getOrgaName(), 1, 20)) {
return Result.error("架构名称不能超过20个字符!");
}
//判断编码是否唯一
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Organization::getOrgaCode, organizationDTO.getOrgaCode());
Organization organCode = baseMapper.selectOne(queryWrapper);
Organization organization = new Organization();
BeanUtils.copyProperties(organizationDTO, organization);
//校级添加
if (organizationDTO.getOrgaLev() == OrganizationLevEnum.SCHOOL.getCode()) {
organization.setParentOrgaId(0L);
organization.setIndex1(100);
}
OrganizationList organizationList = new OrganizationList();
organizationList.setOrgaName(organizationDTO.getOrgaName());
if (this.autoSetOperator(sysUser, organization) ) {
if (organCode != null){
return Result.error("架构编码已存在!");
}
organizationList.setOrgaId(organization.getId());
this.autoSetOperator(sysUser, organizationList);
int i = organizationListMapper.insert(organizationList);
if (i <= 0) {
throw new BusinessException("添加失败!");
}
int in = baseMapper.insert(organization);
if (in <= 0) {
throw new BusinessException("添加失败!");
}
//添加一个创建角色、
OrganizationMember member = new OrganizationMember();
member.setOrgaId(organization.getId());
member.setMemberType(OrganizationMemberTypeEnum.CREATE.getCode());
member.setUserId(sysUser.getId());
this.autoSetOperator(sysUser, member);
i = organizationMemberMapper.insert(member);
if (i <= 0) {
throw new BusinessException("添加失败!");
}
redisService.delLike(RedisConstant.Organ);
return Result.success("添加成功!!!!!!");
}
if (organCode != null && !organCode.getId().equals(organizationDTO.getId())) {
return Result.error("架构编码已存在!");
}
//修改逻辑
organizationList.setOrgaId(organization.getId());
LambdaQueryWrapper<OrganizationList> listQuery = new LambdaQueryWrapper<>();
listQuery.eq(OrganizationList::getOrgaId, organization.getId());
Integer organInt = organizationListMapper.update(organizationList, listQuery);
if (organInt <= 0) {
throw new BusinessException("更新失败!");
}
int i1 = baseMapper.updateById(organization);
if (i1 <= 0) {
throw new BusinessException("更新失败!");
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本资源提供了一套基于Spring Boot的高校毕业生就业信息管理系统设计源码,包含612个文件,其中包括194个Class字节码文件,189个Java源代码文件,178个XML配置文件,12个FreeMarker模板文件,10个PNG图片文件,6个YAML配置文件,以及5个IntelliJ IDEA项目文件。此外,还包括4个JAR打包文件,4个Properties配置文件和4个LST列表文件。这些文件详细展示了如何使用Spring Boot构建高校毕业生就业信息管理系统,非常适合用于学习和参考Java项目的开发。
资源推荐
资源详情
资源评论
收起资源包目录
基于Spring Boot的高校毕业生就业信息管理系统设计源码 (617个子文件)
ManaOrganizationServiceImpl.class 28KB
ManaExamineServiceImpl.class 23KB
ManaClassServiceImpl.class 22KB
EmploymentInfoServiceImpl.class 22KB
ManaOrganizationMemberServiceImpl.class 22KB
SysUserServiceImpl.class 22KB
ManaEnterprisePositionServiceImpl.class 17KB
ManaEnterpriseServiceImpl.class 17KB
ManaClassTeacherServiceImpl.class 16KB
BaseServiceImpl.class 15KB
ManaClassStudentServiceImpl.class 14KB
SysNotificationServiceImpl.class 14KB
SysUser.class 12KB
SysUserDTO.class 11KB
StudentClassDTO.class 11KB
ClassDTO.class 11KB
ManaPersonalServiceImpl.class 10KB
RedisServiceImpl.class 10KB
EmploymentInfo.class 10KB
OrganizationDTO.class 9KB
LoginServiceImpl.class 8KB
UserServiceImpl.class 8KB
DataStatisticsServiceImpl.class 8KB
App.class 8KB
Enterprise.class 8KB
ClassManager.class 8KB
StudentClass.class 8KB
Organization.class 7KB
ClassTeacherDTO.class 7KB
SysNotification.class 7KB
ExcelUtil.class 7KB
Examine.class 7KB
EnterpriseDTO.class 6KB
EnterprisePosition.class 6KB
SysNotificationDTO.class 6KB
StudentServiceImpl.class 6KB
EmploymentInfoDTO.class 6KB
StudentClassServiceImpl.class 6KB
ClassTeacher.class 6KB
RedisConfig.class 6KB
CommonUserQuery.class 6KB
OrganizationMemberDTO.class 6KB
OrganizationMember.class 6KB
BasisRegionDTO.class 5KB
JwtTokenUtil.class 5KB
ClassStudent.class 5KB
Student.class 5KB
PersonalQuery.class 5KB
StringUtils.class 5KB
SecurityConfig.class 5KB
ManaOrganizationController.class 5KB
ManaOrganizationMemberController.class 5KB
EnterprisePositionDTO.class 5KB
LoginController.class 5KB
BaseEntity.class 5KB
OrganizationList.class 5KB
BasisRegionList.class 5KB
Result.class 5KB
ClassTeacherQuery.class 5KB
FileController.class 5KB
TokenArgumentResolver.class 5KB
ClassList.class 4KB
BasisRegionServiceImpl.class 4KB
JwtAuthenticationTokenFilter.class 4KB
ExamineDTO.class 4KB
ClassStudentQuery.class 4KB
BasisRegion.class 4KB
StudentQuery.class 4KB
OrganizationAuthDTO.class 4KB
ClassStudentDTO.class 4KB
StudentDTO.class 4KB
ManaClassController.class 4KB
UserRoleEnum.class 4KB
EmploymentInfoController.class 4KB
EmploymentInfoQuery.class 3KB
OrganMemberInfoExcel.class 3KB
LoginAppUser.class 3KB
ManaExamineController.class 3KB
OrganizationMemberQuery.class 3KB
PageResult.class 3KB
ManaEnterprisePositionController.class 3KB
SysNotificationQuery.class 3KB
LoginUserDTO.class 3KB
RedisService.class 3KB
CaptchaController.class 3KB
ClassInfoExcel.class 3KB
SysNotificationController.class 3KB
ManaEnterpriseController.class 3KB
OrganizationListDTO.class 3KB
EnterprisePositionQuery.class 3KB
OrganizationQuery.class 3KB
ManaClassStudentController.class 3KB
UserInfoEnum.class 3KB
EnterpriseQuery.class 3KB
SysRoleDTO.class 3KB
StudentClassQuery.class 3KB
GlobalExceptionHandler.class 3KB
ManaClassTeacherController.class 3KB
GetLoginInfo.class 3KB
SysRole.class 3KB
共 617 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
沐知全栈开发
- 粉丝: 5706
- 资源: 5205
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功