Ver Fonte

fix 合并

he2802 há 3 anos atrás
pai
commit
ce99761eb8

+ 40 - 12
run-pre.sh

@@ -1,17 +1,50 @@
-<<<<<<< HEAD
+#!/usr/bin/env bash
+# 定义应用组名
+group_name='zhongzheng'
+# 定义应用名称
+app_name='zhongzheng-saas-api-pre'
+# 定义应用版本
+app_version='1.0-SNAPSHOT'
+# 定义应用环境
+profile_active='pre'
+echo '----copy jar----'
+docker stop ${app_name}
+echo '----stop container----'
+docker rm ${app_name}
+echo '----rm container----'
+docker rmi ${group_name}/${app_name}:${app_version}
+echo '----rm image----'
+# 打包编译docker镜像
+docker build -f /mydata-pre/maven/build/Dockerfile -t ${group_name}/${app_name}:${app_version} .
+echo '----build image----'
+docker run -p 6055:5055 --name ${app_name} \
+--restart=always \
+--link mysql:db \
+-e 'spring.profiles.active'=${profile_active} \
+-e TZ="Asia/Shanghai" \
+-v /etc/localtime:/etc/localtime \
+-v /usr/share/fonts:/usr/share/fonts \
+-v /mydata-pre/app/${app_name}/logs:/var/logs \
+-d ${group_name}/${app_name}:${app_version}
+echo '----start container----'
+
+echo "开始等待20秒..."
+# 1-10秒内随机
+sleep 5
+echo "等待后继续"
 
 #!/usr/bin/env bash
 # 定义应用组名
 group_admin_name='zhongzheng'
 # 定义应用名称
 app_admin_name='zhongzheng-saas-pre'
-=======
+
 #!/usr/bin/env bash
 # 定义应用组名
 group_admin_name='zhongzheng-pre'
 # 定义应用名称
 app_admin_name='zhongzheng-saas-admin-pre'
->>>>>>> pre
+
 # 定义应用版本
 app_admin_version='1.0-SNAPSHOT'
 # 定义应用环境
@@ -24,11 +57,9 @@ echo '----rm container admin----'
 docker rmi ${group_admin_name}/${app_admin_name}:${app_admin_version}
 echo '----rm image admin----'
 # 打包编译docker镜像
-<<<<<<< HEAD
-docker build -f /mydata/maven/build/Dockerfile-admi -t ${group_admin_name}/${app_admin_name}:${app_admin_version} .
-=======
+
 docker build -f /mydata-pre/maven/build/Dockerfile-admi -t ${group_admin_name}/${app_admin_name}:${app_admin_version} .
->>>>>>> pre
+
 echo '----build image admin----'
 docker run \
 -p 6030:5030 \
@@ -38,13 +69,10 @@ docker run \
 -e 'spring.profiles.active'=${profile_active} \
 -e TZ="Asia/Shanghai" \
 -v /etc/localtime:/etc/localtime \
-<<<<<<< HEAD
--v /usr/local/temp/fonts:/usr/share/fonts \
--v /mydata/app/${app_admin_name}/logs:/var/logs \
-=======
+
 -v /usr/share/fonts:/usr/share/fonts \
 -v /mydata-pre/app/${app_admin_name}/logs:/var/logs \
->>>>>>> pre
+
 -d ${group_admin_name}/${app_admin_name}:${app_admin_version}
 echo '----start container admin----'
 

+ 7 - 1
zhongzheng-api/src/main/java/com/zhongzheng/controller/exam/ExamBeforeController.java

@@ -5,6 +5,8 @@ import com.zhongzheng.common.core.controller.BaseController;
 import com.zhongzheng.common.core.domain.AjaxResult;
 import com.zhongzheng.common.core.page.TableDataInfo;
 import com.zhongzheng.common.enums.BusinessType;
+import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.framework.web.service.WxTokenService;
 import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.service.IExamBeforeGoodsService;
 import com.zhongzheng.modules.exam.service.IExamBeforeService;
@@ -12,6 +14,7 @@ import com.zhongzheng.modules.exam.service.IExamBeforeUrlService;
 import com.zhongzheng.modules.exam.vo.ExamBeforeUrlVo;
 import com.zhongzheng.modules.exam.vo.ExamBeforeVo;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
+import com.zhongzheng.modules.user.entity.ClientLoginUser;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -23,7 +26,7 @@ import java.util.List;
 
 /**
  * 前培安排Controller
- * 
+ *
  * @author ruoyi
  * @date 2021-12-07
  */
