Browse Source

Merge remote-tracking branch 'remotes/origin/dev_1.0.0' into release_1.0.0

xiatian 2 years ago
parent
commit
4255596d37

+ 2 - 1
db/init.sql

@@ -149,7 +149,8 @@ CREATE TABLE `mps_paper_group_unit` (
   `detail_number` int NOT NULL,
   `detail_unit_number` int NOT NULL,
   PRIMARY KEY (`id`),
-  UNIQUE KEY `IDX_PAPER_GROUP_UNIT_01` (`paper_id`,`group_id`,`detail_number`,`detail_unit_number`)
+  UNIQUE KEY `IDX_PAPER_GROUP_UNIT_01` (`paper_id`,`detail_number`,`detail_unit_number`),
+  KEY `IDX_PAPER_GROUP_UNIT_02` (`group_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 
 -- ----------------------------

+ 2 - 2
src/main/java/cn/com/qmth/mps/controller/PaperController.java

@@ -150,8 +150,8 @@ public class PaperController extends BaseController {
 	
 	@ApiOperation(value = "删除分组信息")
 	@RequestMapping(value = "group/delete", method = RequestMethod.POST)
-	public void groupDelete(@RequestParam Long paperId, @RequestParam Integer groupNumber) {
-		paperGroupService.groupDelete(paperId,groupNumber,getAccessUser());
+	public void groupDelete(@RequestParam Long groupId) {
+		paperGroupService.groupDelete(groupId,getAccessUser());
 	}
 	
 	@ApiOperation(value = "清空分组信息")

+ 1 - 1
src/main/java/cn/com/qmth/mps/service/PaperGroupService.java

@@ -26,7 +26,7 @@ public interface PaperGroupService  extends IService<PaperGroupEntity> {
 
 	void groupSave(PaperGroupDomain domain, User accessUser);
 
-	void groupDelete(Long paperId, Integer groupNumber, User accessUser);
+	void groupDelete(Long groupId, User accessUser);
 
 	Boolean existsGroup(Long paperId);
 

+ 1 - 1
src/main/java/cn/com/qmth/mps/service/PaperGroupUnitService.java

@@ -13,7 +13,7 @@ public interface PaperGroupUnitService  extends IService<PaperGroupUnitEntity> {
 
 	Map<Long, List<PaperGroupUnit>> getGroupInfo(Long paperId);
 
-	void removeByPaperIdAndGroup(Long paperId, Long groupId);
+	void removeByGroupId(Long groupId);
 
 	void saveUnit(PaperGroupEntity group, List<PaperGroupUnit> groupUnits);
 

+ 17 - 12
src/main/java/cn/com/qmth/mps/service/impl/PaperGroupServiceImpl.java

@@ -218,11 +218,16 @@ public class PaperGroupServiceImpl extends ServiceImpl<PaperGroupDao, PaperGroup
 		if (!paper.getStructFinish()) {
 			throw new StatusException("试卷结构未提交,不能设置分组");
 		}
-		groupDelete(domain.getPaperId(), domain.getNumber(), user);
-		PaperGroupEntity g = new PaperGroupEntity();
+		PaperGroupEntity g;
+		if(domain.getGroupId()!=null) {
+			g=this.getById(domain.getGroupId());
+			paperGroupUnitService.removeByGroupId(domain.getGroupId());
+		}else {
+			g = new PaperGroupEntity();
+			g.setPaperId(domain.getPaperId());
+		}
 		g.setNumber(domain.getNumber());
-		g.setPaperId(domain.getPaperId());
-		this.save(g);
+		this.saveOrUpdate(g);
 		List<PaperDetail> pds = paperDetailService.getStructInfo(domain.getPaperId());
 		if (CollectionUtils.isEmpty(pds)) {
 			throw new StatusException("试卷结构小题信息为空");
@@ -258,20 +263,20 @@ public class PaperGroupServiceImpl extends ServiceImpl<PaperGroupDao, PaperGroup
 
 	@Transactional
 	@Override
-	public void groupDelete(Long paperId, Integer groupNumber, User user) {
-		PaperEntity paper = paperService.getById(paperId);
+	public void groupDelete(Long groupId, User user) {
+		PaperGroupEntity group=this.getById(groupId);
+		if (group == null) {
+			throw new StatusException("未找到分组信息");
+		}
+		PaperEntity paper = paperService.getById(group.getPaperId());
 		if (paper == null) {
 			throw new StatusException("未找到试卷结构");
 		}
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(paper.getSchoolId())) {
 			throw new StatusException("没有权限");
 		}
-		PaperGroupEntity old = getByPaperIdAndNumber(paperId, groupNumber);
-		if (old == null) {
-			throw new StatusException("未找到分组信息");
-		}
-		this.removeById(old.getId());
-		paperGroupUnitService.removeByPaperIdAndGroup(paperId, old.getId());
+		this.removeById(groupId);
+		paperGroupUnitService.removeByGroupId(groupId);
 		paper.setGroupFinish(false);
 		paperService.updateById(paper);
 	}

+ 1 - 2
src/main/java/cn/com/qmth/mps/service/impl/PaperGroupUnitServiceImpl.java

@@ -53,10 +53,9 @@ public class PaperGroupUnitServiceImpl extends ServiceImpl<PaperGroupUnitDao, Pa
 	}
 	@Transactional
 	@Override
-	public void removeByPaperIdAndGroup(Long paperId, Long groupId) {
+	public void removeByGroupId( Long groupId) {
 		QueryWrapper<PaperGroupUnitEntity> wrapper = new QueryWrapper<>();
 		LambdaQueryWrapper<PaperGroupUnitEntity> lw = wrapper.lambda();
-		lw.eq(PaperGroupUnitEntity::getPaperId, paperId);
 		lw.eq(PaperGroupUnitEntity::getGroupId, groupId);
 		this.remove(wrapper);
 	}

+ 1 - 3
src/main/java/cn/com/qmth/mps/service/impl/SchoolServiceImpl.java

@@ -42,8 +42,6 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolDao, SchoolEntity> impl
 	private String accessSecret;
 	@Value("${wxapp-url}")
 	private String wxappUrl;
-	@Value("${mps-server}")
-	private String mpsServer;
 
 	@Transactional
 	@Override
@@ -131,7 +129,7 @@ public class SchoolServiceImpl extends ServiceImpl<SchoolDao, SchoolEntity> impl
 				query, schoolId);
 		if (CollectionUtils.isNotEmpty(iPage.getRecords())) {
 			for (SchoolVo vo : iPage.getRecords()) {
-				vo.setQrCode(wxappUrl+"/mpsServer="+mpsServer);
+				vo.setQrCode(wxappUrl);
 			}
 		}
 		return PageUtil.of(iPage);

+ 18 - 8
src/main/java/cn/com/qmth/mps/service/impl/UserServiceImpl.java

@@ -78,7 +78,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 		if (StringUtils.isBlank(domain.getLoginName())) {
 			throw new StatusException("登录名不能为空");
 		}
-		if (domain.getId()== null&&StringUtils.isBlank(domain.getPasswd())) {
+		if (domain.getId() == null && StringUtils.isBlank(domain.getPasswd())) {
 			throw new StatusException("密码不能为空");
 		}
 		if (domain.getRole() == null) {
@@ -243,6 +243,15 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 			throw new StatusException("没有权限");
 		}
 		IPage<UserVo> iPage = this.baseMapper.page(new Page<UserVo>(query.getPageNumber(), query.getPageSize()), query);
+		if (CollectionUtils.isNotEmpty(iPage.getRecords())) {
+			for (UserVo vo : iPage.getRecords()) {
+				vo.setRole(Role.getById(vo.getRoleId()));
+				if (vo.getRoleId().equals(Role.SECTION_LEADER.getId())) {
+					List<CourseInfo> cs = userCourseRelationService.getCourses(vo.getId());
+					vo.setCourseCodes(cs.stream().map(m -> m.getCode()).collect(Collectors.toList()));
+				}
+			}
+		}
 		return PageUtil.of(iPage);
 	}
 
@@ -256,13 +265,14 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 		vo.setEnable(ue.getEnable());
 		vo.setId(ue.getId());
 		vo.setRoleId(ue.getRoleId());
+		vo.setRole(Role.getById(ue.getRoleId()));
 		vo.setLoginName(ue.getLoginName());
 		vo.setName(ue.getName());
 		vo.setSchoolId(ue.getSchoolId());
 		vo.setSchoolName(schoolService.getById(ue.getSchoolId()).getName());
 		if (vo.getRoleId().equals(Role.SECTION_LEADER.getId())) {
-			List<CourseInfo> cs=userCourseRelationService.getCourses(vo.getId());
-			vo.setCourseCodes(cs.stream().map(m->m.getCode()).collect(Collectors.toList()));
+			List<CourseInfo> cs = userCourseRelationService.getCourses(vo.getId());
+			vo.setCourseCodes(cs.stream().map(m -> m.getCode()).collect(Collectors.toList()));
 		}
 		return vo;
 	}
@@ -334,13 +344,13 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
 		vo.setSchoolId(ue.getSchoolId());
 		vo.setSchoolName(schoolService.getById(ue.getSchoolId()).getName());
 		if (vo.getRoleId().equals(Role.SECTION_LEADER.getId())) {
-			List<CourseInfo> cs=userCourseRelationService.getCourses(vo.getId());
-			if(CollectionUtils.isNotEmpty(cs)) {
-				vo.setCourseCodes(cs.stream().map(m->m.getCode()).collect(Collectors.toList()));
-				vo.setCourseNames(cs.stream().map(m->m.getCode()+"-"+m.getName()).collect(Collectors.toList()));
+			List<CourseInfo> cs = userCourseRelationService.getCourses(vo.getId());
+			if (CollectionUtils.isNotEmpty(cs)) {
+				vo.setCourseCodes(cs.stream().map(m -> m.getCode()).collect(Collectors.toList()));
+				vo.setCourseNames(cs.stream().map(m -> m.getCode() + "-" + m.getName()).collect(Collectors.toList()));
 			}
 		}
 		return vo;
 	}
-	
+
 }

+ 8 - 0
src/main/java/cn/com/qmth/mps/vo/paper/PaperGroupDomain.java

@@ -6,6 +6,8 @@ import cn.com.qmth.mps.bean.PaperGroupUnit;
 import io.swagger.annotations.ApiModelProperty;
 
 public class PaperGroupDomain {
+	@ApiModelProperty("分组ID")
+	private Long groupId;
 	@ApiModelProperty("试卷结构ID")
 	private Long paperId;
 	@ApiModelProperty("分组序号")
@@ -30,5 +32,11 @@ public class PaperGroupDomain {
 	public void setPaperId(Long paperId) {
 		this.paperId = paperId;
 	}
+	public Long getGroupId() {
+		return groupId;
+	}
+	public void setGroupId(Long groupId) {
+		this.groupId = groupId;
+	}
 	
 }

+ 10 - 1
src/main/java/cn/com/qmth/mps/vo/user/UserVo.java

@@ -3,6 +3,7 @@ package cn.com.qmth.mps.vo.user;
 import java.util.List;
 
 import cn.com.qmth.mps.entity.base.BaseEntity;
+import cn.com.qmth.mps.enums.Role;
 import io.swagger.annotations.ApiModelProperty;
 
 public class UserVo extends BaseEntity{
@@ -24,8 +25,10 @@ public class UserVo extends BaseEntity{
 	private Boolean enable;
 	@ApiModelProperty("角色名")
 	private String roleName;
-	@ApiModelProperty("角色")
+	@ApiModelProperty("角色ID")
 	private Long roleId;
+	@ApiModelProperty("角色编码")
+	private Role role;
 	@ApiModelProperty("科目代码集合")
 	private List<String> courseCodes;
 	@ApiModelProperty("科目名称集合")
@@ -90,5 +93,11 @@ public class UserVo extends BaseEntity{
 	public void setRoleName(String roleName) {
 		this.roleName = roleName;
 	}
+	public Role getRole() {
+		return role;
+	}
+	public void setRole(Role role) {
+		this.role = role;
+	}
 	
 }

+ 0 - 1
src/main/resources/application-test.properties

@@ -29,7 +29,6 @@ spring.jackson.time-zone=GMT+8
 
 session-timeout=7200
 
-mps-server=http://xxxxxxx
 wxapp-url=wxapp5.qmth.com.cn
 wxapp-appid=wx3564271a274bd400
 wxapp-secret=0bcbea00b9283890f3b6b0a672d5cda5

+ 0 - 1
src/main/resources/application.properties

@@ -29,7 +29,6 @@ spring.jackson.time-zone=GMT+8
 
 session-timeout=7200
 
-mps-server=http://192.168.10.39:7100
 wxapp-url=wxapp5.qmth.com.cn
 wxapp-appid=wx3564271a274bd400
 wxapp-secret=0bcbea00b9283890f3b6b0a672d5cda5