zouxuan 4 лет назад
Родитель
Сommit
6fc36bc023
16 измененных файлов с 953 добавлено и 2 удалено
  1. 43 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentCompetitionDao.java
  2. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserContractsDao.java
  3. 60 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentCompetitionRankingDto.java
  4. 208 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCompetition.java
  5. 112 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentCompetitionQueryInfo.java
  6. 42 0
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentCompetitionService.java
  7. 6 0
      mec-biz/src/main/java/com/ym/mec/biz/service/SysUserContractsService.java
  8. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  9. 114 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCompetitionServiceImpl.java
  10. 5 0
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserContractsServiceImpl.java
  11. 0 2
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  12. 183 0
      mec-biz/src/main/resources/config/mybatis/StudentCompetitionMapper.xml
  13. 4 0
      mec-biz/src/main/resources/config/mybatis/SysUserContractsMapper.xml
  14. 79 0
      mec-student/src/main/java/com/ym/mec/student/controller/StudentCompetitionController.java
  15. 50 0
      mec-web/src/main/java/com/ym/mec/web/controller/StudentCompetitionController.java
  16. 35 0
      mec-web/src/main/java/com/ym/mec/web/controller/SysUserContractsController.java

+ 43 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentCompetitionDao.java

@@ -0,0 +1,43 @@
+package com.ym.mec.biz.dal.dao;
+
+import com.ym.mec.biz.dal.entity.StudentCompetition;
+import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public interface StudentCompetitionDao extends BaseDAO<Long, StudentCompetition> {
+
+    List<StudentCompetition> queryStudentCompetitions(Map<String, Object> params);
+
+    int countStudentCompetitions(Map<String, Object> params);
+
+    /**
+     * @describe 获取指定用户的参赛作品
+     * @author Joburgess
+     * @date 2020.11.10
+     * @param userId:
+     * @return com.ym.mec.biz.dal.entity.StudentCompetition
+     */
+    StudentCompetition getCompetitionWithUser(@Param("userId") Integer userId);
+
+    /**
+     * @describe 获取获奖名单
+     * @author Joburgess
+     * @date 2020.11.10
+     * @return java.util.List<com.ym.mec.biz.dal.dto.StudentCompetitionRankingDto>
+     */
+    List<StudentCompetition> getWinnerList();
+
+    /**
+     * @describe 获取指定奖项级别的作品编号列表
+     * @author Joburgess
+     * @date 2020.11.10
+     * @param prizeLevel:
+     * @return java.util.Set<java.lang.Long>
+     */
+    Set<Long> getCompetitionsWithPrizeLevel(@Param("prizeLevel") Integer prizeLevel);
+
+}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysUserContractsDao.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.SysUserContracts;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -19,4 +20,10 @@ public interface SysUserContractsDao extends BaseDAO<Long, SysUserContracts> {
     List<SysUserContracts> getUserContractWithType(@Param("userId") Integer userId,
                                                    @Param("contractType") SysUserContracts.ContractType contractType);
 	
+    /**
+     * 获取最近一次的协议
+     * @param userId
+     * @return
+     */
+    SysUserContracts getLatestUserContract(Integer userId);
 }

+ 60 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentCompetitionRankingDto.java