@@ -36,6 +39,7 @@ public class ExamBeforeController extends BaseController {
     private final IExamBeforeService iExamBeforeService;
     private final IExamBeforeUrlService iExamBeforeUrlService;
     private final IExamBeforeGoodsService iExamBeforeGoodsService;
+    private final WxTokenService wxTokenService;
 
     /**
      * 获取前培安排详细信息
@@ -43,6 +47,8 @@ public class ExamBeforeController extends BaseController {
     @ApiOperation("获得刷题地址")
     @GetMapping("/address")
     public AjaxResult<ExamBeforeVo> getAddressInfo(ExamBeforeQueryBo examBeforeQueryBo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        examBeforeQueryBo.setUserId(loginUser.getUser().getUserId());
         return AjaxResult.success(iExamBeforeService.getAddressInfo(examBeforeQueryBo));
     }
 }

+ 11 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/CertificateTpServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.google.zxing.BarcodeFormat;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.qrcode.QRCodeWriter;
+import com.zhongzheng.common.core.redis.RedisCache;
 import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
@@ -54,6 +55,7 @@ import java.awt.image.BufferedImage;
 import java.io.*;
 import java.util.*;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 /**
@@ -78,6 +80,9 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
     @Autowired
     private IUserStudyRecordService iUserStudyRecordService;
 
+    @Autowired
+    private RedisCache redisCache;
+
 
     @Value("${certificate.host}")
     private String CERTIFICATE_HOST;
@@ -144,6 +149,12 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
      */
     @Override
     public String makeCertificatePhoto(ClassGradeUserQueryBo bo) {
+        String key = "Certificate-"+bo.getGoodsId()+"-"+bo.getUserId();
+        Long value = redisCache.getCacheObject(key);
+        if(Validator.isNotEmpty(value)){
+            return "";
+        }
+        redisCache.setCacheObject(key,1L,1, TimeUnit.MINUTES);//1分钟
         if(Validator.isEmpty(bo.getUserId())||Validator.isEmpty(bo.getGradeId())||Validator.isEmpty(bo.getGoodsId())){
             throw new CustomException("数据错误");
         }
@@ -159,8 +170,6 @@ public class CertificateTpServiceImpl extends ServiceImpl<CertificateTpMapper, C
         //获取章列表
         List<CourseChapterVo> chapterList =  iClassGradeUserService.findChapterList(bo);
         UserVo userVo = iUserService.queryById(bo.getUserId());
-        System.out.println("培训开始时间");
-        System.out.println(studyRecordVo.getFirstStartTime());
         if(Validator.isNotEmpty(goodsVo.getCertificateIds())){
             String[] s = goodsVo.getCertificateIds().split(",");
             List<Long> tpIds = new ArrayList<>();

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/bo/ExamBeforeQueryBo.java

@@ -64,4 +64,6 @@ public class ExamBeforeQueryBo extends BaseEntity {
 	/** 1启用 0未启用 -1删除 2过期 */
 	@ApiModelProperty("1启用 0未启用 -1删除 2过期")
 	private List<Integer> status;
+	@ApiModelProperty("用户ID")
+	private Long userId;
 }

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamBeforeMapper.java

@@ -29,7 +29,7 @@ public interface ExamBeforeMapper extends BaseMapper<ExamBefore> {
 
     Integer beforeGoods(Long beforeId);
 
-    Long verifyInfo(Long goodsId);
+    Long verifyInfo(ExamBeforeQueryBo examBeforeQueryBo);
 
     ExamBeforeVo verifyExamBeforeVo(ExamBeforeQueryBo examBeforeQueryBo);
 

+ 21 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -1,12 +1,15 @@
 package com.zhongzheng.modules.exam.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
+import com.zhongzheng.modules.course.domain.Course;
 import com.zhongzheng.modules.exam.bo.*;
 import com.zhongzheng.modules.exam.domain.ExamBefore;
 import com.zhongzheng.modules.exam.vo.*;
@@ -144,6 +147,9 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
      */
     private void validEntityBeforeSave(ExamApply entity){
         //TODO 做一些数据校验,如唯一约束
+        if(checkNameUnique(entity)){
+            throw new CustomException("名称重复");
+        }
     }
 
     @Override
@@ -276,4 +282,19 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         }
         return examUserApplySiteVos;
     }
+
+    private boolean checkNameUnique(ExamApply entity) {
+        ExamApply info = getOne(new LambdaQueryWrapper<ExamApply>()
+                .eq(ExamApply::getApplyName,entity.getApplyName()).ne(ExamApply::getStatus,-1).last("limit 1"));
+        if (Validator.isNotNull(info)) {
+            if(Validator.isNotEmpty(entity.getApplyId())){
+                if(entity.getApplyId().longValue() != info.getApplyId().longValue()){
+                    return true;
+                }
+            }else{
+                return true;
+            }
+        }
+        return false;
+    }
 }

+ 22 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamBeforeServiceImpl.java

@@ -1,12 +1,15 @@
 package com.zhongzheng.modules.exam.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.zhongzheng.common.exception.CustomException;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.modules.collect.domain.CollectBank;
 import com.zhongzheng.modules.exam.bo.*;
+import com.zhongzheng.modules.exam.domain.ExamApply;
 import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -133,6 +136,9 @@ public class ExamBeforeServiceImpl extends ServiceImpl<ExamBeforeMapper, ExamBef
      */
     private void validEntityBeforeSave(ExamBefore entity){
         //TODO 做一些数据校验,如唯一约束
+        if(checkNameUnique(entity)){
+            throw new CustomException("名称重复");
+        }
     }
 
     @Override
@@ -166,11 +172,26 @@ public class ExamBeforeServiceImpl extends ServiceImpl<ExamBeforeMapper, ExamBef
     @Override
     public ExamBeforeVo getAddressInfo(ExamBeforeQueryBo examBeforeQueryBo) {
         //查询该商品是否有前培设置
-        Long verLong = baseMapper.verifyInfo(examBeforeQueryBo.getGoodsId());
+        Long verLong = baseMapper.verifyInfo(examBeforeQueryBo);
         if (verLong < 1){
             throw new IllegalArgumentException("您不符合考前刷题条件,请先预约考试,或者咨询相关工作人员,了解使用条件。");
         }
         ExamBeforeVo examBeforeVo = baseMapper.verifyExamBeforeVo(examBeforeQueryBo);
         return examBeforeVo;
     }
+
+    private boolean checkNameUnique(ExamBefore entity) {
+        ExamBefore info = getOne(new LambdaQueryWrapper<ExamBefore>()
+                .eq(ExamBefore::getBeforeName,entity.getBeforeName()).ne(ExamBefore::getStatus,-1).last("limit 1"));
+        if (Validator.isNotNull(info)) {
+            if(Validator.isNotEmpty(entity.getBeforeId())){
+                if(entity.getBeforeId().longValue() != info.getBeforeId().longValue()){
+                    return true;
+                }
+            }else{
+                return true;
+            }
+        }
+        return false;
+    }
 }

