|
@@ -1,14 +1,12 @@
|
|
|
package com.qmth.teachcloud.common.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.teachcloud.common.bean.dto.OrgDto;
|
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
|
import com.qmth.teachcloud.common.bean.result.SysUserResult;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicCampus;
|
|
|
import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
import com.qmth.teachcloud.common.entity.SysRole;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
@@ -18,7 +16,10 @@ import com.qmth.teachcloud.common.enums.OrgTypeEnum;
|
|
|
import com.qmth.teachcloud.common.enums.RoleTypeEnum;
|
|
|
import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
|
|
|
import com.qmth.teachcloud.common.mapper.SysOrgMapper;
|
|
|
-import com.qmth.teachcloud.common.service.*;
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
+import com.qmth.teachcloud.common.service.SysRoleService;
|
|
|
+import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
+import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -54,8 +55,8 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
@Resource
|
|
|
TeachcloudCommonService teachcloudCommonService;
|
|
|
|
|
|
- @Resource
|
|
|
- BasicCampusService basicCampusService;
|
|
|
+// @Resource
|
|
|
+// BasicCampusService basicCampusService;
|
|
|
|
|
|
@Override
|
|
|
public List<OrgDto> listOrgTree(SpecialPrivilegeEnum specialPrivilegeEnum) {
|
|
@@ -123,36 +124,36 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
org.setSchoolId(schoolId);
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
|
|
- QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(SysOrg::getSchoolId, org.getSchoolId()).eq(SysOrg::getParentId, org.getParentId()).eq(SysOrg::getCode, org.getCode());
|
|
|
- SysOrg sysOrg = this.getOne(queryWrapper);
|
|
|
+// QueryWrapper<SysOrg> queryWrapper = new QueryWrapper<>();
|
|
|
+// queryWrapper.lambda().eq(SysOrg::getSchoolId, org.getSchoolId()).eq(SysOrg::getParentId, org.getParentId()));
|
|
|
+// SysOrg sysOrg = this.getOne(queryWrapper);
|
|
|
|
|
|
if (org.getId() == null) {// 新增
|
|
|
- if (sysOrg != null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("机构代码已存在");
|
|
|
- }
|
|
|
- checkOrgTree(org);
|
|
|
+// if (sysOrg != null) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("机构代码已存在");
|
|
|
+// }
|
|
|
+// checkOrgTree(org);
|
|
|
org.insertInfo(sysUser.getId());
|
|
|
success = this.save(org);
|
|
|
} else { // 修改
|
|
|
- if (sysOrg != null && org.getId().longValue() != sysOrg.getId().longValue()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("机构代码已存在");
|
|
|
- }
|
|
|
+// if (sysOrg != null && org.getId().longValue() != sysOrg.getId().longValue()) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("机构代码已存在");
|
|
|
+// }
|
|
|
org.updateInfo(sysUser.getId());
|
|
|
success = this.updateById(org);
|
|
|
}
|
|
|
- if (Objects.nonNull(org.getCampusId())) {//更新校区
|
|
|
- BasicCampus basicCampus = basicCampusService.getById(org.getCampusId());
|
|
|
- if (Objects.nonNull(basicCampus) && Objects.nonNull(basicCampus.getPrintHouseId())
|
|
|
- && basicCampus.getPrintHouseId().longValue() != org.getId().longValue()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该校区已绑定其它印刷室");
|
|
|
- }
|
|
|
-
|
|
|
- UpdateWrapper<BasicCampus> basicCampusUpdateWrapper = new UpdateWrapper<>();
|
|
|
- basicCampusUpdateWrapper.lambda().eq(BasicCampus::getId, org.getCampusId())
|
|
|
- .set(BasicCampus::getPrintHouseId, org.getId());
|
|
|
- basicCampusService.update(basicCampusUpdateWrapper);
|
|
|
- }
|
|
|
+// if (Objects.nonNull(org.getCampusId())) {//更新校区
|
|
|
+// BasicCampus basicCampus = basicCampusService.getById(org.getCampusId());
|
|
|
+// if (Objects.nonNull(basicCampus) && Objects.nonNull(basicCampus.getPrintHouseId())
|
|
|
+// && basicCampus.getPrintHouseId().longValue() != org.getId().longValue()) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("该校区已绑定其它印刷室");
|
|
|
+// }
|
|
|
+//
|
|
|
+// UpdateWrapper<BasicCampus> basicCampusUpdateWrapper = new UpdateWrapper<>();
|
|
|
+// basicCampusUpdateWrapper.lambda().eq(BasicCampus::getId, org.getCampusId())
|
|
|
+// .set(BasicCampus::getPrintHouseId, org.getId());
|
|
|
+// basicCampusService.update(basicCampusUpdateWrapper);
|
|
|
+// }
|
|
|
} catch (Exception e) {
|
|
|
if (e instanceof DuplicateKeyException) {
|
|
|
String errorColumn = e.getCause().toString();
|
|
@@ -200,34 +201,34 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 校验各机构关系
|
|
|
- *
|
|
|
- * @param org
|
|
|
- */
|
|
|
- private void checkOrgTree(SysOrg org) {
|
|
|
- // 印刷厂不能设置子机构
|
|
|
- if (Objects.nonNull(org.getParentId())) {
|
|
|
- SysOrg parentOrg = this.getById(org.getParentId());
|
|
|
- if (Objects.nonNull(parentOrg) && OrgTypeEnum.COLLEGE.equals(parentOrg.getType())) {
|
|
|
- if (!OrgTypeEnum.FACULTY.equals(org.getType()) && !OrgTypeEnum.TEACHING_ROOM.equals(org.getType())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学院下只能设置院系或者教研室");
|
|
|
- }
|
|
|
- } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.FACULTY.equals(parentOrg.getType())) {
|
|
|
- if (!OrgTypeEnum.TEACHING_ROOM.equals(org.getType())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("院系下只能设置教研室");
|
|
|
- }
|
|
|
- } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.TEACHING_ROOM.equals(parentOrg.getType())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("教研室下不能设置子机构");
|
|
|
- } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.PRINTING_HOUSE.equals(parentOrg.getType())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("印刷厂不能设置子机构");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!OrgTypeEnum.COLLEGE.equals(org.getType()) && !OrgTypeEnum.PRINTING_HOUSE.equals(org.getType())) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("一级机构只能设置学院或者印刷厂");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 校验各机构关系
|
|
|
+// *
|
|
|
+// * @param org
|
|
|
+// */
|
|
|
+// private void checkOrgTree(SysOrg org) {
|
|
|
+// // 印刷厂不能设置子机构
|
|
|
+// if (Objects.nonNull(org.getParentId())) {
|
|
|
+// SysOrg parentOrg = this.getById(org.getParentId());
|
|
|
+// if (Objects.nonNull(parentOrg) && OrgTypeEnum.COLLEGE.equals(parentOrg.getType())) {
|
|
|
+// if (!OrgTypeEnum.FACULTY.equals(org.getType()) && !OrgTypeEnum.TEACHING_ROOM.equals(org.getType())) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("学院下只能设置院系或者教研室");
|
|
|
+// }
|
|
|
+// } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.FACULTY.equals(parentOrg.getType())) {
|
|
|
+// if (!OrgTypeEnum.TEACHING_ROOM.equals(org.getType())) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("院系下只能设置教研室");
|
|
|
+// }
|
|
|
+// } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.TEACHING_ROOM.equals(parentOrg.getType())) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("教研室下不能设置子机构");
|
|
|
+// } else if (Objects.nonNull(parentOrg) && OrgTypeEnum.PRINTING_HOUSE.equals(parentOrg.getType())) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("印刷厂不能设置子机构");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// if (!OrgTypeEnum.COLLEGE.equals(org.getType()) && !OrgTypeEnum.PRINTING_HOUSE.equals(org.getType())) {
|
|
|
+// throw ExceptionResultEnum.ERROR.exception("一级机构只能设置学院或者印刷厂");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public SysOrg findByForeignKey(Long schoolId, String collegeCode, String collegeName) {
|
|
@@ -500,12 +501,12 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
|
|
* @return 新增后的机构id
|
|
|
*/
|
|
|
private SysOrg saveOrgElement(Long parentId, String orgName, SysUser requestUser) {
|
|
|
- SysOrg checkOrg = this.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getName,orgName).eq(SysOrg::getSchoolId,requestUser.getSchoolId()));
|
|
|
- if (Objects.nonNull(checkOrg)){
|
|
|
+ SysOrg checkOrg = this.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getName, orgName).eq(SysOrg::getSchoolId, requestUser.getSchoolId()));
|
|
|
+ if (Objects.nonNull(checkOrg)) {
|
|
|
// 数据库中存在该名字的机构
|
|
|
SysOrg p1 = this.getById(checkOrg.getParentId());
|
|
|
SysOrg p2 = this.getById(parentId);
|
|
|
- if (SystemConstant.isOneNull(p1,p2)){
|
|
|
+ if (SystemConstant.isOneNull(p1, p2)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("未找到父机构");
|
|
|
}
|
|
|
throw ExceptionResultEnum.ERROR.exception("机构创建失败:机构【" + orgName + "】存在多个不同的上级机构 " +
|