Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin
This commit is contained in:
commit
b3d131ff56
@ -34,7 +34,7 @@ public class PaperCompositionController {
|
||||
return compositionService.createPaperComposition(req, user);
|
||||
}
|
||||
/**
|
||||
* 修改试卷蓝图基础信息(名称、项目、简介)
|
||||
* 修改试卷蓝图基础信息
|
||||
*/
|
||||
@PutMapping("/basic")
|
||||
public void updatePaperCompositionProfile(@RequestBody PaperCompositionBasicVo req, @RequestAttribute AccountVO user) {
|
||||
@ -44,7 +44,7 @@ public class PaperCompositionController {
|
||||
/**
|
||||
* 修改试卷蓝图详细信息
|
||||
*/
|
||||
@PutMapping("/detail")
|
||||
//@PutMapping("/detail")
|
||||
public void updatePaperCompositionDetail(@RequestBody PaperCompositionDetailVo req, @RequestAttribute AccountVO user) {
|
||||
compositionService.updatePaperCompositionDetail(req, user);
|
||||
}
|
||||
|
@ -69,8 +69,8 @@ public class AcPermissionController {
|
||||
* 获取一个权限的完整信息
|
||||
*/
|
||||
@GetMapping("/{permissionId}/whole")
|
||||
public WholePermissionRspVo findWholePermission() {
|
||||
return null;
|
||||
public WholePermissionRspVo findWholePermission(@PathVariable("permissionId") Long permissionId) {
|
||||
return this.permissionService.findWholePermission(permissionId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,6 +78,6 @@ public class AcPermissionController {
|
||||
*/
|
||||
@PostMapping("/find/page")
|
||||
public PageVO<PermissionBasicRspVo> findByPage(@RequestBody FindPermissionBasicByPageReqVo req) {
|
||||
return null;
|
||||
return this.permissionService.findByPage(req);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.paper.*;
|
||||
import club.joylink.rtss.vo.paper.convertor.PaperCompositionConvertor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -27,6 +28,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 试卷蓝图业务
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PaperCompositionService {
|
||||
@Autowired
|
||||
@ -49,6 +51,10 @@ public class PaperCompositionService {
|
||||
newPc.setName(req.getName());
|
||||
newPc.setOrgId(req.getOrgId());
|
||||
newPc.setProfile(req.getProfile());
|
||||
newPc.setStartTime(req.getStartTime());
|
||||
newPc.setEndTime(req.getEndTime());
|
||||
newPc.setValidDuration(req.getValidDuration());
|
||||
newPc.setPassScore(req.getPassScore());
|
||||
newPc.setCreateTime(LocalDateTime.now());
|
||||
newPc.setUpdateTime(LocalDateTime.now());
|
||||
newPc.setCreatorId(user.getId());
|
||||
@ -87,6 +93,10 @@ public class PaperCompositionService {
|
||||
curPc.setProfile(req.getProfile());
|
||||
curPc.setOrgId(req.getOrgId());
|
||||
curPc.setUpdateTime(LocalDateTime.now());
|
||||
curPc.setStartTime(req.getStartTime());
|
||||
curPc.setEndTime(req.getEndTime());
|
||||
curPc.setValidDuration(req.getValidDuration());
|
||||
curPc.setPassScore(req.getPassScore());
|
||||
compositionDAO.updateByPrimaryKeySelective(curPc);
|
||||
}
|
||||
|
||||
|
@ -6,17 +6,14 @@ import club.joylink.rtss.dao.permission.SystemAbilityDAO;
|
||||
import club.joylink.rtss.entity.permission.*;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.permission.CreatePermissionReqVo;
|
||||
import club.joylink.rtss.vo.permission.PermissionAbilityDeletedReqVo;
|
||||
import club.joylink.rtss.vo.permission.PermissionAbilityRspVo;
|
||||
import club.joylink.rtss.vo.permission.UpdatePermissionBasicReqVo;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.permission.*;
|
||||
import club.joylink.rtss.vo.permission.convertor.PermissionConvertor;
|
||||
import club.joylink.rtss.vo.permission.convertor.SystemAbilityConvertor;
|
||||
import org.apache.http.util.TextUtils;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@ -86,6 +83,7 @@ public class AcPermissionService {
|
||||
//
|
||||
permissionDAO.updateByPrimaryKeySelective(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给权限添加功能
|
||||
*
|
||||
@ -102,7 +100,7 @@ public class AcPermissionService {
|
||||
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();
|
||||
psaExample.createCriteria().andPermissionIdEqualTo(permissionId).andSystemAbilityIdEqualTo(abilityId);
|
||||
List<PermissionSystemAbility> psaFind = permissionSystemAbilityDAO.selectByExample(psaExample);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(psaFind),String.format("权限[id = %s]已经包含功能[id = %s]",permissionId,abilityId));
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(CollectionUtils.isEmpty(psaFind), String.format("权限[id = %s]已经包含功能[id = %s]", permissionId, abilityId));
|
||||
//
|
||||
PermissionSystemAbility permissionAddAbility = new PermissionSystemAbility();
|
||||
permissionAddAbility.setPermissionId(permissionId);
|
||||
@ -110,6 +108,7 @@ public class AcPermissionService {
|
||||
//
|
||||
permissionSystemAbilityDAO.insertSelective(permissionAddAbility);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取权限的所有功能
|
||||
*
|
||||
@ -117,19 +116,9 @@ public class AcPermissionService {
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public List<PermissionAbilityRspVo> findPermissionAbilities(Long permissionId) {
|
||||
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();
|
||||
psaExample.createCriteria().andPermissionIdEqualTo(permissionId);
|
||||
List<PermissionSystemAbility> psaFind = permissionSystemAbilityDAO.selectByExample(psaExample);
|
||||
if(!CollectionUtils.isEmpty(psaFind)){
|
||||
List<Long> abilityIds = psaFind.stream().map(PermissionSystemAbility::getSystemAbilityId).collect(Collectors.toList());
|
||||
SystemAbilityExample abilityExample = new SystemAbilityExample();
|
||||
abilityExample.createCriteria().andAbilityIdIn(abilityIds);
|
||||
List<SystemAbility> abilityList = abilityDAO.selectByExample(abilityExample);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(abilityList.size()==abilityIds.size(),String.format("权限[id = %s]包含的功能的实体有些已经不存在",permissionId));
|
||||
return abilityList.stream().map(SystemAbilityConvertor::convertPermissionAbilityRspVoFrom).collect(Collectors.toList());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
return this.findAbilitiesByPermissionId(permissionId).stream().map(SystemAbilityConvertor::convertPermissionAbilityRspVoFrom).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除权限的功能,删除桥接表记录
|
||||
*/
|
||||
@ -140,6 +129,37 @@ public class AcPermissionService {
|
||||
this.permissionSystemAbilityDAO.deleteByExample(example);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个权限的完整信息
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public WholePermissionRspVo findWholePermission(Long permissionId) {
|
||||
Permission permission = this.permissionDAO.selectByPrimaryKey(permissionId);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null != permission, String.format("权限[id = %s]不存在", permissionId));
|
||||
List<SystemAbility> abilityList = findAbilitiesByPermissionId(permissionId);
|
||||
return PermissionConvertor.convertWholePermissionRspVoFrom(permission, abilityList);
|
||||
}
|
||||
/**
|
||||
* 分页获取权限
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public PageVO<PermissionBasicRspVo> findByPage(FindPermissionBasicByPageReqVo req) {
|
||||
return null;
|
||||
}
|
||||
private List<SystemAbility> findAbilitiesByPermissionId(Long permissionId) {
|
||||
PermissionSystemAbilityExample psaExample = new PermissionSystemAbilityExample();
|
||||
psaExample.createCriteria().andPermissionIdEqualTo(permissionId);
|
||||
List<PermissionSystemAbility> psaFind = permissionSystemAbilityDAO.selectByExample(psaExample);
|
||||
if (!CollectionUtils.isEmpty(psaFind)) {
|
||||
List<Long> abilityIds = psaFind.stream().map(PermissionSystemAbility::getSystemAbilityId).collect(Collectors.toList());
|
||||
SystemAbilityExample abilityExample = new SystemAbilityExample();
|
||||
abilityExample.createCriteria().andAbilityIdIn(abilityIds);
|
||||
List<SystemAbility> abilityList = abilityDAO.selectByExample(abilityExample);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(abilityList.size() == abilityIds.size(), String.format("权限[id = %s]包含的功能的实体有些已经不存在", permissionId));
|
||||
return abilityList;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
private Permission findByName(String name) {
|
||||
PermissionExample example = new PermissionExample();
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.rtss.vo.paper;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CreatePaperCompositionReqVo {
|
||||
@ -22,4 +23,23 @@ public class CreatePaperCompositionReqVo {
|
||||
*/
|
||||
@NotNull
|
||||
private Long orgId;
|
||||
/**
|
||||
* 启用起始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 启用截止时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 完成考试有效最长时长,单位min
|
||||
*/
|
||||
private Integer validDuration;
|
||||
|
||||
/**
|
||||
* 及格分
|
||||
*/
|
||||
private Integer passScore;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class PaperCompositionBasicVo {
|
||||
@ -29,4 +30,23 @@ public class PaperCompositionBasicVo {
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orgId;
|
||||
/**
|
||||
* 启用起始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 启用截止时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 完成考试有效最长时长,单位min
|
||||
*/
|
||||
private Integer validDuration;
|
||||
|
||||
/**
|
||||
* 及格分
|
||||
*/
|
||||
private Integer passScore;
|
||||
}
|
||||
|
@ -1,12 +1,75 @@
|
||||
package club.joylink.rtss.vo.permission;
|
||||
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import club.joylink.rtss.vo.paper.FindPuType;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分页查询权限基础信息请求
|
||||
*/
|
||||
@Data
|
||||
public class FindPermissionBasicByPageReqVo extends PageQueryVO {
|
||||
/**
|
||||
* 按权限名称查询
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 按权限名称查询时,默认true,true-模糊查询,false-精确查询
|
||||
*/
|
||||
private Boolean nameLike = true;
|
||||
/**
|
||||
* 按权限描述查询
|
||||
*/
|
||||
private String des;
|
||||
/**
|
||||
* 按权限描述查询时,默认true,true-模糊查询,false-精确查询
|
||||
*/
|
||||
private Boolean desLike = true;
|
||||
/**
|
||||
* 是否降序,true-降序,false-升序,默认值为true;
|
||||
*/
|
||||
private Boolean desc = true;
|
||||
/**
|
||||
* 排序类型
|
||||
*/
|
||||
private OrderByType orderByType;
|
||||
|
||||
/////////////////////////////////////////////
|
||||
public static enum OrderByType {
|
||||
;
|
||||
private Integer value;
|
||||
private String orderBy;
|
||||
|
||||
private OrderByType(Integer value, String orderBy) {
|
||||
this.value = value;
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public String orderBy() {
|
||||
return this.orderBy;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static OrderByType getItem(Integer value) {
|
||||
return map.get(value);
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private static Map<Integer, OrderByType> map = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (OrderByType t : values()) {
|
||||
map.put(t.value, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package club.joylink.rtss.vo.permission.convertor;
|
||||
|
||||
import club.joylink.rtss.entity.permission.Permission;
|
||||
import club.joylink.rtss.entity.permission.SystemAbility;
|
||||
import club.joylink.rtss.vo.permission.WholePermissionRspVo;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PermissionConvertor {
|
||||
public static WholePermissionRspVo convertWholePermissionRspVoFrom(Permission fromP, List<SystemAbility> fromA) {
|
||||
WholePermissionRspVo rt = new WholePermissionRspVo();
|
||||
rt.setId(fromP.getId());
|
||||
rt.setCreateTime(fromP.getCreateTime());
|
||||
rt.setCreatorId(fromP.getCreatorId());
|
||||
rt.setDes(fromP.getDes());
|
||||
rt.setName(fromP.getName());
|
||||
rt.setUpdateTime(fromP.getUpdateTime());
|
||||
if (CollectionUtils.isEmpty(fromA)) {
|
||||
rt.setAbilityList(new ArrayList<>());
|
||||
} else {
|
||||
rt.setAbilityList(fromA.stream().map(SystemAbilityConvertor::convertPermissionAbilityRspVoFrom).collect(Collectors.toList()));
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user