更新站间数据
This commit is contained in:
parent
04eb086254
commit
36b509ff40
@ -14,10 +14,10 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = {"单位成员管理接口"})
|
||||
@Api(tags = {"组织成员管理接口"})
|
||||
@RestController
|
||||
@RequestMapping("/api/company")
|
||||
public class CompanyController {
|
||||
public class OrgController {
|
||||
|
||||
@Autowired
|
||||
private IOrgUserService iOrgUserService;
|
@ -38,7 +38,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
private ISysUserService iSysUserService;
|
||||
|
||||
@Autowired
|
||||
private OrgUserDAO departmentUserDAO;
|
||||
private OrgUserDAO orgUserDAO;
|
||||
|
||||
@Autowired
|
||||
private OrgLessonDAO orgLessonDAO;
|
||||
@ -143,7 +143,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
public boolean isCompanyUser(Long userId) {
|
||||
OrgUserExample e = new OrgUserExample();
|
||||
e.createCriteria().andUserIdEqualTo(userId);
|
||||
return departmentUserDAO.countByExample(e) > 0;
|
||||
return orgUserDAO.countByExample(e) > 0;
|
||||
}
|
||||
|
||||
//************************************部门管理**********************************************
|
||||
@ -257,7 +257,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
example.createCriteria()
|
||||
.andUserIdEqualTo(userId)
|
||||
.andOrgIdEqualTo(departId);
|
||||
List<OrgUser> ucrs = departmentUserDAO.selectByExample(example);
|
||||
List<OrgUser> ucrs = orgUserDAO.selectByExample(example);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(ucrs, "非部门" + departId + "内部用户");
|
||||
return ucrs.get(0);
|
||||
}
|
||||
@ -266,7 +266,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
public List<UserDepartRelVO> getDepartRefByUserId(Long userId) {
|
||||
OrgUserExample e = new OrgUserExample();
|
||||
e.createCriteria().andUserIdEqualTo(userId).andRoleNotEqualTo(BusinessConsts.OrgRole.Admin.name());
|
||||
List<OrgUser> departmentUserRefs = this.departmentUserDAO.selectByExample(e);
|
||||
List<OrgUser> departmentUserRefs = this.orgUserDAO.selectByExample(e);
|
||||
return UserDepartRelVO.convert2VOList(departmentUserRefs);
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StringUtils.hasText(userRel.getRole()) && !Objects.equals(userRel.getRole(),BusinessConsts.OrgRole.Student), "非部门管理员无法操作");
|
||||
var departmentUser = getDepartUseRelEntity(userDepartRelVO.getUserId(), userDepartRelVO.getDepartmentId());
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNull(departmentUser, "已存在的部门成员");
|
||||
departmentUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
orgUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
}
|
||||
|
||||
/**更新部门-职位-用户关系*/
|
||||
@ -300,13 +300,13 @@ public class OrgUserService implements IOrgUserService {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StringUtils.hasText(userRel.getRole()) && !Objects.equals(userRel.getRole(),BusinessConsts.OrgRole.Student), "非部门管理员无法操作");
|
||||
OrgUserExample example = new OrgUserExample();
|
||||
example.createCriteria().andOrgIdEqualTo(userDepartRelVO.getDepartmentId()).andUserIdEqualTo(userDepartRelVO.getUserId());
|
||||
departmentUserDAO.deleteByExample(example);
|
||||
orgUserDAO.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompanyDepartUserVO> getUserCompanyDeparts(UserVO user, Integer companyId) {
|
||||
//根据公司id和用户id查询用户企业详细信息
|
||||
return departmentUserDAO.getUserCompanyDeparts(companyId,user.getId());
|
||||
return orgUserDAO.getUserCompanyDeparts(companyId,user.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -316,7 +316,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
companyUserQueryVO.setDepartmentId(departId);
|
||||
companyUserQueryVO.setOrgRole(BusinessConsts.OrgRole.Student);
|
||||
PageHelper.startPage(companyUserQueryVO.getPageNum(), companyUserQueryVO.getPageSize());
|
||||
Page<CompanyDepartUserVO> page = (Page<CompanyDepartUserVO>) departmentUserDAO.getCompanyDepartUsers(companyUserQueryVO);
|
||||
Page<CompanyDepartUserVO> page = (Page<CompanyDepartUserVO>) orgUserDAO.getCompanyDepartUsers(companyUserQueryVO);
|
||||
return PageVO.convert(page);
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertEquals(user.getCompanyId(), companyId, "非同单位成员无法操作");
|
||||
OrgUserExample oue = new OrgUserExample();
|
||||
oue.createCriteria().andOrgIdEqualTo(companyId).andRoleEqualTo(BusinessConsts.OrgRole.Admin.name());
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(departmentUserDAO.countByExample(oue)> 0,"非本单位管理员");
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(orgUserDAO.countByExample(oue)> 0,"非本单位管理员");
|
||||
//验证是否存在并导入新的年级和班级
|
||||
var departmentExample = new OrgExample();
|
||||
departmentExample.createCriteria()
|
||||
@ -346,7 +346,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
childDepart = new DepartmentVO(importCompanyUserVO.getDepart(), parentDepart.getId(),companyId);
|
||||
createDepart(childDepart);
|
||||
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(user.getId(), childDepart.getId(), BusinessConsts.OrgRole.Teacher.name());
|
||||
departmentUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
orgUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
} else {
|
||||
parentDepart = new DepartmentVO(importParentDepart.get(0));
|
||||
departmentExample.clear();
|
||||
@ -363,7 +363,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
childDepart = new DepartmentVO(importCompanyUserVO.getDepart(), parentDepart.getId(), companyId);
|
||||
createDepart(childDepart);
|
||||
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(user.getId(), childDepart.getId(), BusinessConsts.OrgRole.Teacher.name());
|
||||
departmentUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
orgUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
}
|
||||
|
||||
//构建系统用户对象
|
||||
@ -374,11 +374,11 @@ public class OrgUserService implements IOrgUserService {
|
||||
iSysUserService.createUser(sysUser);
|
||||
userVO = new UserVO(sysUser);
|
||||
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(userVO.getId(), childDepart.getId(), BusinessConsts.OrgRole.Student.name());
|
||||
departmentUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
orgUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
} else {
|
||||
OrgUserExample e = new OrgUserExample();
|
||||
e.createCriteria().andUserIdEqualTo(sysUser.getId());
|
||||
List<OrgUser> orgUsers = departmentUserDAO.selectByExample(e);
|
||||
List<OrgUser> orgUsers = orgUserDAO.selectByExample(e);
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertCollectionNotEmpty(orgUsers, sysUser.getAccount() + "账号重复");
|
||||
OrgExample oe = new OrgExample();
|
||||
oe.createCriteria().andRootIdEqualTo(companyId);
|
||||
@ -386,7 +386,7 @@ public class OrgUserService implements IOrgUserService {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(orgUsers.stream().allMatch(orgUser -> orgIds.contains(orgUser.getOrgId())), sysUser.getAccount() + "账号重复");
|
||||
if (orgUsers.stream().anyMatch(orgUser -> Objects.equals(orgUser.getOrgId(), childDepart.getId()))) return;
|
||||
UserDepartRelVO userDepartRelVO = new UserDepartRelVO(userVO.getId(), childDepart.getId(), BusinessConsts.OrgRole.Student.name());
|
||||
departmentUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
orgUserDAO.insertSelective(userDepartRelVO.toDB());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
@ -28,6 +30,7 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
|
||||
private RunPlanRunlevelDAO runPlanRunlevelDAO;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void createUserRunlevel(RunPlanRunlevelVO runLevelVO) {
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(isExisted(runLevelVO));
|
||||
RunPlanRunlevel runLevel = runLevelVO.convert2Entity();
|
||||
@ -42,7 +45,9 @@ public class RunPlanRunlevelService implements IRunPlanRunlevelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateRefLevels(Long userId, Long mapId, List<RunPlanRunlevelVO> list) {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(CollectionUtils.isEmpty(list),"操作失败,数据为空");
|
||||
list.forEach(runLevelVO -> {
|
||||
RunPlanRunlevel runLevel = this.getEntityById(runLevelVO.getId());
|
||||
if (runLevel.getMapId().equals(mapId) && runLevel.getUserId().equals(userId)) {
|
||||
|
Loading…
Reference in New Issue
Block a user