Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1
This commit is contained in:
commit
f97b92e6f8
11
sql/20220929-wei-org-project.sql
Normal file
11
sql/20220929-wei-org-project.sql
Normal file
@ -0,0 +1,11 @@
|
||||
create TABLE `org_project` (
|
||||
`id` int NOT NULL AUTO_INCREMENT comment '主键',
|
||||
`org_id` int NOT NULL comment '组织ID',
|
||||
`project_code` varchar(255) NOT NULL comment '项目编码',
|
||||
`creator_id` int DEFAULT NULL comment '创建者',
|
||||
`create_time` datetime DEFAULT NULL comment '创建时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `org_id_2` (`org_id`,`project_code`),
|
||||
KEY `org_id` (`org_id`),
|
||||
KEY `project_code` (`project_code`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
@ -0,0 +1,33 @@
|
||||
package club.joylink.rtss.controller.org;
|
||||
|
||||
import club.joylink.rtss.services.org.IOrgProjectService;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/org")
|
||||
public class OrgProjectController {
|
||||
|
||||
@Autowired
|
||||
private IOrgProjectService orgProjectService;
|
||||
|
||||
/**
|
||||
* 用户登录时,要选择的组织列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public List<OrgProjectVO> queryOrgList(@RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
return orgProjectService.queryOrgProjectListByProjectAndUid(loginInfo.getProject(), loginInfo.getAccountVO().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择登入组织
|
||||
*/
|
||||
@PutMapping("signIn/{orgId}")
|
||||
public void signInOrg(@PathVariable Long orgId, @RequestAttribute LoginUserInfoVO loginInfo) {
|
||||
orgProjectService.signInOrg(orgId, loginInfo);
|
||||
}
|
||||
}
|
16
src/main/java/club/joylink/rtss/dao/org/OrgProjectDao.java
Normal file
16
src/main/java/club/joylink/rtss/dao/org/OrgProjectDao.java
Normal file
@ -0,0 +1,16 @@
|
||||
package club.joylink.rtss.dao.org;
|
||||
|
||||
import club.joylink.rtss.dao.MyBatisBaseDao;
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.entity.org.OrgProjectExample;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 组织与项目关系
|
||||
*/
|
||||
@Repository
|
||||
public interface OrgProjectDao extends MyBatisBaseDao<OrgProject, Long, OrgProjectExample> {
|
||||
|
||||
int deleteByExampleSelective(@Param("example") OrgProjectExample example);
|
||||
}
|
@ -0,0 +1,511 @@
|
||||
package club.joylink.rtss.entity.org;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OrgProjectExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public OrgProjectExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(Integer value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(Integer value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(Integer value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(Integer value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<Integer> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<Integer> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdIsNull() {
|
||||
addCriterion("org_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdIsNotNull() {
|
||||
addCriterion("org_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdEqualTo(Long value) {
|
||||
addCriterion("org_id =", value, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdNotEqualTo(Long value) {
|
||||
addCriterion("org_id <>", value, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdGreaterThan(Long value) {
|
||||
addCriterion("org_id >", value, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("org_id >=", value, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdLessThan(Long value) {
|
||||
addCriterion("org_id <", value, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("org_id <=", value, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdIn(List<Long> values) {
|
||||
addCriterion("org_id in", values, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdNotIn(List<Long> values) {
|
||||
addCriterion("org_id not in", values, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdBetween(Long value1, Long value2) {
|
||||
addCriterion("org_id between", value1, value2, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andOrgIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("org_id not between", value1, value2, "orgId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeIsNull() {
|
||||
addCriterion("project_code is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeIsNotNull() {
|
||||
addCriterion("project_code is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeEqualTo(String value) {
|
||||
addCriterion("project_code =", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeNotEqualTo(String value) {
|
||||
addCriterion("project_code <>", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeGreaterThan(String value) {
|
||||
addCriterion("project_code >", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("project_code >=", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeLessThan(String value) {
|
||||
addCriterion("project_code <", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeLessThanOrEqualTo(String value) {
|
||||
addCriterion("project_code <=", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeLike(String value) {
|
||||
addCriterion("project_code like", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeNotLike(String value) {
|
||||
addCriterion("project_code not like", value, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeIn(List<String> values) {
|
||||
addCriterion("project_code in", values, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeNotIn(List<String> values) {
|
||||
addCriterion("project_code not in", values, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeBetween(String value1, String value2) {
|
||||
addCriterion("project_code between", value1, value2, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andProjectCodeNotBetween(String value1, String value2) {
|
||||
addCriterion("project_code not between", value1, value2, "projectCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdIsNull() {
|
||||
addCriterion("creator_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdIsNotNull() {
|
||||
addCriterion("creator_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdEqualTo(Integer value) {
|
||||
addCriterion("creator_id =", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdNotEqualTo(Integer value) {
|
||||
addCriterion("creator_id <>", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdGreaterThan(Integer value) {
|
||||
addCriterion("creator_id >", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("creator_id >=", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdLessThan(Integer value) {
|
||||
addCriterion("creator_id <", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("creator_id <=", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdIn(List<Integer> values) {
|
||||
addCriterion("creator_id in", values, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdNotIn(List<Integer> values) {
|
||||
addCriterion("creator_id not in", values, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdBetween(Integer value1, Integer value2) {
|
||||
addCriterion("creator_id between", value1, value2, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("creator_id not between", value1, value2, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(Date value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(Date value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(Date value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(Date value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<Date> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<Date> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(Date value1, Date value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package club.joylink.rtss.services.org;
|
||||
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目与组织关系
|
||||
*/
|
||||
public interface IOrgProjectService {
|
||||
|
||||
/**
|
||||
* 根据组织Id获取项目列表
|
||||
*/
|
||||
List<OrgProject> queryOrgProjectListByOrgId(Long orgId);
|
||||
|
||||
/**
|
||||
* 根据项目获取组织列表
|
||||
*/
|
||||
List<OrgProjectVO> queryOrgProjectListByProjectAndUid(String project, Long uid);
|
||||
|
||||
/**
|
||||
* 选择登入项目
|
||||
*/
|
||||
void signInOrg(Long orgId, LoginUserInfoVO loginInfo);
|
||||
|
||||
/**
|
||||
* 保存顶级信息时,处理信息
|
||||
*/
|
||||
void save(Long orgId, List<String> projectList, AccountVO user);
|
||||
|
||||
/**
|
||||
* 保存顶级信息时,处理编辑信息
|
||||
*/
|
||||
void update(Long orgId, List<String> projectList, AccountVO user);
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
package club.joylink.rtss.services.org;
|
||||
|
||||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.dao.OrgDAO;
|
||||
import club.joylink.rtss.dao.OrgUserDAO;
|
||||
import club.joylink.rtss.dao.org.OrgProjectDao;
|
||||
import club.joylink.rtss.entity.Org;
|
||||
import club.joylink.rtss.entity.OrgExample;
|
||||
import club.joylink.rtss.entity.OrgUser;
|
||||
import club.joylink.rtss.entity.OrgUserExample;
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.entity.org.OrgProjectExample;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||
import club.joylink.rtss.vo.client.org.OrgProjectVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 组织与项目关联管理
|
||||
*/
|
||||
@Service
|
||||
public class OrgProjectService implements IOrgProjectService {
|
||||
@Autowired
|
||||
private OrgProjectDao orgProjectDao;
|
||||
|
||||
@Autowired
|
||||
private OrgUserDAO orgUserDAO;
|
||||
|
||||
@Autowired
|
||||
private OrgDAO orgDAO;
|
||||
|
||||
@Override
|
||||
public List<OrgProject> queryOrgProjectListByOrgId(Long orgId) {
|
||||
OrgProjectExample orgProjectExample = new OrgProjectExample();
|
||||
orgProjectExample.createCriteria().andOrgIdEqualTo(orgId);
|
||||
return orgProjectDao.selectByExample(orgProjectExample);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgProjectVO> queryOrgProjectListByProjectAndUid(String project, Long uid) {
|
||||
// 查询项目关联顶级组织
|
||||
OrgProjectExample orgProjectExample = new OrgProjectExample();
|
||||
orgProjectExample.createCriteria().andProjectCodeEqualTo(project);
|
||||
List<OrgProject> orgProjectList = orgProjectDao.selectByExample(orgProjectExample);
|
||||
if (CollectionUtils.isEmpty(orgProjectList)) {
|
||||
return List.of();
|
||||
}
|
||||
List<Long> orgTopIdList = orgProjectList.stream().map(OrgProject::getOrgId).collect(Collectors.toList());
|
||||
// 获取人员关联组织
|
||||
OrgUserExample example = new OrgUserExample();
|
||||
example.createCriteria().andUserIdEqualTo(uid);
|
||||
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(orgUserList)) {
|
||||
return List.of();
|
||||
}
|
||||
List<Long> orgIdList = orgUserList.stream().map(OrgUser::getOrgId).collect(Collectors.toList());
|
||||
OrgExample orgExample = new OrgExample();
|
||||
orgExample.createCriteria().andStatusEqualTo(BusinessConsts.Org.Status.VALID).andIdIn(orgIdList).andRootIdIn(orgTopIdList);
|
||||
List<Org> orgList = orgDAO.selectByExample(orgExample);
|
||||
return orgList.stream().map(org -> new OrgProjectVO(org, project)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signInOrg(Long orgId, LoginUserInfoVO loginInfo) {
|
||||
Org orgInfo = orgDAO.selectByPrimaryKey(orgId);
|
||||
if (orgInfo == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||
}
|
||||
// 查询项目关联顶级组织
|
||||
OrgProjectExample orgProjectExample = new OrgProjectExample();
|
||||
orgProjectExample.createCriteria().andProjectCodeEqualTo(loginInfo.getProject()).andOrgIdEqualTo(orgInfo.getRootId());
|
||||
List<OrgProject> orgProjectList = orgProjectDao.selectByExample(orgProjectExample);
|
||||
if (CollectionUtils.isEmpty(orgProjectList)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||
}
|
||||
// 检验用户是否有组织信息
|
||||
OrgUserExample example = new OrgUserExample();
|
||||
example.createCriteria().andUserIdEqualTo(loginInfo.getAccountVO().getId()).andOrgIdEqualTo(orgId);
|
||||
List<OrgUser> orgUserList = orgUserDAO.selectByExample(example);
|
||||
if (CollectionUtils.isEmpty(orgUserList)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||
}
|
||||
loginInfo.setOrgProjectVO(new OrgProjectVO(orgInfo, loginInfo.getProject()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Long orgId, List<String> projectList, AccountVO user) {
|
||||
if (orgId == null || CollectionUtils.isEmpty(projectList)) {
|
||||
return;
|
||||
}
|
||||
projectList.stream().forEach(code -> {
|
||||
OrgProject orgProject = new OrgProject();
|
||||
orgProject.setOrgId(orgId);
|
||||
orgProject.setProjectCode(code);
|
||||
orgProject.setCreateTime(LocalDateTime.now());
|
||||
orgProject.setCreatorId(user.getId());
|
||||
orgProjectDao.insert(orgProject);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Long orgId, List<String> projectList, AccountVO user) {
|
||||
OrgProjectExample orgProjectExample = new OrgProjectExample();
|
||||
if (CollectionUtils.isEmpty(projectList)) { // 为空,直接删除项目列表
|
||||
orgProjectExample.createCriteria().andOrgIdEqualTo(orgId);
|
||||
orgProjectDao.deleteByExampleSelective(orgProjectExample);
|
||||
} else {
|
||||
List<OrgProject> orgProjects = orgProjectDao.selectByExample(orgProjectExample);
|
||||
if (checkChange(orgProjects, projectList)) {
|
||||
List<String> oldProjectList = orgProjects.stream().map(OrgProject::getProjectCode).collect(Collectors.toList());
|
||||
// 删除不存在的
|
||||
List<String> delCodeList = oldProjectList.stream().filter(code -> !projectList.contains(code)).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(delCodeList)) {
|
||||
orgProjectExample.createCriteria().andOrgIdEqualTo(orgId).andProjectCodeIn(delCodeList);
|
||||
orgProjectDao.deleteByExampleSelective(orgProjectExample);
|
||||
}
|
||||
// 插入信息的
|
||||
List<String> newCodeList = projectList.stream().filter(code -> !oldProjectList.contains(code)).collect(Collectors.toList());
|
||||
if (!CollectionUtils.isEmpty(newCodeList)) {
|
||||
save(orgId, newCodeList, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数组是否发生变化
|
||||
*/
|
||||
private boolean checkChange(List<OrgProject> orgProjects, List<String> projectList) {
|
||||
if (CollectionUtils.isEmpty(projectList) && CollectionUtils.isEmpty(projectList)) {
|
||||
return false;
|
||||
}
|
||||
if (orgProjects.size() != projectList.size()) {
|
||||
return true;
|
||||
}
|
||||
if (orgProjects.stream().anyMatch(o -> !projectList.contains(o.getProjectCode()))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -43,6 +43,9 @@ public class OrgService implements IOrgService {
|
||||
@Autowired
|
||||
private QRCodeManager qrCodeManager;
|
||||
|
||||
@Autowired
|
||||
private IOrgProjectService orgProjectService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CompanyVO createTopOrg(CompanyVO companyVO, AccountVO user) {
|
||||
@ -60,6 +63,8 @@ public class OrgService implements IOrgService {
|
||||
this.orgDAO.insert(entity);
|
||||
entity.setRootId(entity.getId());
|
||||
orgDAO.updateByPrimaryKey(entity);
|
||||
// 20220929 增加
|
||||
orgProjectService.save(entity.getId(), companyVO.getProjectCodes(), user);
|
||||
return new CompanyVO(entity);
|
||||
}
|
||||
|
||||
@ -154,6 +159,8 @@ public class OrgService implements IOrgService {
|
||||
if (!CollectionUtils.isEmpty(companyVO.getProjectCodes())) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(isTopOrg(org), "非顶级组织不能修改关联项目");
|
||||
// confirmProjectCodesNotRepeat(org.getId(), companyVO.getProjectCodes());
|
||||
// 20220929 增加
|
||||
orgProjectService.update(id, companyVO.getProjectCodes(), user);
|
||||
}
|
||||
confirmNameUnique(id, companyVO.getName());
|
||||
//更新
|
||||
|
@ -37,8 +37,9 @@ public class PagerQuestionService {
|
||||
private PaperQuestionDAO questionDAO;
|
||||
|
||||
private Object queryQuestions(QuestionQueryVO queryVO, boolean isPaging,boolean companyIdCanNull){
|
||||
boolean check = Objects.equals(false,companyIdCanNull) && Objects.isNull(queryVO.getCompanyId());
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(check,"题目答案不能为空");
|
||||
if(Objects.equals(false,companyIdCanNull)){
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(Objects.nonNull(queryVO.getCompanyId()),"题目答案不能为空");
|
||||
}
|
||||
if(isPaging){
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
}
|
||||
|
@ -1,19 +1,24 @@
|
||||
package club.joylink.rtss.vo.client.org;
|
||||
|
||||
import club.joylink.rtss.entity.org.OrgProject;
|
||||
import club.joylink.rtss.entity.Org;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class OrgProjectVO {
|
||||
private Long topOrgId;
|
||||
|
||||
private Long orgId;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long topOrgId;
|
||||
|
||||
private String projectCode;
|
||||
|
||||
public OrgProjectVO(OrgProject orgProject) {
|
||||
this.orgId = orgProject.getOrgId();
|
||||
this.projectCode = orgProject.getProjectCode();
|
||||
public OrgProjectVO(Org org, String projectCode) {
|
||||
this.orgId = org.getId();
|
||||
this.name = org.getName();
|
||||
this.topOrgId = org.getRootId();
|
||||
this.projectCode = projectCode;
|
||||
}
|
||||
}
|
||||
|
208
src/main/resources/mybatis/mapper/OrgProjectDao.xml
Normal file
208
src/main/resources/mybatis/mapper/OrgProjectDao.xml
Normal file
@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="club.joylink.rtss.dao.org.OrgProjectDao">
|
||||
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.org.OrgProject">
|
||||
<id column="id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="org_id" property="orgId" jdbcType="BIGINT"/>
|
||||
<result column="project_code" property="projectCode" jdbcType="VARCHAR"/>
|
||||
<result column="creator_id" property="creatorId" jdbcType="BIGINT"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" suffix=")" prefixOverrides="and">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach collection="criterion.value" item="listItem" open="(" close=")"
|
||||
separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" suffix=")" prefixOverrides="and">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach collection="criterion.value" item="listItem" open="(" close=")"
|
||||
separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, org_id, project_code, creator_id, create_time
|
||||
</sql>
|
||||
<select id="selectByExample" resultMap="BaseResultMap"
|
||||
parameterType="club.joylink.rtss.entity.org.OrgProjectExample">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
'true' as QUERYID,
|
||||
<include refid="Base_Column_List"/>
|
||||
from org_project
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause"/>
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from org_project
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
||||
delete from org_project where id = #{id,jdbcType=BIGINT}
|
||||
</delete>
|
||||
<update id="deleteByExampleSelective" parameterType="map">
|
||||
delete from org_project
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause"/>
|
||||
</if>
|
||||
</update>
|
||||
<insert id="insert" parameterType="club.joylink.rtss.entity.org.OrgProject" keyProperty="id"
|
||||
useGeneratedKeys="true" keyColumn="id">
|
||||
insert into org_project (org_id, project_code, creator_id, create_time)
|
||||
values (#{orgId,jdbcType=BIGINT}, #{projectCode,jdbcType=VARCHAR},
|
||||
#{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="club.joylink.rtss.entity.org.OrgProject">
|
||||
insert into org_project
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="orgId != null">
|
||||
org_id,
|
||||
</if>
|
||||
<if test="projectCode != null">
|
||||
project_code,
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
creator_id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="orgId != null">
|
||||
#{orgId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="projectCode != null">
|
||||
#{projectCode,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
#{creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update org_project
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.orgId != null">
|
||||
org_id = #{record.orgId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.projectCode != null">
|
||||
project_code = #{record.projectCode,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.creatorId != null">
|
||||
creator_id = #{record.creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause"/>
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update org_project
|
||||
set id = #{record.id,jdbcType=BIGINT},
|
||||
org_id = #{record.orgId,jdbcType=BIGINT},
|
||||
project_code = #{record.projectCode,jdbcType=VARCHAR},
|
||||
creator_id = #{record.creatorId,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause"/>
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.org.OrgProject">
|
||||
update org_project
|
||||
<set>
|
||||
<if test="orgId != null">
|
||||
org_id = #{orgId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="projectCode != null">
|
||||
project_code = #{projectCode,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
creator_id = #{creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.org.OrgProject">
|
||||
update org_project
|
||||
set org_id = #{orgId,jdbcType=BIGINT},
|
||||
project_code = #{projectCode,jdbcType=VARCHAR},
|
||||
creator_id = #{creatorId,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user