Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-10-14 13:33:42 +08:00
commit e577e255a9
3 changed files with 60 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
@ -61,6 +62,36 @@ public class PagerQuestionService {
if(Objects.nonNull(queryVO.getOrgId())){
criteria.andOrgIdEqualTo(queryVO.getOrgId());
}
if(Objects.nonNull(queryVO.getLabels())){
// PaperQuestionExample.Criteria criteria2 = example.createCriteria();
// example.getOredCriteria().add(criteria2);
List<String> tmpLableList = Splitter.on(",").omitEmptyStrings().splitToList(queryVO.getLabels());
if(Objects.equals(false,CollectionUtils.isEmpty(tmpLableList))){
StringBuilder sqlBuilder = new StringBuilder("(");
for(var i = 0 ; i < tmpLableList.size();i++){
String data = tmpLableList.get(i);
if(i != 0){
sqlBuilder.append(" or ");
}
sqlBuilder.append(String.format(" find_in_set('%s',tags) > 0 ",data));
}
sqlBuilder.append(")");
Class<?> criteriaCls = PaperQuestionExample.Criteria.class;
Class<?> generatedCriteriaCls = criteriaCls.getSuperclass();
try{
Method addCriterion = generatedCriteriaCls.getDeclaredMethod("addCriterion", String.class);
addCriterion.setAccessible(true);
addCriterion.invoke(criteria, sqlBuilder.toString());
}catch (Exception e){
}
}
}
criteria.andIsDelEqualTo(BusinessConsts.DBLogicDelete.NORMAL.ordinal());
return questionDAO.selectByExampleWithBLOBs(example);

View File

@ -1,6 +1,9 @@
package club.joylink.rtss.services.permission;
import club.joylink.rtss.dao.permission.PermissionSystemAbilityDAO;
import club.joylink.rtss.dao.permission.SystemAbilityDAO;
import club.joylink.rtss.entity.permission.PermissionSystemAbility;
import club.joylink.rtss.entity.permission.PermissionSystemAbilityExample;
import club.joylink.rtss.entity.permission.SystemAbility;
import club.joylink.rtss.entity.permission.SystemAbilityExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
@ -16,7 +19,9 @@ import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import static club.joylink.rtss.vo.permission.SystemAbilityStatus.Editing;
@ -25,6 +30,9 @@ import static club.joylink.rtss.vo.permission.SystemAbilityStatus.Editing;
public class SystemAbilityService {
@Resource
private SystemAbilityDAO systemAbilityDAO;
@Resource
private PermissionSystemAbilityDAO permissionSystemAbilityDAO;
public SystemAbility findById(Long id){
SystemAbility dbSa = this.systemAbilityDAO.selectByPrimaryKey(id);
@ -84,9 +92,26 @@ public class SystemAbilityService {
*/
public void remove(DeleteAbilitiesReqVo reqVo){
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(CollectionUtils.isEmpty(reqVo.getIds()),"删除数据的id不能为空");
List<Long> newIds = reqVo.getIds().stream().distinct().collect(Collectors.toList());
PermissionSystemAbilityExample pe = new PermissionSystemAbilityExample();
pe.createCriteria().andSystemAbilityIdIn(newIds);
List<PermissionSystemAbility> psaList = this.permissionSystemAbilityDAO.selectByExample(pe);
Map<Long,List<PermissionSystemAbility>> psaMapList = psaList.stream()
.collect(Collectors.groupingBy(PermissionSystemAbility::getSystemAbilityId));
newIds.stream().forEach(psaMapList::remove);
StringBuilder sb = new StringBuilder();
psaMapList.forEach((k,v)->{
sb.append(String.format("id=%s有绑定的权限数量=%s,不能删除",k,v.size()));
});
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(psaMapList.isEmpty(),sb.toString());
SystemAbilityExample example = new SystemAbilityExample();
SystemAbilityExample.Criteria criteria = example.createCriteria();
criteria.andIdIn(reqVo.getIds());
criteria.andIdIn(newIds);
this.systemAbilityDAO.deleteByExample(example);
}

View File

@ -4,6 +4,8 @@ import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class QuestionQueryVO extends PageQueryVO {
@ -14,5 +16,5 @@ public class QuestionQueryVO extends PageQueryVO {
// private String projectCode;
private Long orgId;
private String labels;
}