@@ -0,0 +1,60 @@
+package com.ym.mec.biz.dal.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.11.10
+ */
+public class StudentCompetitionRankingDto {
+
+    private Long competitionId;
+
+    private Integer prizeLevel;
+
+    private String username;
+
+    private String pictureUrl;
+
+    public StudentCompetitionRankingDto() {
+    }
+
+    public StudentCompetitionRankingDto(Long competitionId, Integer prizeLevel, String username, String pictureUrl) {
+        this.competitionId = competitionId;
+        this.prizeLevel = prizeLevel;
+        this.username = username;
+        this.pictureUrl = pictureUrl;
+    }
+
+    public Integer getPrizeLevel() {
+        return prizeLevel;
+    }
+
+    public void setPrizeLevel(Integer prizeLevel) {
+        this.prizeLevel = prizeLevel;
+    }
+
+    public Long getCompetitionId() {
+        return competitionId;
+    }
+
+    public void setCompetitionId(Long competitionId) {
+        this.competitionId = competitionId;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPictureUrl() {
+        return pictureUrl;
+    }
+
+    public void setPictureUrl(String pictureUrl) {
+        this.pictureUrl = pictureUrl;
+    }
+}

+ 208 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentCompetition.java

@@ -0,0 +1,208 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(student_competition):
+ */
+public class StudentCompetition {
+
+	private Long id;
+
+	@ApiModelProperty(value = "用户编号")
+	private Integer userId;
+
+	@ApiModelProperty(value = "姓名")
+	private String username;
+
+	@ApiModelProperty(value = "身份证号")
+	private String idCardNo;
+
+	@ApiModelProperty(value = "年龄")
+	private Integer age;
+
+	@ApiModelProperty(value = "性别")
+	private Boolean gender;
+
+	@ApiModelProperty(value = "年级")
+	private String grade;
+
+	@ApiModelProperty(value = "专业")
+	private String subject;
+
+	@ApiModelProperty(value = "曲目")
+	private String chapter;
+
+	@ApiModelProperty(value = "头像")
+	private String pictureUrl;
+
+	@ApiModelProperty(value = "作品")
+	private String videoUrl;
+
+	@ApiModelProperty(value = "分数")
+	private java.math.BigDecimal score;
+
+	@ApiModelProperty(value = "获奖等级")
+	private Integer prizeLevel;
+
+	@ApiModelProperty(value = "是否展示")
+	private Boolean isShow;
+
+	@ApiModelProperty(value = "评价")
+	private String comment;
+
+	private java.util.Date createTime;
+
+	private java.util.Date updateTime;
+	
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setUserId(Integer userId){
+		this.userId = userId;
+	}
+	
+	public Integer getUserId(){
+		return this.userId;
+	}
+			
+	public void setUsername(String username){
+		this.username = username;
+	}
+	
+	public String getUsername(){
+		return this.username;
+	}
+			
+	public void setIdCardNo(String idCardNo){
+		this.idCardNo = idCardNo;
+	}
+	
+	public String getIdCardNo(){
+		return this.idCardNo;
+	}
+			
+	public void setAge(Integer age){
+		this.age = age;
+	}
+	
+	public Integer getAge(){
+		return this.age;
+	}
+
+	public Boolean getGender() {
+		return gender;
+	}
+
+	public void setGender(Boolean gender) {
+		this.gender = gender;
+	}
+
+	public void setGrade(String grade){
+		this.grade = grade;
+	}
+	
+	public String getGrade(){
+		return this.grade;
+	}
+			
+	public void setSubject(String subject){
+		this.subject = subject;
+	}
+	
+	public String getSubject(){
+		return this.subject;
+	}
+			
+	public void setChapter(String chapter){
+		this.chapter = chapter;
+	}
+	
+	public String getChapter(){
+		return this.chapter;
+	}
+			
+	public void setPictureUrl(String pictureUrl){
+		this.pictureUrl = pictureUrl;
+	}
+	
+	public String getPictureUrl(){
+		return this.pictureUrl;
+	}
+
+	public String getVideoUrl() {
+		return videoUrl;
+	}
+
+	public void setVideoUrl(String videoUrl) {
+		this.videoUrl = videoUrl;
+	}
+
+	public boolean isShow() {
+		return isShow;
+	}
+
+	public void setShow(boolean show) {
+		isShow = show;
+	}
+
+	public void setScore(java.math.BigDecimal score){
+		this.score = score;
+	}
+	
+	public java.math.BigDecimal getScore(){
+		return this.score;
+	}
+
+	public Integer getPrizeLevel() {
+		return prizeLevel;
+	}
+
+	public void setPrizeLevel(Integer prizeLevel) {
+		this.prizeLevel = prizeLevel;
+	}
+
+	public Boolean getIsShow() {
+		return isShow;
+	}
+
+	public void setIsShow(Boolean show) {
+		isShow = show;
+	}
+
+	public void setComment(String comment){
+		this.comment = comment;
+	}
+	
+	public String getComment(){
+		return this.comment;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 112 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentCompetitionQueryInfo.java

@@ -0,0 +1,112 @@
+package com.ym.mec.biz.dal.page;
+
+import com.sun.org.apache.xpath.internal.operations.Bool;
+import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.11.10
+ */
+public class StudentCompetitionQueryInfo extends QueryInfo {
+
+    @ApiModelProperty(value = "性别")
+    private Boolean gender;
+
+    @ApiModelProperty(value = "年级")
+    private String grade;
+
+    @ApiModelProperty(value = "专业")
+    private String subject;
+
+    @ApiModelProperty(value = "分数")
+    private BigDecimal score;
+
+    @ApiModelProperty(value = "获奖等级")
+    private Integer prizeLevel;
+
+    @ApiModelProperty(value = "是否展示")
+    private Boolean isShow;
+
+    @ApiModelProperty(value = "评价")
+    private String comment;
+
+    private Date createTime;
+
+    private Integer isReview;
+
+    public Integer getIsReview() {
+        return isReview;
+    }
+
+    public void setIsReview(Integer isReview) {
+        this.isReview = isReview;
+    }
+
+    public Boolean getGender() {
+        return gender;
+    }
+
+    public void setGender(Boolean gender) {
+        this.gender = gender;
+    }
+
+    public Boolean getIsShow() {
+        return isShow;
+    }
+
+    public void setIsShow(Boolean show) {
+        isShow = show;
+    }
+
+    public String getGrade() {
+        return grade;
+    }
+
+    public void setGrade(String grade) {
+        this.grade = grade;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+    public BigDecimal getScore() {
+        return score;
+    }
+
+    public void setScore(BigDecimal score) {
+        this.score = score;
+    }
+
+    public Integer getPrizeLevel() {
+        return prizeLevel;
+    }
+
+    public void setPrizeLevel(Integer prizeLevel) {
+        this.prizeLevel = prizeLevel;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 42 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentCompetitionService.java

@@ -0,0 +1,42 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.dto.StudentCompetitionRankingDto;
+import com.ym.mec.biz.dal.entity.StudentCompetition;
+import com.ym.mec.biz.dal.page.StudentCompetitionQueryInfo;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.BaseService;
+
+import java.util.List;
+
+public interface StudentCompetitionService extends BaseService<Long, StudentCompetition> {
+
+    /**
+     * @describe 新增选手参赛作品
+     * @author Joburgess
+     * @date 2020.11.10
+     * @param studentCompetition:
+     * @return void
+     */
+    void addStudentCompetition(StudentCompetition studentCompetition);
+
+    PageInfo<StudentCompetition> queryPage(StudentCompetitionQueryInfo queryInfo);
+
+    /**
+     * @describe
+     * @author Joburgess
+     * @date 2020.11.10
+     * @return void
+     */
+    List<StudentCompetitionRankingDto> getWinnerList();
+
+    StudentCompetition checkIsUpload(Integer userId);
+
+    /**
+     * @describe 更新参赛作品信息
+     * @author Joburgess
+     * @date 2020.11.10
+     * @param studentCompetition:
+     * @return void
+     */
+    void updateCompetition(StudentCompetition studentCompetition);
+}

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysUserContractsService.java

@@ -17,4 +17,10 @@ public interface SysUserContractsService extends BaseService<Long, SysUserContra
      */
     List<SysUserContracts> getUserContractWithType(Integer userId, SysUserContracts.ContractType contractType);
 
+    /**
+     * 获取最近一次的协议
+     * @param userId
+     * @return
+     */
+    SysUserContracts getLatestUserContract(Integer userId);
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -2706,6 +2706,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         if(groupType == VIP){
 			VipGroup vipGroup = vipGroupDao.get(vipGroupCourseAdjustInfo.getVipGroupId().longValue());
 
+			CourseSchedule courseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
+			if(courseSchedule.getEndClassTime().compareTo(vipGroup.getCoursesExpireDate())>0){
+				throw new BizException("调整失败:课程时间超过课程有效期");
+			}
+
 			BigDecimal teacherSalary=BigDecimal.ZERO;
 
 			Map<String, BigDecimal> salaryMap = vipGroupService.countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);

+ 114 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCompetitionServiceImpl.java

@@ -0,0 +1,114 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dto.StudentCompetitionRankingDto;
+import com.ym.mec.biz.dal.page.StudentCompetitionQueryInfo;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.ym.mec.biz.dal.entity.StudentCompetition;
+import com.ym.mec.biz.service.StudentCompetitionService;
+import com.ym.mec.biz.dal.dao.StudentCompetitionDao;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+@Service
+public class StudentCompetitionServiceImpl extends BaseServiceImpl<Long, StudentCompetition> implements StudentCompetitionService {
+	
+	@Autowired
+	private StudentCompetitionDao studentCompetitionDao;
+
+	@Override
+	public BaseDAO<Long, StudentCompetition> getDAO() {
+		return studentCompetitionDao;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+	public void addStudentCompetition(StudentCompetition studentCompetition) {
+		StudentCompetition userCompetition = studentCompetitionDao.getCompetitionWithUser(studentCompetition.getUserId());
+		if(Objects.nonNull(userCompetition)){
+			throw new BizException("您已有正在审核中的参赛作品");
+		}
+		if(StringUtils.isBlank(studentCompetition.getSubject())){
+			throw new BizException("请选择参赛专业");
+		}
+		if(StringUtils.isBlank(studentCompetition.getChapter())){
+			throw new BizException("请选择参赛曲目");
+		}
+		if(StringUtils.isBlank(studentCompetition.getVideoUrl())){
+			throw new BizException("请指定参赛作品");
+		}
+		studentCompetition.setIsShow(false);
+		studentCompetitionDao.insert(studentCompetition);
+	}
+
+	@Override
+	public PageInfo<StudentCompetition> queryPage(StudentCompetitionQueryInfo queryInfo) {
+		PageInfo<StudentCompetition> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<StudentCompetition> dataList = null;
+		int count = studentCompetitionDao.countStudentCompetitions(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = studentCompetitionDao.queryStudentCompetitions(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+	public StudentCompetition checkIsUpload(Integer userId) {
+		return studentCompetitionDao.getCompetitionWithUser(userId);
+	}
+
+	@Override
+	public List<StudentCompetitionRankingDto> getWinnerList() {
+		List<StudentCompetition> winnerList = studentCompetitionDao.getWinnerList();
+		List<StudentCompetitionRankingDto> winnerSimpleInfoList = new ArrayList<>();
+		for (StudentCompetition studentCompetition : winnerList) {
+			winnerSimpleInfoList.add(new StudentCompetitionRankingDto(studentCompetition.getId(), studentCompetition.getPrizeLevel(), studentCompetition.getUsername(), studentCompetition.getPictureUrl()));
+		}
+		return winnerSimpleInfoList;
+	}
+
+	@Override
+	public void updateCompetition(StudentCompetition studentCompetition) {
+		if(Objects.nonNull(studentCompetition.getPrizeLevel())&&studentCompetition.getPrizeLevel()>0){
+			Set<Long> competitionsWithPrizeLevel = studentCompetitionDao.getCompetitionsWithPrizeLevel(studentCompetition.getPrizeLevel());
+			int maxPrizeLevelUserNum = 0;
+			switch (studentCompetition.getPrizeLevel()){
+				case 1:
+					maxPrizeLevelUserNum = 1;
+					break;
+				case 2:
+				case 3:
+					maxPrizeLevelUserNum = 12;
+					break;
+				case 4:
+					maxPrizeLevelUserNum = 24;
+					break;
+				case 5:
+					maxPrizeLevelUserNum = 50;
+					break;
+			}
+			if(competitionsWithPrizeLevel.size()>=maxPrizeLevelUserNum&&!competitionsWithPrizeLevel.contains(studentCompetition.getId())){
+				throw new BizException("该奖项名额已达上线");
+			}
+		}
+		studentCompetitionDao.update(studentCompetition);
+	}
+}

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserContractsServiceImpl.java

@@ -26,5 +26,10 @@ public class SysUserContractsServiceImpl extends BaseServiceImpl<Long, SysUserCo
 	public List<SysUserContracts> getUserContractWithType(Integer userId, SysUserContracts.ContractType contractType) {
 		return sysUserContractsDao.getUserContractWithType(userId, contractType);
 	}
+
+	@Override
+	public SysUserContracts getLatestUserContract(Integer userId) {
+		return sysUserContractsDao.getLatestUserContract(userId);
+	}
 	
 }

+ 0 - 2
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -185,11 +185,9 @@
             course_schedule_student_payment cssp
             LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
             LEFT JOIN student_attendance sa ON cssp.course_schedule_id_ = sa.course_schedule_id_ AND cssp.user_id_ = sa.user_id_
-            LEFT JOIN class_group_student_mapper cgsm ON cssp.user_id_=cgsm.user_id_ AND cssp.class_group_id_=cgsm.class_group_id_
         WHERE
             cssp.course_schedule_id_ =#{courseScheduleId}
             AND su.id_ IS NOT NULL
-            AND cgsm.status_!='QUIT'
     </select>
 
     <select id="findStudentByCourseWithPage" resultMap="com.ym.mec.biz.dal.dao.StudentAttendanceDao.studentAttendanceViewUtilEntity">

+ 183 - 0
mec-biz/src/main/resources/config/mybatis/StudentCompetitionMapper.xml

@@ -0,0 +1,183 @@
+<?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="com.ym.mec.biz.dal.dao.StudentCompetitionDao">
+
+	<resultMap type="com.ym.mec.biz.dal.entity.StudentCompetition" id="StudentCompetition">
+		<result column="id_" property="id" />
+		<result column="user_id_" property="userId" />
+		<result column="username_" property="username" />
+		<result column="id_card_no_" property="idCardNo" />
+		<result column="age_" property="age" />
+		<result column="gender_" property="gender" />
+		<result column="grade_" property="grade" />
+		<result column="subject_" property="subject" />
+		<result column="chapter_" property="chapter" />
+		<result column="picture_url_" property="pictureUrl" />
+		<result column="video_url_" property="videoUrl" />
+		<result column="score_" property="score" />
+		<result column="prize_level_" property="prizeLevel" />
+		<result column="is_show_" property="isShow" />
+		<result column="comment_" property="comment" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="StudentCompetition" >
+		SELECT * FROM student_competition WHERE id_ = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="StudentCompetition">
+		SELECT * FROM student_competition ORDER BY id_
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentCompetition" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!--
+		<selectKey resultClass="int" keyProperty="id" >
+		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
+		</selectKey>
+		-->
+		INSERT INTO student_competition (id_,user_id_,username_,id_card_no_,age_,gender_,grade_,subject_,chapter_,picture_url_,video_url_,score_,prize_level_,is_show_,comment_,create_time_,update_time_)
+		VALUES(#{id},#{userId},#{username},#{idCardNo},#{age},#{gender},#{grade},#{subject},#{chapter},#{pictureUrl},#{videoUrl},#{score},#{prizeLevel},#{isShow},#{comment},NOW(),NOW())
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.StudentCompetition">
+		UPDATE student_competition <set>
+		<if test="isShow != null">
+			is_show_ = #{isShow},
+		</if>
+		<if test="id != null">
+			id_ = #{id},
+		</if>
+		<if test="gender != null">
+			gender_ = #{gender},
+		</if>
+		<if test="score != null">
+			score_ = #{score},
+		</if>
+		<if test="prizeLevel != null">
+			prize_level_ = #{prizeLevel},
+		</if>
+		<if test="age != null">
+			age_ = #{age},
+		</if>
+		<if test="videoUrl != null">
+			video_url_ = #{videoUrl},
+		</if>
+		<if test="username != null">
+			username_ = #{username},
+		</if>
+		<if test="chapter != null">
+			chapter_ = #{chapter},
+		</if>
+		<if test="userId != null">
+			user_id_ = #{userId},
+		</if>
+		<if test="subject != null">
+			subject_ = #{subject},
+		</if>
+		<if test="comment != null">
+			comment_ = #{comment},
+		</if>
+		<if test="pictureUrl != null">
+			picture_url_ = #{pictureUrl},
+		</if>
+		<if test="idCardNo != null">
+			id_card_no_ = #{idCardNo},
+		</if>
+		<if test="grade != null">
+			grade_ = #{grade},
+		</if>
+		update_time_ = NOW()
+	</set> WHERE id_ = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM student_competition WHERE id_ = #{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="StudentCompetition" parameterType="map">
+		SELECT * FROM student_competition ORDER BY id_ <include refid="global.limit"/>
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM student_competition
+	</select>
+
+	<sql id="queryStudentCondition">
+		<where>
+			<if test="grade!=null">
+				AND grade_=#{grade}
+			</if>
+			<if test="gender!=null">
+				AND gender_=#{gender}
+			</if>
+			<if test="subject != null and subject != ''">
+				AND subject_=#{subject}
+			</if>
+			<if test="prizeLevel!=null">
+				AND prize_level_=#{prizeLevel}
+			</if>
+			<if test="isShow!=null">
+				AND is_show_=#{isShow}
+			</if>
+			<if test="isReview!=null and isReview==0">
+				AND score_ IS NULL
+			</if>
+			<if test="isReview!=null and isReview==1">
+				AND score_ IS NOT NULL
+			</if>
+			<if test="search!=null and search!=''">
+				AND (CAST(age_ AS CHAR)=#{search} OR CAST(user_id_ AS CHAR)=#{search} OR username_ LIKE CONCAT('%', #{search}, '%') OR id_card_no_ LIKE CONCAT('%', #{search}, '%'))
+			</if>
+		</where>
+	</sql>
+
+	<select id="queryStudentCompetitions" resultMap="StudentCompetition">
+		SELECT
+		id_,
+		user_id_,
+		username_,
+		id_card_no_,
+		age_,
+		gender_,
+		grade_,
+		subject_,
+		chapter_,
+		picture_url_,
+		video_url_,
+		CASE WHEN score_ IS NULL THEN -1 ELSE score_ END score_,
+		CASE WHEN prize_level_ IS NULL THEN -1 ELSE prize_level_ END prize_level_,
+		is_show_,
+		comment_,
+		create_time_,
+		update_time_
+		FROM student_competition
+		<include refid="queryStudentCondition"/>
+		ORDER BY id_ DESC
+		<include refid="global.limit"/>
+	</select>
+	<select id="countStudentCompetitions" resultType="int">
+		SELECT COUNT(*) FROM student_competition
+		<include refid="queryStudentCondition"/>
+	</select>
+
+	<select id="getWinnerList" resultMap="StudentCompetition">
+		SELECT * FROM student_competition WHERE is_show_ = 1
+		ORDER BY ISNULL(score_),score_ DESC
+	</select>
+
+	<select id="getCompetitionWithUser" resultMap="StudentCompetition">
+		SELECT * FROM student_competition WHERE user_id_ = #{userId}
+	</select>
+
+	<select id="getCompetitionsWithPrizeLevel" resultType="long">
+		SELECT id_ FROM student_competition WHERE prize_level_ = #{prizeLevel} FOR UPDATE
+	</select>
+</mapper>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/SysUserContractsMapper.xml

@@ -87,4 +87,8 @@
 	<select id="getUserContractWithType" resultMap="SysUserContracts">
 		SELECT * FROM sys_user_contracts WHERE user_id_=#{userId} AND type_=#{contractType}
 	</select>
+
+	<select id="getLatestUserContract" resultMap="SysUserContracts">
+		SELECT * FROM sys_user_contracts WHERE user_id_=#{userId} order by id_ desc limit 0,1
+	</select>
 </mapper>

+ 79 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentCompetitionController.java

@@ -0,0 +1,79 @@
+package com.ym.mec.student.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.StudentCompetitionRankingDto;
+import com.ym.mec.biz.dal.entity.StudentCompetition;
+import com.ym.mec.biz.service.ContractService;
+import com.ym.mec.biz.service.StudentCompetitionService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.11.10
+ */
+@RestController
+@RequestMapping("studentCompetition")
+@Api(tags = "长三角比赛服务")
+public class StudentCompetitionController extends BaseController {
+
+    @Autowired
+    private StudentCompetitionService studentCompetitionService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private ContractService contractService;
+
+    @ApiOperation(value = "新增参赛作品")
+    @PostMapping("/add")
+    public HttpResponseResult add(@RequestBody StudentCompetition studentCompetition){
+        if(StringUtils.isBlank(studentCompetition.getUsername())||StringUtils.isBlank(studentCompetition.getIdCardNo())){
+            return failed("参赛选手身份信息不完整");
+        }
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("请登录");
+        }
+        contractService.register(sysUser.getId(), studentCompetition.getUsername(), studentCompetition.getIdCardNo(),sysUser.getPhone());
+        studentCompetition.setUserId(sysUser.getId());
+        studentCompetitionService.addStudentCompetition(studentCompetition);
+        return succeed();
+    }
+
+    @ApiOperation(value = "检测学生是否已有上传作品")
+    @GetMapping("/checkIsUpload")
+    public HttpResponseResult<StudentCompetition> checkIsUpload(){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("请登录");
+        }
+        return succeed(studentCompetitionService.checkIsUpload(sysUser.getId()));
+    }
+
+    @ApiOperation(value = "获取获奖名单")
+    @GetMapping("/getWinnerList")
+    public HttpResponseResult<List<StudentCompetitionRankingDto>> getWinnerList(){
+        return succeed(studentCompetitionService.getWinnerList());
+    }
+
+    @ApiOperation(value = "获取指定参赛作品详情")
+    @GetMapping("/get")
+    public HttpResponseResult<StudentCompetition> get(Long competitionId){
+        StudentCompetition studentCompetition = studentCompetitionService.get(competitionId);
+        if(Objects.isNull(studentCompetition)||!studentCompetition.isShow()){
+            return succeed();
+        }
+        return succeed(studentCompetition);
+    }
+
+}

+ 50 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentCompetitionController.java

@@ -0,0 +1,50 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.biz.dal.entity.StudentCompetition;
+import com.ym.mec.biz.dal.page.StudentCompetitionQueryInfo;
+import com.ym.mec.biz.service.StudentCompetitionService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Objects;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.11.10
+ */
+@RestController
+@RequestMapping("studentCompetition")
+@Api(tags = "长三角比赛服务")
+public class StudentCompetitionController extends BaseController {
+
+    @Autowired
+    private StudentCompetitionService studentCompetitionService;
+
+    @ApiOperation(value = "查询报名记录")
+    @PostMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('studentCompetition/queryPage')")
+    public HttpResponseResult<PageInfo<StudentCompetition>> queryPage(@RequestBody StudentCompetitionQueryInfo queryInfo){
+        return succeed(studentCompetitionService.queryPage(queryInfo));
+    }
+    @ApiOperation(value = "更新报名记录")
+    @PostMapping("/update")
+    @PreAuthorize("@pcs.hasPermissions('studentCompetition/update')")
+    public HttpResponseResult update(@RequestBody StudentCompetition studentCompetition){
+        if(Objects.isNull(studentCompetition.getId())){
+            throw new BizException("请指定参赛作品");
+        }
+        studentCompetitionService.updateCompetition(studentCompetition);
+        return succeed();
+    }
+
+}

+ 35 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SysUserContractsController.java

@@ -0,0 +1,35 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.entity.SysUserContracts;
+import com.ym.mec.biz.service.SysUserContractsService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.entity.HttpResponseResult;
+
+@RequestMapping("sysUserContracts")
+@Api(tags = "用户协议服务")
+@RestController
+public class SysUserContractsController extends BaseController {
+
+	@Autowired
+	private SysUserContractsService sysUserContractsService;
+	
+	@GetMapping("/getLatest")
+	public HttpResponseResult<SysUserContracts> getLatest(Integer userId) {
+		
+		SysUserContracts sysUserContracts = sysUserContractsService.getLatestUserContract(userId);
+		
+		if(sysUserContracts == null){
+			return failed("该学员尚未签署协议");
+		}
+
+		return succeed(sysUserContracts);
+	}
+
+}