Kaynağa Gözat

feat:教师端点名优化

Joburgess 4 yıl önce
ebeveyn
işleme
f1873918fd

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

@@ -36,4 +36,13 @@ public interface SysUserContractsDao extends BaseDAO<Long, SysUserContracts> {
      * @return
      */
     SysUserContracts getLatestUserContract(Integer userId);
+
+    /**
+     * @describe 统计学员有效协议数量
+     * @author Joburgess
+     * @date 2021/4/1 0001
+     * @param userId:
+     * @return int
+     */
+    int countUserValidContact(Integer userId);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -84,6 +84,9 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 	private SysUserContractsService sysUserContractsService;
 
 	@Autowired
+	private SysUserContractsDao sysUserContractsDao;
+
+	@Autowired
 	private StudentRegistrationService studentRegistrationService;
 
 	@Autowired
@@ -1155,6 +1158,11 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 			return BaseController.failed("用户不存在");
 		}
 
+		int validContactNum = sysUserContractsDao.countUserValidContact(userId);
+		if(validContactNum>0){
+			return BaseController.succeed();
+		}
+
 		if(StringUtils.isBlank(user.getRealName())||StringUtils.isBlank(user.getIdCardNo())){
 			return BaseController.failed(HttpStatus.PARTIAL_CONTENT, user, "");
 		}

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

@@ -107,4 +107,9 @@
 				#{userId}
 			</foreach>
 	</select>
+	<select id="countUserValidContact" resultType="int">
+		SELECT COUNT(id_) FROM sys_user_contracts WHERE user_id_=#{userId} AND version_ IN (2,3)
+	</select>
+
+
 </mapper>