+ 3 - 3
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/impl/UserSubscribeServiceImpl.java

@@ -626,7 +626,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
 
             String goodsName = baseMapper.selectGoodsName(userSubscribeImport.getCode());
             if (!goodsName.equals(userSubscribeImport.getGoodsName())) {
-                userSubscribeImport.setCause("商品名称错误");
+                userSubscribeImport.setCause("商品名称跟编码不匹配");
                 userSubscribeImports.add(userSubscribeImport);
                 continue;
             }
@@ -866,7 +866,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
 
             String goodsName = baseMapper.selectGoodsName(userSubscribeImport.getCode());
             if (!goodsName.equals(userSubscribeImport.getGoodsName())) {
-                userSubscribeImport.setCause("商品名称错误");
+                userSubscribeImport.setCause("商品名称跟编码不匹配");
                 userSubscribeImports.add(userSubscribeImport);
                 continue;
             }
@@ -1184,7 +1184,7 @@ public class UserSubscribeServiceImpl extends ServiceImpl<UserSubscribeMapper, U
 
             String goodsName = baseMapper.selectGoodsName(userSubscribeImport.getCode());
             if (!goodsName.equals(userSubscribeImport.getGoodsName())) {
-                userSubscribeImport.setCause("商品名称错误");
+                userSubscribeImport.setCause("商品名称跟编码不匹配");
                 userSubscribeImports.add(userSubscribeImport);
                 continue;
             }

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamBeforeMapper.xml

@@ -134,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND us.goods_id = #{goodsId}
           AND us.exam_status = 0
           AND us.subscribe_status = 1
+          AND us.user_id = #{userId}
           AND us.before_status =1
     </select>