Compare commits

..

45 Commits

Author SHA1 Message Date
zcx e8fe589d02 vip查询 2023-10-23 11:43:01 +08:00
zcx c4692e2d75 vip查询 2023-10-18 17:34:43 +08:00
zcx 74d8f55541 登录新增参数 2023-10-17 14:47:42 +08:00
caolin df4345f34c 数据库配置 2023-09-17 22:53:57 +08:00
caolin 62b2bf95aa 数据库配置 2023-09-17 22:48:16 +08:00
caolin 336cd37581 增加支付商品 2023-09-17 18:16:20 +08:00
caolin 0bcb6a611d redis配置更改 2023-09-15 15:27:16 +08:00
caolin 24a767c216 答题技巧 2023-09-14 12:12:46 +08:00
caolin a5fd57993e 答题技巧 2023-09-14 12:00:04 +08:00
caolin 30fd69726c 单点登陆 2023-09-12 23:48:23 +08:00
caolin e3158205b0 单点登陆 2023-09-12 13:26:07 +08:00
caolin 8926ac4236 单点登陆 2023-09-11 01:11:34 +08:00
caolin 86f663e55f 错题分类优化 2023-09-04 14:40:27 +08:00
caolin 75763435ba 优化 2023-09-03 23:44:18 +08:00
caolin 51361ad1ed 优化 2023-09-03 22:38:58 +08:00
caolin 70f899ca5f 错题列表 2023-09-01 00:50:00 +08:00
caolin 2d529ec4b8 获取专项题目数量 2023-08-27 16:38:22 +08:00
caolin 55193fab29 配置修改 2023-08-25 23:55:20 +08:00
caolin 11cb221f06 配置修改 2023-08-25 17:20:50 +08:00
caolin 27f318406a 配置修改 2023-08-25 16:58:23 +08:00
caolin a8253325e7 微信支付bug调整 2023-08-25 00:49:15 +08:00
caolin 06a3faae08 微信支付bug调整 2023-08-24 15:19:52 +08:00
caolin 0e3d0bc7ee 微信支付bug调整 2023-08-24 15:16:00 +08:00
caolin 1aea550071 微信支付bug调整 2023-08-24 12:53:29 +08:00
caolin bd00a6125e 微信支付bug调整 2023-08-24 12:52:19 +08:00
caolin c8672c15ea 微信支付bug调整 2023-08-24 12:51:27 +08:00
caolin ae3af80e9c 查询调整 2023-08-24 03:01:33 +08:00
caolin 443cf0b890 查询调整 2023-08-24 02:34:46 +08:00
caolin 0273c01772 查询调整 2023-08-24 02:28:30 +08:00
caolin 3653366102 查询调整 2023-08-24 01:31:16 +08:00
caolin 5cf311efea 查询调整 2023-08-24 01:20:02 +08:00
caolin 07470c037d 查询调整 2023-08-24 01:06:56 +08:00
caolin 66548f73df 查询调整 2023-08-23 23:58:25 +08:00
caolin 5db6f312ed 小程序支付调整 2023-08-23 22:29:50 +08:00
caolin d019f727fd 小程序支付调整 2023-08-23 22:15:41 +08:00
caolin 61afc0928f 小程序支付调整 2023-08-23 16:02:14 +08:00
caolin e5beeb0ac9 bug调整 2023-08-21 23:57:39 +08:00
caolin 45bf79ea01 成绩提交 2023-08-21 02:02:39 +08:00
caolin f81e2f159c 获取视频 2023-08-21 01:46:09 +08:00
caolin 00d4f131f1 获取视频 2023-08-21 01:46:03 +08:00
caolin 8ab9529030 微信支付会员充值 2023-08-20 17:05:40 +08:00
caolin aeae6d9d8e 题目修改 2023-08-20 15:06:53 +08:00
caolin 32ab1db4a9 Merge remote-tracking branch 'origin/master' 2023-08-19 23:37:01 +08:00
caolin dff741a9fd 题目修改 2023-08-19 23:36:50 +08:00
zcx 67e2f7b437 Merge pull request '微信支付' (#5) from dev-zcx into master
Reviewed-on: http://118.31.23.45:3000/caolin/driver-server/pulls/5
2023-08-19 17:28:31 +08:00
93 changed files with 2773 additions and 313 deletions

26
pom.xml
View File

@ -20,6 +20,17 @@
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- 使用谷歌的gson来实现json的传递-->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@ -52,6 +63,13 @@
<version>${mybatis-plus-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
@ -168,6 +186,14 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -29,7 +29,8 @@ public class CorsConfig implements WebMvcConfigurer {
"/error",
"/webjars/**",
"/doc.html",
"/tdQuestion/duima/*");
"/tdQuestion/duima/*",
"/tdSysUserMember/duima/**");
}

View File

@ -30,8 +30,11 @@ public class RedisConfig {
serializer.setObjectMapper(mapper);
redisTemplate.setValueSerializer(serializer);
redisTemplate.setHashValueSerializer(serializer);
//使用StringRedisSerializer来序列化和反序列化redis的key值
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setKeySerializer(serializer);
redisTemplate.setHashValueSerializer(serializer);
// redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}

View File

@ -15,7 +15,8 @@ public class Constants {
public static String MESSAGE_CODE_PREFIX = "code_";
//短信验证码的模板
public static String MESSAGE_TEMPLATE = "SMS_198880447";
// public static String MESSAGE_TEMPLATE = "SMS_198880447";
public static String MESSAGE_TEMPLATE = "SMS_463155307";
//是否有效-有效
public static String IS_ACTIVE_TRUE = "0";
@ -35,16 +36,45 @@ public class Constants {
//科目四
public static String SUBJECT_FOUR = "4";
//单选
//判断
public static String QUESTION_TYPE_ONE = "1";
//判断
//单选
public static String QUESTION_TYPE_TWO = "2";
//多选题
public static String QUESTION_TYPE_THREE = "3";
//字典表题目分类标识
public static String QUESTION_CATEGORY = "QusetionCategory";
//字典表题目科一分类标识
public static String QUESTION_CATEGORY_OF_SUBJECT_ONE = "QusetionCategoryOfSubjectOne";
//字典表题目科四分类标识
public static String QUESTION_CATEGORY_OF_SUBJECT_FOUR = "QusetionCategoryOfSubjectFour";
//微信支付
public static String WECHAT_PAY = "weChatPay";
//题库版本前缀
public static String QUESTION_VERSOPN_PREFIX = "QuestionVersion_";
//redis 有效期(单位秒)
public static String REDIS_EXPIRE_TIME = "RedisExprieTime";
//考试题型数量配置项
public static String TEST_QUESTION_TYPE_NUM = "TestQuestionTypeNum";
//配置项列表前缀
public static String CONFIG_LIST_PREFIX = "configListOf_";
//配置项前缀
public static String CONFIG_PREFIX = "configOf_";
//专项数量前缀
public static String SPECIAL_NUM_PREFIX= "SpecialNum_";
//token手机号前缀
public static String PHONE_PREFIX= "loginPhone_";
}

View File

@ -31,6 +31,9 @@ public class ErrorCode {
// 业务异常编码,异常原因已知
public static final String BUSINESS = "E008";
// 题库版本异常
public static final String VERSION_ERROR = "4001";
public static final String NOT_SHOW = "NOO1";
private ErrorCode() {

View File

@ -1,30 +1,43 @@
package com.jwl.driver.server.controller;
import com.jwl.driver.server.config.WechatPayConfig;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.IOrderPayInfoService;
import com.jwl.driver.server.util.InputStreamUtil;
import com.jwl.driver.server.util.WechatPayUtil;
import com.jwl.driver.server.vo.AppletPayVo;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.*;
import com.wechat.pay.java.service.payments.model.Transaction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
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 javax.annotation.Resource;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.math.BigDecimal;
/**
*
*/
@Api(tags = "小程序支付")
@Controller
@RestController
@RequestMapping("/applet/pay")
@Slf4j
public class AppletPayController {
@ -32,30 +45,37 @@ public class AppletPayController {
@Resource
private WechatPayConfig wechatPayConfig;
@Autowired
private IOrderPayInfoService orderPayInfoService;
//生成预支付订单
@ApiOperation("生成预支付订单")
@PostMapping("/prepay")
public BaseResponse createPrepay(@RequestBody AppletPayVo payDto){
// 构建service
log.info("payDto===================>{}",payDto);
JsapiServiceExtension service = createService();
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payDto.getMoney(),payDto.getUserId(), payDto.getDescription(), payDto.getTradeType(), payDto.getOutTradeNo(),"applet");
// 请求下单参数
PrepayRequest request = new PrepayRequest();
Amount amount = new Amount();
amount.setTotal(Integer.valueOf((payDto.getMoney()*100)+""));
amount.setTotal(Integer.valueOf((payDto.getMoney().multiply(new BigDecimal("100")).setScale(0).toString())+""));
request.setAmount(amount);
request.setAppid(wechatPayConfig.getAppId());
request.setMchid(wechatPayConfig.getMchId());
request.setDescription(payDto.getDescription());
request.setNotifyUrl(wechatPayConfig.getPayNoticeUrl());
request.setOutTradeNo(payDto.getOutTradeNo());
request.setOutTradeNo(orderPayInfo.getPayId().toString());
Payer payer = new Payer();
payer.setOpenid(WechatPayUtil.getOpenId(wechatPayConfig.getAppId(), wechatPayConfig.getAppSecret(), payDto.getCode()));
request.setPayer(payer);
// 调用下单方法,得到应答
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
// 使用微信扫描 code_url 对应的二维码即可体验Native支付
// log.info(response);
log.info("response=================>{}",response);
// return BaseResponse.success();
return BaseResponse.success(response);
}
@ -65,7 +85,8 @@ public class AppletPayController {
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.privateKey(PemUtil.loadPrivateKeyFromString(InputStreamUtil.getContentStr("wechatPay/apiclient_key.pem")))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();

View File

@ -1,29 +1,42 @@
package com.jwl.driver.server.controller;
import com.jwl.driver.server.config.WechatPayConfig;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.IOrderPayInfoService;
import com.jwl.driver.server.util.InputStreamUtil;
import com.jwl.driver.server.vo.H5PayVo;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.h5.H5Service;
import com.wechat.pay.java.service.payments.h5.model.*;
import com.wechat.pay.java.service.payments.model.Transaction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
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 javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.math.BigDecimal;
import java.util.Objects;
/**
*
*/
@Api(tags = "H5支付")
@Controller
@RestController
@RequestMapping("/H5/pay")
@Slf4j
public class H5PayController {
@ -31,40 +44,46 @@ public class H5PayController {
@Resource
private WechatPayConfig wechatPayConfig;
@Autowired
private IOrderPayInfoService orderPayInfoService;
//生成预支付订单
@ApiOperation("生成预支付订单")
@PostMapping("/prepay")
public BaseResponse createPrepay(@RequestBody H5PayVo payVo){
// 构建service
H5Service service = createService();
//在order_pay_info里新增一条数据
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payVo.getMoney(),payVo.getUserId(),payVo.getDescription(), payVo.getTradeType(), payVo.getOutTradeNo(), "h5");
// 请求下单参数
PrepayRequest request = new PrepayRequest();
Amount amount = new Amount();
amount.setTotal(Integer.valueOf((payVo.getMoney()*100)+""));
amount.setTotal(Integer.valueOf((payVo.getMoney().multiply(new BigDecimal("100")).setScale(0).toString())+""));
request.setAmount(amount);
request.setAppid(wechatPayConfig.getAppId());
request.setMchid(wechatPayConfig.getMchId());
request.setDescription(payVo.getDescription());
request.setNotifyUrl(wechatPayConfig.getPayNoticeUrl());
request.setOutTradeNo(payVo.getOutTradeNo());
request.setOutTradeNo(orderPayInfo.getPayId().toString());
//场景参数
SceneInfo sceneInfo = new SceneInfo();
sceneInfo.setPayerClientIp(payVo.getClientIp());
request.setSceneInfo(sceneInfo);
// 调用下单方法,得到应答
PrepayResponse response = service.prepay(request);
// 使用微信扫描 code_url 对应的二维码即可体验Native支付
// log.info(response);
return BaseResponse.success(response);
}
private H5Service createService() {
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.privateKey(PemUtil.loadPrivateKeyFromString(InputStreamUtil.getContentStr("wechatPay/apiclient_key.pem")))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();

View File

@ -1,20 +1,27 @@
package com.jwl.driver.server.controller;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.jwl.driver.server.config.WechatPayConfig;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.enums.PurchaseProductTypeEnum;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.IOrderPayInfoService;
import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.service.ITdSysUserMemberService;
import com.jwl.driver.server.util.InputStreamUtil;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.core.util.PemUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.resource.HttpResource;
@ -30,12 +37,19 @@ import javax.annotation.Resource;
* @since 2023-08-10
*/
@Api(tags = "支付回调")
@Controller
@RestController
@RequestMapping("/payNoticeLog")
@Slf4j
public class PayNoticeLogController {
@Resource
private WechatPayConfig wechatPayConfig;
@Autowired
private ITdSysUserMemberService userMemberService;
@Autowired
private IOrderPayInfoService payInfoService;
/**
*
* @param wechatPayCertificateSerialNumber
@ -52,10 +66,12 @@ public class PayNoticeLogController {
@RequestHeader("Wechatpay-Timestamp") String timstamp,
@RequestHeader("Wechatpay-Nonce") String nonce,
@RequestBody String requestBody){
log.info("支付回调信息==============》{}",requestBody);
NotificationConfig config = new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getPrivateKeyPath())
.privateKey(PemUtil.loadPrivateKeyFromString(InputStreamUtil.getContentStr("wechatPay/apiclient_key.pem")))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();
RequestParam requestParam = new RequestParam.Builder()
@ -76,11 +92,22 @@ public class PayNoticeLogController {
System.out.println("decryptObject="+decryptObject.toJSONString());
String trade_state=decryptObject.getString("trade_state");
//取业务id
String outTradeNo = decryptObject.getString("out_trade_no");
JSONObject jsonResponse = new JSONObject();
OrderPayInfo payInfo = payInfoService.getById(Long.parseLong(outTradeNo));
if(trade_state.equals("SUCCESS")) {
//各种业务逻辑
//1.订单详情表里修改数据
payInfoService.payNotice(payInfo,Boolean.TRUE);
//2.如果购买商品是会员则冲会员,其余的则不做操作
if (StrUtil.equals(payInfo.getPurchaseProductType(), PurchaseProductTypeEnum.MEMBER.getValue())){
userMemberService.purchaseMember(payInfo);
}
}else{
//还是各种业务逻辑
//1.订单详情表里修改数据
payInfoService.payNotice(payInfo,Boolean.FALSE);
}
jsonResponse.put("code", "SUCCESS");
jsonResponse.put("message", "成功");

View File

@ -4,6 +4,7 @@ package com.jwl.driver.server.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
@ -13,8 +14,9 @@ import org.springframework.stereotype.Controller;
* @author Automated procedures
* @since 2023-08-10
*/
@Controller
@RequestMapping("//payPrepay")
@RestController
@RequestMapping("/payPrepay")
public class PayPrepayController {
}

View File

@ -5,6 +5,7 @@ import com.jwl.driver.server.dto.MemberQueryDto;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.util.SecurityUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -46,6 +47,6 @@ public class TdMemberController {
@PostMapping("/queryUserMember")
public BaseResponse queryUserMember(@RequestBody MemberQueryDto queryDto) {
log.info("获取用户会员列表======>queryDto:{}", queryDto);
return BaseResponse.success(memberService.queryUserMember(queryDto));
return BaseResponse.success(memberService.queryUserMember(queryDto, SecurityUtil.getUserId()));
}
}

View File

@ -0,0 +1,36 @@
package com.jwl.driver.server.controller;
import com.jwl.driver.server.dto.ProjectDto;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Api(tags = "考试项目")
@RestController
@RequestMapping("/tdTestProject")
@Slf4j
public class TdProjectController {
@Autowired
private ITdProjectService projectService;
@ApiOperation("获取项目列表 (考试项目和基础操作)")
@PostMapping("/queryProjectList")
public BaseResponse list(@RequestBody ProjectDto projectDto) {
log.info("获取考试项目=========》projectDto{}",projectDto);
return BaseResponse.success(projectService.queryProjectList(projectDto));
}
}

View File

@ -2,19 +2,19 @@ package com.jwl.driver.server.controller;
import cn.hutool.core.collection.CollectionUtil;
import com.jwl.driver.server.dto.QuestionAddDto;
import com.jwl.driver.server.dto.QuestionQueryDto;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdQuestionService;
import com.jwl.driver.server.vo.QusetionVo;
import com.jwl.driver.server.vo.QuestionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.validation.Valid;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -44,7 +44,6 @@ public class TdQuestionController {
return BaseResponse.success(tdQuestionService.queryQuestionById(queryDto));
}
@ApiOperation("根据id列表获取题目")
@PostMapping("/queryQuestionByIdList")
public BaseResponse queryQuestionByIdList(@RequestBody QuestionQueryDto queryDto) {
@ -52,14 +51,20 @@ public class TdQuestionController {
return BaseResponse.success(tdQuestionService.queryQuestionByIdList(queryDto));
}
@ApiOperation("根据查询条件获取题目")
@PostMapping("/queryQuestion")
public BaseResponse queryQuestion(@RequestBody QuestionQueryDto queryDto) {
log.info("获取题型======>queryDto:{}", queryDto);
log.info("根据查询条件获取题目======>queryDto:{}", queryDto);
return BaseResponse.success(tdQuestionService.queryQuestion(queryDto));
}
@ApiOperation("根据查询条件获取题目Id")
@PostMapping("/queryQuestionId")
public BaseResponse queryQuestionId(@RequestBody QuestionQueryDto queryDto) {
log.info("根据查询条件获取题目Id======>queryDto:{}", queryDto);
return BaseResponse.success(tdQuestionService.queryQuestionId(queryDto));
}
@ApiOperation("获取模拟考试题目")
@PostMapping("/getTestQuestion")
public BaseResponse getTestQuestion(@RequestBody QuestionQueryDto queryDto) {
@ -70,6 +75,13 @@ public class TdQuestionController {
return BaseResponse.success(tdQuestionService.getTestQuestion(queryDto));
}
@ApiOperation("获取模拟考试题目Id")
@PostMapping("/getTestQuestionId")
public BaseResponse getTestQuestionId(@RequestBody QuestionQueryDto queryDto) {
log.info("根据查询条件获取题目Id======>queryDto:{}", queryDto);
return BaseResponse.success(tdQuestionService.getTestQuestionId(queryDto));
}
@ApiOperation("题目分类")
@PostMapping("/questionCategory")
public BaseResponse questionCategory(@RequestBody QuestionQueryDto queryDto) {
@ -92,13 +104,29 @@ public class TdQuestionController {
@ApiOperation("对嘛接口-修改题库")
@PutMapping("/duima/update")
public Map updateQuestion(@RequestBody QusetionVo qusetionVo) {
log.info("修改题库======>qusetionVo:{}", qusetionVo);
public Map updateQuestion(@RequestBody QuestionVo questionVo) {
log.info("修改题库======>questionVo:{}", questionVo);
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", tdQuestionService.updateQuestion(qusetionVo));
result.put("data", tdQuestionService.updateQuestion(questionVo));
return result;
}
@ApiOperation("新增题库")
@PostMapping("/insert")
public Map insertQuestion(@RequestBody @Valid QuestionAddDto addDto) {
log.info("新增题库======>QuestionAddDto:{}", addDto);
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", tdQuestionService.insertQuestion(addDto));
return result;
}
@ApiOperation("查询各专项分类题目数量")
@PostMapping("/querySpecialNum")
public BaseResponse querySpecialNum(@RequestBody QuestionQueryDto queryDto) {
log.info("查询各专项分类题目数量======>queryDto:{}", queryDto);
return BaseResponse.success(tdQuestionService.querySpecialNum(queryDto));
}
}

View File

@ -2,6 +2,7 @@ package com.jwl.driver.server.controller;
import com.jwl.driver.server.dto.QuestionQueryDto;
import com.jwl.driver.server.dto.TestQueryDto;
import com.jwl.driver.server.dto.TestSubmitDto;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdQuestionService;
@ -40,7 +41,10 @@ public class TdQuestionTestController {
return BaseResponse.success(testService.testSubmit(submitDto));
}
@ApiOperation("获取考试统计")
@PostMapping("/testTotal")
public BaseResponse testTotal(@RequestBody @Valid TestQueryDto queryDto) {
log.info("考试统计查询======>queryDto:{}", queryDto);
return BaseResponse.success(testService.testTotal(queryDto));
}
}

View File

@ -0,0 +1,56 @@
package com.jwl.driver.server.controller;
import com.jwl.driver.server.dto.TestSubmitDto;
import com.jwl.driver.server.entity.TdQuestionVersion;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdQuestionVersionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.validation.Valid;
import java.util.Objects;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-09-03
*/
@Api(tags = "题库版本")
@RestController
@RequestMapping("/tdQuestionVersion")
@Slf4j
public class TdQuestionVersionController {
@Autowired
private ITdQuestionVersionService versionService;
@ApiOperation("获取题库当前版本")
@GetMapping("/currentVersion")
public BaseResponse testSubmit(@RequestParam Integer carTypeId) {
log.info("获取题库当前版本======>carTypeId:{}", carTypeId);
return BaseResponse.success(versionService.currentVersion(carTypeId));
}
@ApiOperation("题库版本更新")
@PostMapping("/addVersion")
public BaseResponse addVersion(@RequestBody TdQuestionVersion versionDto) {
log.info("题库版本更新======>versionDto:{}", versionDto);
if (Objects.isNull(versionDto.getCarTypeId())){
throw new BusinessException("缺少必要参数");
}
return BaseResponse.success(versionService.addVersion(versionDto));
}
}

View File

@ -41,21 +41,31 @@ public class TdSysConfigListController {
@ApiOperation("根据configKey和carTypeId查询系统配置列表")
@GetMapping("/querySysConfigList")
public BaseResponse querySysConfigList(@RequestParam("configKey") String configKey, @RequestParam("carTypeId") Integer carTypeId) {
log.info("request to querySysConfigList {}", configKey);
log.info("request to querySysConfigList {}, carTypeId:{}", configKey,carTypeId);
List<TdSysConfigList> resultList = configListService.querySysConfigList(configKey, carTypeId);
return BaseResponse.success(resultList);
}
/**
* key carTypeId
* configKey carTypeId
*/
@ApiOperation("通过多个配置key 和 carTypeId 查询多个配置列表")
@ApiOperation("通过多个configKey以逗号分隔 和 carTypeId 查询多个配置列表")
@GetMapping("/querySysConfigMap")
public BaseResponse querySysConfigMap(@RequestParam("configKeys") String configKeys, @RequestParam("carTypeId") Integer carTypeId) {
log.info("request to querySysConfigList {}", configKeys);
log.info("request to querySysConfigMap {}, carTypeId:{}", configKeys,carTypeId);
Map<String, Map<String, String>> map = configListService.querySysConfigMap(Arrays.asList(configKeys.split(",")), carTypeId);
return BaseResponse.success(map);
}
/**
* configKeycarTypeId
*/
@ApiOperation("根据configKey和carTypeId查询系统配置列表数量")
@GetMapping("/querySysConfigListNum")
public BaseResponse querySysConfigListNum(@RequestParam("configKey") String configKey, @RequestParam("carTypeId") Integer carTypeId) {
log.info("request to querySysConfigListNum {}, carTypeId:{}", configKey,carTypeId);
Integer listNum = configListService.querySysConfigListNum(configKey, carTypeId);
return BaseResponse.success(listNum);
}
}

View File

@ -1,6 +1,7 @@
package com.jwl.driver.server.controller;
import com.jwl.driver.server.dto.DriverSchoolDto;
import com.jwl.driver.server.dto.LoginUserDto;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.response.BaseResponse;
@ -64,12 +65,9 @@ public class TdSysUserController {
@ApiOperation("用户绑定驾校")
@PostMapping("/bindSchool")
public BaseResponse bindSchool(@RequestBody LoginUserDto userDto) {
log.info("用户绑定驾校======>schoolId{}",userDto.getSchoolId());
if (Objects.isNull(userDto.getSchoolId())){
throw new BusinessException("缺少必要参数");
}
return BaseResponse.success(userService.bindSchool(userDto));
public BaseResponse bindSchool(@RequestBody @Valid DriverSchoolDto schoolDto) {
log.info("用户绑定驾校信息======>schoolDto{}",schoolDto);
return BaseResponse.success(userService.bindSchool(schoolDto));
}

View File

@ -1,10 +1,35 @@
package com.jwl.driver.server.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.dto.MemberQueryDto;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.TdSysUser;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.response.BaseResponse;
import com.jwl.driver.server.service.ITdCarService;
import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.service.ITdSysUserMemberService;
import com.jwl.driver.server.service.ITdSysUserService;
import com.jwl.driver.server.vo.MemberVo;
import com.jwl.driver.server.vo.UserMemberVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.User;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* ;
@ -13,8 +38,87 @@ import org.springframework.stereotype.Controller;
* @author Automated procedures
* @since 2023-08-10
*/
@Controller
@RequestMapping("//tdSysUserMember")
@RestController
@RequestMapping("/tdSysUserMember")
@Slf4j
@Api(tags = "用户会员")
public class TdSysUserMemberController {
@Resource
private ITdMemberService memberService;
@Resource
private ITdSysUserMemberService userMemberService;
@Resource
private ITdCarService tdCarService;
@Resource
private ITdSysUserService userService;
/**
*
* */
@ApiOperation("查询车型列表")
@GetMapping("/duima/car/list")
public Map getCarList(){
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", tdCarService.list());
return result;
}
/**
*
* */
@ApiOperation("查询会员类型列表")
@GetMapping("/duima/member/list")
public Map getMemberList(MemberQueryDto memberQueryDto){
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", memberService.queryMember(memberQueryDto));
return result;
}
//查询用户会员列表
@ApiOperation("查询会员用户列表")
@GetMapping("/duima/user/member/list")
public Map getUserMemberList(UserMemberDto userMemberDto){
Map<String, Object> result = new HashMap<>();
result.put("code", 200);
result.put("data", userMemberService.queryUserMemberList(userMemberDto));
return result;
}
//新增会员
@ApiOperation("新增用户会员")
@PostMapping("/duima/user/member")
public Map addUserMember(@RequestBody UserMemberVo userMemberVo){
Map<String, Object> result = new HashMap<>();
final LocalDateTime nowTime = LocalDateTime.now();
//跟进手机号查询用户
LambdaQueryWrapper<TdSysUser> cond = new LambdaQueryWrapper<TdSysUser>()
.eq(TdSysUser::getPhone,userMemberVo.getPhone());
TdSysUser user = userService.getOne(cond);
if(user == null){
result.put("code", 500);
result.put("msg", "用户不存在");
return result;
}
TdSysUserMember userMember = new TdSysUserMember()
.setMemberId(userMemberVo.getMemberId())
.setUserId(user.getUserId())
.setCreateTime(nowTime)
.setUpdateTime(nowTime)
.setStartDate(LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
.setEndDate(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusYears(1).minusSeconds(1));
result.put("code", 200);
result.put("data", userMemberService.saveOrUpdate(userMember));
return result;
}
}

View File

@ -1,20 +0,0 @@
package com.jwl.driver.server.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Controller
@RequestMapping("//tdTestProject")
public class TdTestProjectController {
}

View File

@ -11,10 +11,10 @@ import org.springframework.stereotype.Controller;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
* @since 2023-08-20
*/
@Controller
@RequestMapping("//tdTestProjectVideos")
public class TdTestProjectVideosController {
@RequestMapping("//tdVideos")
public class TdVideosController {
}

View File

@ -0,0 +1,31 @@
package com.jwl.driver.server.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author
* @description
* @create 2023/8/11 22:21
*/
@Data
@Accessors(chain = true)
public class DriverSchoolDto {
@ApiModelProperty(value = "驾校id",required = true)
@NotNull(message = "驾校id不能为空")
private Long schoolId;
@ApiModelProperty(value = "驾校名称",required = true)
@NotBlank(message = "驾校名称不能为空")
private String schoolName;
@ApiModelProperty(value = "驾校联系方式",required = false)
private String schoolPhone;
}

View File

@ -23,6 +23,6 @@ public class LoginUserDto {
@NotBlank(message = "登陆验证码不能为空")
private String code;
@ApiModelProperty(value = "驾校id",required = false)
private Long schoolId;
@ApiModelProperty(value = "来源")
private String id;
}

View File

@ -0,0 +1,55 @@
package com.jwl.driver.server.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Data
@Accessors(chain = true)
@ApiModel("考试项目查询入参")
public class ProjectDto implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("考试项目")
private Integer projectId;
/**
*
*/
@ApiModelProperty("类型 1:考试项目 2:基础操作")
private String type;
/**
*
*/
@ApiModelProperty("所属科目")
private String subject;
/**
*
*/
@ApiModelProperty("车型标识")
private Integer carTypeId;
/**
* A2:B2
*/
@ApiModelProperty("驾驶类型")
private String driveType;
}

View File

@ -1,34 +1,31 @@
package com.jwl.driver.server.vo;
package com.jwl.driver.server.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author
* @description
* @description
* @create 2023/8/13 17:13
*/
@Data
@Accessors(chain = true)
@ApiModel("驾考题目出参")
public class QusetionVo {
public class QuestionAddDto {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("题目标识")
private Long questionId;
/**
*
*/
@ApiModelProperty("题目内容")
@ApiModelProperty(value = "题目内容",required = true)
private String question;
/**
@ -131,6 +128,7 @@ public class QusetionVo {
* 1 23
*/
@ApiModelProperty("题目类型1选择题 2判断题3多选题")
@NotBlank
private String type;
/**
@ -143,6 +141,7 @@ public class QusetionVo {
*
*/
@ApiModelProperty("车型")
@NotNull
private Integer carTypeId;
/**
@ -155,6 +154,7 @@ public class QusetionVo {
* vip
*/
@ApiModelProperty("是否VIP")
@NotNull
private Integer isVip;
/**
*

View File

@ -93,4 +93,57 @@ public class QuestionQueryDto implements Serializable {
@ApiModelProperty("题目")
private String question;
/**
*
*/
@ApiModelProperty("是否易错")
private Integer isError;
/**
* v
*/
@ApiModelProperty("是否v新规")
private Integer isNew;
/**
*
*/
@ApiModelProperty("是否是图片")
private Integer isImage;
/**
*
*/
@ApiModelProperty("考点")
private String examKey;
/**
* 500
*/
@ApiModelProperty("是否精讯500题")
private Integer isVip;
/**
* 600
*/
@ApiModelProperty("是否精讯600题")
private Integer isVip2;
/**
* 1
*/
@ApiModelProperty("是否密卷1")
private Integer isExam1;
/**
* 2
*/
@ApiModelProperty("是否密卷2")
private Integer isExam2;
/**
* id
*/
@ApiModelProperty("题库版本id")
private Long versionId;
}

View File

@ -0,0 +1,35 @@
package com.jwl.driver.server.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
/**
* @author
* @description
* @create 2023/8/14 21:22
*/
@Data
@Accessors(chain = true)
@ApiModel("成绩查询入参")
public class TestQueryDto {
/**
*
*/
@ApiModelProperty(value = "车型标识",required = true)
@NotNull(message = "车型标识不能为空")
private Integer carTypeId;
/**
*
*/
@ApiModelProperty(value = "科目",required = true)
@NotNull(message = "考试科目不能为空")
private String subject ;
}

View File

@ -0,0 +1,38 @@
package com.jwl.driver.server.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author
* @description
* @create 2023/8/11 22:21
*/
@Data
@Accessors(chain = true)
public class TestQuestionTypeDto {
//科目
private String subject;
private List<TestOfChapter> chapterList;
@Data
@Accessors(chain = true)
public static class TestOfChapter {
//章节
private String chapter;
//判断题
private Integer judgeNum;
//单选题
private Integer radioNum;
//多选题
private Integer multipleChoiceNum;
}
}

View File

@ -8,6 +8,7 @@ import lombok.experimental.Accessors;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@ -28,6 +29,13 @@ public class TestSubmitDto {
@NotNull(message = "车型标识不能为空")
private Integer carTypeId;
/**
*
*/
@ApiModelProperty(value = "科目",required = true)
@NotBlank(message = "考试科目不能为空")
private String subject ;
/**
*
*/

View File

@ -0,0 +1,9 @@
package com.jwl.driver.server.dto;
import lombok.Data;
@Data
public class UserMemberDto {
private String phone;
private Integer memberId;
}

View File

@ -31,10 +31,16 @@ public class OrderPayInfo implements Serializable {
private Long payId;
/**
*
* 1.2.3.
*/
@TableField("MEMBER_ID")
private Integer memberId;
@TableField("PURCHASE_PRODUCT_TYPE")
private String purchaseProductType;
/**
*
*/
@TableField("PURCHASE_PRODUCT_ID")
private String purchaseProductId;
/**
*

View File

@ -76,8 +76,8 @@ public class TdMember implements Serializable {
/**
*
*/
@TableField("DESC")
private String desc;
@TableField("DESCRIPTION")
private String DESCRIPTION;
/**
*

View File

@ -19,15 +19,21 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class TdTestProject implements Serializable {
public class TdProject implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId("TEST_PROJECT_ID")
private Integer testProjectId;
@TableId("PROJECT_ID")
private Integer projectId;
/**
*
*/
@TableField("TYPE")
private String type;
/**
*
@ -47,6 +53,12 @@ public class TdTestProject implements Serializable {
@TableField("DRIVE_TYPE")
private String driveType;
/**
*
*/
@TableField("DESCRIPTION")
private String description;
/**
*
*/

View File

@ -115,6 +115,12 @@ public class TdQuestion implements Serializable {
@TableField("BEST_ANSWER")
private String bestAnswer;
/**
*
*/
@TableField("SKILL_INFO")
private String skillInfo;
/**
*
*/

View File

@ -36,6 +36,12 @@ public class TdQuestionTest implements Serializable {
@TableField("CAR_TYPE_ID")
private Integer carTypeId;
/**
*
*/
@TableField("SUBJECT")
private String subject;
/**
*
*/

View File

@ -0,0 +1,58 @@
package com.jwl.driver.server.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-09-03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class TdQuestionVersion implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "VERSION_ID", type = IdType.AUTO)
private Long versionId;
/**
*
*/
@TableField("CAR_TYPE_ID")
private Integer carTypeId;
/**
*
*/
@TableField("IS_ACTIVE")
private String isActive;
/**
*
*/
@TableField("DESCRIPTION")
private String description;
/**
*
*/
@TableField("CREATE_TIME")
private LocalDateTime createTime;
}

View File

@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -77,6 +82,8 @@ public class TdSysConfig implements Serializable {
*
*/
@TableField("CREATE_TIME")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;

View File

@ -4,6 +4,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -63,6 +68,8 @@ public class TdSysConfigList implements Serializable {
*
*/
@TableField("CREATE_TIME")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;

View File

@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@ -65,6 +66,18 @@ public class TdSysUser implements Serializable {
@TableField("SCHOOL_ID")
private Long schoolId;
/**
*
*/
@TableField("SCHOOL_NAME")
private String schoolName;
/**
*
*/
@TableField("SCHOOL_PHONE")
private String schoolPhone;
/**
*
*/

View File

@ -15,12 +15,12 @@ import lombok.experimental.Accessors;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
* @since 2023-08-20
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class TdTestProjectVideos implements Serializable {
public class TdVideos implements Serializable {
private static final long serialVersionUID = 1L;
@ -31,21 +31,41 @@ public class TdTestProjectVideos implements Serializable {
private Integer videoId;
/**
*
*
*/
@TableField("TEST_PROJECT_ID")
private Integer testProjectId;
@TableField("TYPE_ID")
private Integer typeId;
/**
*
*/
@TableField("VIDEO_IMAGE")
private String videoImage;
/**
*
*/
@TableField("VIDEO_URL")
private String videoUrl;
/**
* ()
*/
@TableField("VIDEO_TIME")
private Integer videoTime;
/**
*
*/
@TableField("SHOW_ORDER")
private Integer showOrder;
/**
*
*/
@TableField("DESCRIPTION")
private String description;
/**
*
*/

View File

@ -0,0 +1,47 @@
package com.jwl.driver.server.enums;
import java.util.HashMap;
import java.util.Map;
/**
* @author
* @description
* @create 2023/8/20 1:19
*/
public enum PayStatus {
NOT(1, "未支付"),
SUCCESS(2, "支付成功"),
FAIL(3, "支付失败");
private Integer value;
private String name;
public static final Map<Integer, PayStatus> valueMap = new HashMap();
public static PayStatus fromValue(Integer value) {
return (PayStatus)valueMap.get(value);
}
private PayStatus(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return this.value;
}
public String getName() {
return this.name;
}
static {
PayStatus[] var0 = values();
int var1 = var0.length;
for(int var2 = 0; var2 < var1; ++var2) {
PayStatus value = var0[var2];
valueMap.put(value.getValue(), value);
}
}
}

View File

@ -0,0 +1,49 @@
package com.jwl.driver.server.enums;
import java.util.HashMap;
import java.util.Map;
/**
* @author
* @description
* @create 2023/9/17 17:19
*/
public enum PurchaseProductTypeEnum {
MEMBER("1", "会员"),
UPLOAD_PHOTO_ID ("2", "上传证件照"),
PHYSICAL_EXAMINATION_INFORMATION("3", "体检信息");
private String value;
private String desc;
public static final Map<String, PurchaseProductTypeEnum> valueMap = new HashMap();
public static PurchaseProductTypeEnum fromValue(String value) {
return (PurchaseProductTypeEnum)valueMap.get(value);
}
private PurchaseProductTypeEnum(String value, String name) {
this.value = value;
this.desc = name;
}
public String getValue() {
return this.value;
}
public String getName() {
return this.desc;
}
static {
PurchaseProductTypeEnum[] var0 = values();
int var1 = var0.length;
for(int var2 = 0; var2 < var1; ++var2) {
PurchaseProductTypeEnum value = var0[var2];
valueMap.put(value.getValue(), value);
}
}
}

View File

@ -1,15 +1,15 @@
package com.jwl.driver.server.generator;
public class MysqlParamGenerator {
private static final String host = "127.0.0.1:3306";
private static final String database = "driver_test";
private static final String host = "118.31.23.45";
private static final String database = "driver_server";
private static final String url = "jdbc:mysql://" + host + "/" + database + "?characterEncoding=utf-8&autoReconnect=true&serverTimezone=Asia/Shanghai&failOverReadOnly=false";
private static final String userName = "root";
private static final String password = "123456";
private static final String password = "admin231280";
private static final String module = "com.jwl.driver.server";
// projectPath项为空即可
private static final String projectPath = "/driver-server";
private static final String projectPath = "";
// todo 实体类是否继承基础类-具备开始时间和结束时间实体类的基础属性
private static final String superEntityClass = "";

View File

@ -1,6 +1,6 @@
package com.jwl.driver.server.mapper;
import com.jwl.driver.server.entity.TdTestProject;
import com.jwl.driver.server.entity.TdProject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
@ -11,6 +11,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* @author Automated procedures
* @since 2023-08-10
*/
public interface TdTestProjectMapper extends BaseMapper<TdTestProject> {
public interface TdProjectMapper extends BaseMapper<TdProject> {
}

View File

@ -3,10 +3,11 @@ package com.jwl.driver.server.mapper;
import com.jwl.driver.server.dto.QuestionQueryDto;
import com.jwl.driver.server.entity.TdQuestion;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwl.driver.server.vo.QusetionVo;
import com.jwl.driver.server.vo.QuestionVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -23,14 +24,42 @@ public interface TdQuestionMapper extends BaseMapper<TdQuestion> {
* @param queryDto
* @return
*/
List<QusetionVo> queryQuestion(@Param("queryDto") QuestionQueryDto queryDto);
List<QuestionVo> queryQuestion(@Param("queryDto") QuestionQueryDto queryDto);
/**
* id
* @param queryDto
* @return
*/
List<Long> queryQuestionId(@Param("queryDto") QuestionQueryDto queryDto);
/**
*
* @param queryDto
* @return
*/
List<QusetionVo> queryQuestionByRandom(@Param("queryDto") QuestionQueryDto queryDto);
List<QuestionVo> queryQuestionByRandom(@Param("queryDto") QuestionQueryDto queryDto);
int updateQuestion(@Param("qusetionVo") QusetionVo qusetionVo);
/**
* Id
* @param queryDto
* @return
*/
List<Long> queryQuestionIdByRandom(@Param("queryDto") QuestionQueryDto queryDto);
int updateQuestion(@Param("questionVo") QuestionVo questionVo);
/**
*
* @param queryDto
* @return
*/
Map<String, Integer> querySpecialNum(@Param("queryDto") QuestionQueryDto queryDto);
/**
*
* @param carTypeId
* @return
*/
Integer queryMaxSort(@Param("carTypeId") int carTypeId);
}

View File

@ -0,0 +1,16 @@
package com.jwl.driver.server.mapper;
import com.jwl.driver.server.entity.TdQuestionVersion;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* ; Mapper
* </p>
*
* @author Automated procedures
* @since 2023-09-03
*/
public interface TdQuestionVersionMapper extends BaseMapper<TdQuestionVersion> {
}

View File

@ -1,7 +1,12 @@
package com.jwl.driver.server.mapper;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jwl.driver.server.vo.UserMemberVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface TdSysUserMemberMapper extends BaseMapper<TdSysUserMember> {
List<UserMemberVo> queryUserMemberList(@Param("userMemberDto") UserMemberDto userMemberDto);
}

View File

@ -1,6 +1,6 @@
package com.jwl.driver.server.mapper;
import com.jwl.driver.server.entity.TdTestProjectVideos;
import com.jwl.driver.server.entity.TdVideos;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
* @since 2023-08-20
*/
public interface TdTestProjectVideosMapper extends BaseMapper<TdTestProjectVideos> {
public interface TdVideosMapper extends BaseMapper<TdVideos> {
}

View File

@ -2,6 +2,9 @@ package com.jwl.driver.server.service;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwl.driver.server.vo.H5PayVo;
import java.math.BigDecimal;
/**
* <p>
@ -13,4 +16,22 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface IOrderPayInfoService extends IService<OrderPayInfo> {
/**
*
* @param money
* @param userIdStr
* @param description
* @param tradeType
* @param outTradeNo
* @param payType
* @return
*/
OrderPayInfo createOrderPayInfo(BigDecimal money,String userIdStr,String description,String tradeType,String outTradeNo,String payType);
/**
*
* @param payInfo
* @param payResult
*/
Boolean payNotice( OrderPayInfo payInfo, Boolean payResult);
}

View File

@ -27,7 +27,8 @@ public interface ITdMemberService extends IService<TdMember> {
/**
*
* @param queryDto
* @param userId
* @return
*/
List<MemberVo> queryUserMember(MemberQueryDto queryDto);
List<MemberVo> queryUserMember(MemberQueryDto queryDto,Long userId);
}

View File

@ -0,0 +1,26 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.dto.ProjectDto;
import com.jwl.driver.server.entity.TdProject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwl.driver.server.vo.ProjectVo;
import java.util.List;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
public interface ITdProjectService extends IService<TdProject> {
/**
*
* @param queryDto
* @return
*/
List<ProjectVo> queryProjectList(ProjectDto queryDto);
}

View File

@ -1,12 +1,14 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.dto.QuestionAddDto;
import com.jwl.driver.server.dto.QuestionQueryDto;
import com.jwl.driver.server.entity.TdQuestion;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwl.driver.server.vo.QuestionVo;
import com.jwl.driver.server.vo.QusetionCategoryVo;
import com.jwl.driver.server.vo.QusetionVo;
import java.util.List;
import java.util.Map;
/**
* <p>
@ -24,28 +26,42 @@ public interface ITdQuestionService extends IService<TdQuestion> {
* @param queryDto
* @return
*/
TdQuestion queryQuestionById(QuestionQueryDto queryDto);
QuestionVo queryQuestionById(QuestionQueryDto queryDto);
/**
* id
* @param queryDto
* @return
*/
List<TdQuestion> queryQuestionByIdList(QuestionQueryDto queryDto);
List<QuestionVo> queryQuestionByIdList(QuestionQueryDto queryDto);
/**
*
* @param queryDto
* @return
*/
List<QusetionVo> queryQuestion(QuestionQueryDto queryDto);
List<QuestionVo> queryQuestion(QuestionQueryDto queryDto);
/**
* Id
* @param queryDto
* @return
*/
List<Long> queryQuestionId(QuestionQueryDto queryDto);
/**
*
* @param queryDto
* @return
*/
List<QusetionVo> getTestQuestion(QuestionQueryDto queryDto);
List<QuestionVo> getTestQuestion(QuestionQueryDto queryDto);
/**
* Id
* @param queryDto
* @return
*/
List<Long> getTestQuestionId(QuestionQueryDto queryDto);
/**
*
@ -56,8 +72,24 @@ public interface ITdQuestionService extends IService<TdQuestion> {
/**
*
* @param qusetionVo
* @param questionVo
* @return
*/
int updateQuestion(QusetionVo qusetionVo);
int updateQuestion(QuestionVo questionVo);
/**
*
* @param addDto
* @return
*/
Boolean insertQuestion(QuestionAddDto addDto);
/**
*
* @param queryDto
* @return
*/
Map<String,Integer> querySpecialNum(QuestionQueryDto queryDto);
}

View File

@ -1,8 +1,10 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.dto.TestQueryDto;
import com.jwl.driver.server.dto.TestSubmitDto;
import com.jwl.driver.server.entity.TdQuestionTest;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwl.driver.server.vo.TestTotalVo;
/**
* <p>
@ -19,5 +21,12 @@ public interface ITdQuestionTestService extends IService<TdQuestionTest> {
* @param submitDto
* @return
*/
Boolean testSubmit(TestSubmitDto submitDto);
TdQuestionTest testSubmit(TestSubmitDto submitDto);
/**
*
* @param queryDto
* @return
*/
TestTotalVo testTotal(TestQueryDto queryDto);
}

View File

@ -0,0 +1,29 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.entity.TdQuestionVersion;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-09-03
*/
public interface ITdQuestionVersionService extends IService<TdQuestionVersion> {
/**
*
* @param carTypeId
* @return
*/
Long currentVersion(Integer carTypeId);
/**
*
* @param versionDto
* @return
*/
Boolean addVersion(TdQuestionVersion versionDto);
}

View File

@ -25,10 +25,18 @@ public interface ITdSysConfigListService extends IService<TdSysConfigList> {
List<TdSysConfigList> querySysConfigList(String configKey, Integer carTypeId);
/**
* key carTypeId
* configKey carTypeId
* @param configKeyList
* @param carTypeId
* @return
*/
Map<String, Map<String, String>> querySysConfigMap(List<String> configKeyList, Integer carTypeId);
/**
* configKeycarTypeId
* @param configKey
* @param carTypeId
* @return
*/
Integer querySysConfigListNum(String configKey, Integer carTypeId);
}

View File

@ -1,7 +1,12 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwl.driver.server.vo.UserMemberVo;
import java.util.List;
/**
* <p>
@ -13,4 +18,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface ITdSysUserMemberService extends IService<TdSysUserMember> {
/**
*
* @param payInfo
* @return
*/
Boolean purchaseMember(OrderPayInfo payInfo);
List<UserMemberVo> queryUserMemberList(UserMemberDto userMemberDto);
}

View File

@ -1,5 +1,6 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.dto.DriverSchoolDto;
import com.jwl.driver.server.dto.LoginUserDto;
import com.jwl.driver.server.entity.TdSysUser;
import com.baomidou.mybatisplus.extension.service.IService;
@ -20,7 +21,7 @@ public interface ITdSysUserService extends IService<TdSysUser> {
* @param phone
* @return
*/
String code(String phone);
Boolean code(String phone);
/**
*
@ -43,8 +44,8 @@ public interface ITdSysUserService extends IService<TdSysUser> {
/**
*
* @param userDto
* @param schoolDto
* @return
*/
Boolean bindSchool(LoginUserDto userDto);
Boolean bindSchool(DriverSchoolDto schoolDto);
}

View File

@ -1,16 +0,0 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.entity.TdTestProject;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
public interface ITdTestProjectService extends IService<TdTestProject> {
}

View File

@ -1,6 +1,6 @@
package com.jwl.driver.server.service;
import com.jwl.driver.server.entity.TdTestProjectVideos;
import com.jwl.driver.server.entity.TdVideos;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
* @since 2023-08-20
*/
public interface ITdTestProjectVideosService extends IService<TdTestProjectVideos> {
public interface ITdVideosService extends IService<TdVideos> {
}

View File

@ -1,10 +1,28 @@
package com.jwl.driver.server.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.StrUtil;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.entity.TdMember;
import com.jwl.driver.server.entity.TdSysUser;
import com.jwl.driver.server.enums.PayStatus;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.OrderPayInfoMapper;
import com.jwl.driver.server.service.IOrderPayInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.service.ITdSysUserService;
import com.jwl.driver.server.util.SecurityUtil;
import com.jwl.driver.server.vo.H5PayVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* <p>
@ -15,6 +33,60 @@ import org.springframework.stereotype.Service;
* @since 2023-08-10
*/
@Service
@Slf4j
public class OrderPayInfoServiceImpl extends ServiceImpl<OrderPayInfoMapper, OrderPayInfo> implements IOrderPayInfoService {
@Autowired
private ITdSysUserService userService;
@Autowired
private ITdMemberService memberService;
@Autowired
private Snowflake snowflake;
@Override
public OrderPayInfo createOrderPayInfo(BigDecimal money,String userIdStr,String description,String tradeType,String outTradeNo,String payType) {
Long userId = StrUtil.isNotBlank(userIdStr) ? Long.parseLong(userIdStr) : SecurityUtil.getUserId();
TdSysUser user = userService.getById(userId);
if (Objects.isNull(user)) {
log.error("数据异常,用户不存在" + userId);
throw new BusinessException("数据缺失");
}
TdMember member = memberService.getById(Integer.parseInt(outTradeNo));
if (Objects.isNull(member) || StrUtil.equals(Constants.IS_ACTIVE_FALSE, member.getIsActive())) {
log.error("数据异常,会员不存在或者已过期" + outTradeNo);
throw new BusinessException("数据缺失");
}
OrderPayInfo orderPayInfo = new OrderPayInfo()
.setPayId(snowflake.nextId())
.setPurchaseProductType(tradeType)
.setPurchaseProductId(outTradeNo)
.setMoney(money)
.setPaymentType(Constants.WECHAT_PAY)
.setPayType(payType)
.setDescription(user.getUserName() + "-" + member.getMemberName())
.setPayStatus(PayStatus.NOT.getValue())
.setDeleteStatus(0)
.setUserId(userId)
.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now());
this.save(orderPayInfo);
return orderPayInfo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean payNotice( OrderPayInfo payInfo, Boolean payResult) {
log.info("支付回调信息===============> payInfo{} , payResult{}",payInfo,payResult);
if (Objects.isNull(payInfo)){
throw new BusinessException("订单信息不存在");
}
payInfo.setPayStatus(payResult?PayStatus.SUCCESS.getValue() : PayStatus.FAIL.getValue())
.setUpdateTime(LocalDateTime.now());
this.updateById(payInfo);
return Boolean.TRUE;
}
}

View File

@ -9,7 +9,9 @@ import com.jwl.driver.server.mapper.TdMemberMapper;
import com.jwl.driver.server.service.ITdMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.util.SecurityUtil;
import com.jwl.driver.server.util.TokenThreadUtil;
import com.jwl.driver.server.vo.MemberVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.*;
@ -24,6 +26,7 @@ import java.util.stream.Collectors;
* @since 2023-08-10
*/
@Service
@Slf4j
public class TdMemberServiceImpl extends ServiceImpl<TdMemberMapper, TdMember> implements ITdMemberService {
@Override
@ -32,7 +35,15 @@ public class TdMemberServiceImpl extends ServiceImpl<TdMemberMapper, TdMember> i
List<MemberVo> resultList = new ArrayList<>();
//获取用户已开通且未到期的会员(即使该会员已不售卖了)
List<MemberVo> userMemberList = queryUserMember(queryDto);
List<MemberVo> userMemberList = new ArrayList<>();
try {
if (StrUtil.isNotBlank(TokenThreadUtil.getToken())){
userMemberList = queryUserMember(queryDto,SecurityUtil.getUserId());
}
}catch (Exception e){
log.info("===================>用户没有登录");
}
Map<Integer, MemberVo> userMemberMap = userMemberList.stream().collect(Collectors.toMap(MemberVo::getMemberId, v -> v, (v1, v2) -> v1));
//将用户购买的已停售但未过期的会员放在最前面
@ -57,8 +68,8 @@ public class TdMemberServiceImpl extends ServiceImpl<TdMemberMapper, TdMember> i
}
@Override
public List<MemberVo> queryUserMember(MemberQueryDto queryDto) {
return this.getBaseMapper().queryUserMember(queryDto,SecurityUtil.getUserId());
public List<MemberVo> queryUserMember(MemberQueryDto queryDto,Long userId) {
return this.getBaseMapper().queryUserMember(queryDto,userId);
}
}

View File

@ -0,0 +1,67 @@
package com.jwl.driver.server.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.dto.ProjectDto;
import com.jwl.driver.server.entity.TdProject;
import com.jwl.driver.server.entity.TdVideos;
import com.jwl.driver.server.mapper.TdProjectMapper;
import com.jwl.driver.server.service.ITdProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdVideosService;
import com.jwl.driver.server.vo.ProjectVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Service
public class TdProjectServiceImpl extends ServiceImpl<TdProjectMapper, TdProject> implements ITdProjectService {
@Autowired
private ITdVideosService videosService;
@Override
public List<ProjectVo> queryProjectList(ProjectDto queryDto) {
List<ProjectVo> resultList = new ArrayList<>();
LambdaQueryWrapper<TdProject> queryWrapper = new LambdaQueryWrapper<TdProject>()
.eq(Objects.nonNull(queryDto.getProjectId()),TdProject::getProjectId,queryDto.getProjectId())
.eq(StrUtil.isNotBlank(queryDto.getType()),TdProject::getType,queryDto.getType())
.eq(Objects.nonNull(queryDto.getCarTypeId()),TdProject::getCarTypeId,queryDto.getCarTypeId())
.eq(StrUtil.isNotBlank(queryDto.getSubject()),TdProject::getSubject,queryDto.getSubject())
.eq(StrUtil.isNotBlank(queryDto.getDriveType()),TdProject::getDriveType,queryDto.getDriveType())
.eq(TdProject::getIsActive, Constants.IS_ACTIVE_TRUE)
.orderByAsc(TdProject::getShowOrder);
List<TdProject> tdProjects = this.getBaseMapper().selectList(queryWrapper);
if (CollectionUtil.isNotEmpty(tdProjects)){
for (TdProject tdProject : tdProjects) {
ProjectVo projectVo = new ProjectVo();
BeanUtils.copyProperties(tdProject,projectVo);
//查询项目视频
List<TdVideos> videoList = videosService.list(new QueryWrapper<TdVideos>().lambda().eq(TdVideos::getTypeId, tdProject.getProjectId()).orderByAsc(TdVideos::getShowOrder));
if (CollectionUtil.isNotEmpty(videoList)){
projectVo.setVideoList(videoList);
projectVo.setImageUrl(videoList.get(0).getVideoImage());
}
resultList.add(projectVo);
}
}
return resultList;
}
}

View File

@ -2,18 +2,32 @@ package com.jwl.driver.server.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.generator.config.IFileCreate;
import com.google.gson.JsonObject;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.constant.ErrorCode;
import com.jwl.driver.server.dto.QuestionAddDto;
import com.jwl.driver.server.dto.QuestionQueryDto;
import com.jwl.driver.server.dto.TestQuestionTypeDto;
import com.jwl.driver.server.entity.TdQuestion;
import com.jwl.driver.server.entity.TdSysConfig;
import com.jwl.driver.server.entity.TdSysConfigList;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.TdQuestionMapper;
import com.jwl.driver.server.redis.RedisCache;
import com.jwl.driver.server.service.ITdQuestionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdQuestionVersionService;
import com.jwl.driver.server.service.ITdSysConfigListService;
import com.jwl.driver.server.service.ITdSysConfigService;
import com.jwl.driver.server.vo.QuestionVo;
import com.jwl.driver.server.vo.QusetionCategoryVo;
import com.jwl.driver.server.vo.QusetionVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -29,6 +43,7 @@ import java.util.stream.Collectors;
* @since 2023-08-10
*/
@Service
@Slf4j
public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuestion> implements ITdQuestionService {
@Autowired
@ -37,52 +52,151 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
@Autowired
private ITdSysConfigListService configListService;
@Autowired
private RedisCache redisCache;
@Autowired
private ITdQuestionVersionService versionService;
@Override
public TdQuestion queryQuestionById(QuestionQueryDto queryDto) {
return this.getBaseMapper().selectById(queryDto.getQuestionId());
public QuestionVo queryQuestionById(QuestionQueryDto queryDto) {
QuestionQueryDto newDto = new QuestionQueryDto()
.setQuestionId(queryDto.getQuestionId());
List<QuestionVo> questionVos = queryQuestion(newDto);
return CollectionUtil.isEmpty(questionVos) ? null : questionVos.get(0);
}
@Override
public List<TdQuestion> queryQuestionByIdList(QuestionQueryDto queryDto) {
LambdaQueryWrapper<TdQuestion> queryWrapper = new LambdaQueryWrapper<TdQuestion>()
.in(TdQuestion::getQuestionId,queryDto.getQuestionIdList());
public List<QuestionVo> queryQuestionByIdList(QuestionQueryDto queryDto) {
return this.getBaseMapper().selectList(queryWrapper);
QuestionQueryDto newDto = new QuestionQueryDto()
.setQuestionIdList(queryDto.getQuestionIdList());
return queryQuestion(newDto);
}
@Override
public List<QusetionVo> queryQuestion(QuestionQueryDto queryDto) {
return this.getBaseMapper().queryQuestion(queryDto);
public List<QuestionVo> queryQuestion(QuestionQueryDto queryDto) {
//校验题库版本是否一致
checkQuestionVersion(queryDto.getCarTypeId(), queryDto.getVersionId());
List<QuestionVo> questionVos = this.getBaseMapper().queryQuestion(queryDto);
questionOptionHandler(questionVos);
return questionVos;
}
@Override
public List<QusetionVo> getTestQuestion(QuestionQueryDto queryDto) {
List<QusetionVo> resultList = new ArrayList<>();
public List<Long> queryQuestionId(QuestionQueryDto queryDto) {
//校验题库版本是否一致
checkQuestionVersion(queryDto.getCarTypeId(), queryDto.getVersionId());
if (StrUtil.equals(Constants.SUBJECT_ONE,queryDto.getSubject())){
//40道判断题 60道单选 每题1分
List<Long> questionIds = this.getBaseMapper().queryQuestionId(queryDto);
return questionIds;
}
@Override
public List<QuestionVo> getTestQuestion(QuestionQueryDto queryDto) {
//校验题库版本是否一致
checkQuestionVersion(queryDto.getCarTypeId(), queryDto.getVersionId());
List<QuestionVo> resultList = new ArrayList<>();
TdSysConfig tdSysConfig = configService.queryConfigByKey(Constants.TEST_QUESTION_TYPE_NUM, queryDto.getCarTypeId());
if (Objects.isNull(tdSysConfig)) {
log.info("config is not exist");
throw new BusinessException("获取信息异常");
}
List<TestQuestionTypeDto> testQuestionTypeDtos = JSON.parseArray(tdSysConfig.getConfigJson(), TestQuestionTypeDto.class);
Optional<TestQuestionTypeDto> optional = testQuestionTypeDtos.stream().filter(s -> StrUtil.equals(s.getSubject(), queryDto.getSubject())).findFirst();
if (optional.isPresent()) {
TestQuestionTypeDto testQuestionTypeDto = optional.get();
List<TestQuestionTypeDto.TestOfChapter> chapterList = testQuestionTypeDto.getChapterList();
if (CollectionUtil.isEmpty(chapterList)){
return resultList;
}
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
//判断题
if (Objects.nonNull(testOfChapter.getJudgeNum()) && testOfChapter.getJudgeNum() > 0) {
queryDto.setType(Constants.QUESTION_TYPE_ONE)
.setNum(60);
.setChapter(testOfChapter.getChapter())
.setNum(testOfChapter.getJudgeNum());
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
}
}
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
//单选
if (Objects.nonNull(testOfChapter.getRadioNum()) && testOfChapter.getRadioNum() > 0) {
queryDto.setType(Constants.QUESTION_TYPE_TWO)
.setNum(40);
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
}else if(StrUtil.equals(Constants.SUBJECT_FOUR,queryDto.getSubject())){
//20道判断题 20道单选 10道多选每题2分如果各车型不统一 可以配在数据库里
queryDto.setType(Constants.QUESTION_TYPE_TWO)
.setNum(20);
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
queryDto.setType(Constants.QUESTION_TYPE_ONE)
.setNum(20);
.setChapter(testOfChapter.getChapter())
.setNum(testOfChapter.getRadioNum());
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
}
}
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
//多选
if (Objects.nonNull(testOfChapter.getMultipleChoiceNum()) && testOfChapter.getMultipleChoiceNum() > 0) {
queryDto.setType(Constants.QUESTION_TYPE_THREE)
.setNum(10);
.setChapter(testOfChapter.getChapter())
.setNum(testOfChapter.getMultipleChoiceNum());
resultList.addAll(this.getBaseMapper().queryQuestionByRandom(queryDto));
}
}
}
questionOptionHandler(resultList);
return resultList;
}
@Override
public List<Long> getTestQuestionId(QuestionQueryDto queryDto) {
//校验题库版本是否一致
checkQuestionVersion(queryDto.getCarTypeId(), queryDto.getVersionId());
List<Long> resultList = new ArrayList<>();
TdSysConfig tdSysConfig = configService.queryConfigByKey(Constants.TEST_QUESTION_TYPE_NUM, queryDto.getCarTypeId());
if (Objects.isNull(tdSysConfig)) {
log.info("config is not exist");
throw new BusinessException("获取信息异常");
}
List<TestQuestionTypeDto> testQuestionTypeDtos = JSON.parseArray(tdSysConfig.getConfigJson(), TestQuestionTypeDto.class);
Optional<TestQuestionTypeDto> optional = testQuestionTypeDtos.stream().filter(s -> StrUtil.equals(s.getSubject(), queryDto.getSubject())).findFirst();
if (optional.isPresent()) {
TestQuestionTypeDto testQuestionTypeDto = optional.get();
List<TestQuestionTypeDto.TestOfChapter> chapterList = testQuestionTypeDto.getChapterList();
if (CollectionUtil.isEmpty(chapterList)){
return resultList;
}
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
//判断题
if (Objects.nonNull(testOfChapter.getJudgeNum()) && testOfChapter.getJudgeNum() > 0) {
queryDto.setType(Constants.QUESTION_TYPE_ONE)
.setChapter(testOfChapter.getChapter())
.setNum(testOfChapter.getJudgeNum());
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
}
}
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
//单选
if (Objects.nonNull(testOfChapter.getRadioNum()) && testOfChapter.getRadioNum() > 0) {
queryDto.setType(Constants.QUESTION_TYPE_TWO)
.setChapter(testOfChapter.getChapter())
.setNum(testOfChapter.getRadioNum());
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
}
}
for (TestQuestionTypeDto.TestOfChapter testOfChapter : chapterList) {
//多选
if (Objects.nonNull(testOfChapter.getMultipleChoiceNum()) && testOfChapter.getMultipleChoiceNum() > 0) {
queryDto.setType(Constants.QUESTION_TYPE_THREE)
.setChapter(testOfChapter.getChapter())
.setNum(testOfChapter.getMultipleChoiceNum());
resultList.addAll(this.getBaseMapper().queryQuestionIdByRandom(queryDto));
}
}
}
return resultList;
}
@ -91,18 +205,28 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
List<QusetionCategoryVo> resultList = new ArrayList<>();
//获取题目
List<TdQuestion> tdQuestions = queryQuestionByIdList(queryDto);
if (CollectionUtil.isEmpty(tdQuestions)){
List<QuestionVo> tdQuestionVos = queryQuestionByIdList(queryDto);
if (CollectionUtil.isEmpty(tdQuestionVos)) {
return resultList;
}
//获取分类
List<TdSysConfigList> categoryList = configListService.querySysConfigList(Constants.QUESTION_CATEGORY, Constants.DEFAULT_CARTYPE_ID);
Map<String, String> categoryMap = categoryList.stream().collect(Collectors.toMap(TdSysConfigList::getConfigItemCode, TdSysConfigList::getConfigItemName, (v1, v2) -> v1));
Map<String,Integer> totalMap = new HashMap<>();
for (TdQuestion tdQuestion : tdQuestions) {
String category = tdQuestion.getCategory();
if (StrUtil.isBlank(category)){
final Integer carTypeId = tdQuestionVos.get(0).getCarTypeId();
final String subject = tdQuestionVos.get(0).getSubject();
//获取分类
List<TdSysConfigList> categoryList = new ArrayList<>();
if (StrUtil.equals(Constants.SUBJECT_ONE,subject)){
categoryList = configListService.querySysConfigList(Constants.QUESTION_CATEGORY_OF_SUBJECT_ONE, carTypeId);
} else if (StrUtil.equals(Constants.SUBJECT_FOUR,subject)){
categoryList = configListService.querySysConfigList(Constants.QUESTION_CATEGORY_OF_SUBJECT_FOUR, carTypeId);
}
Map<String, String> categoryMap = categoryList.stream().collect(Collectors.toMap(TdSysConfigList::getConfigItemCode, TdSysConfigList::getConfigItemName, (v1, v2) -> v1));
Map<String, Integer> totalMap = new HashMap<>();
Map<String, List<Long>> errorQuestionIdMap = new HashMap<>();
for (QuestionVo tdQuestionVo : tdQuestionVos) {
String category = tdQuestionVo.getCategory();
if (StrUtil.isBlank(category)) {
continue;
}
String[] split = category.split(",");
@ -110,8 +234,13 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
if (totalMap.containsKey(s)) { //判断Map集合中是否有该字符
Integer value = totalMap.get(s); //通过key找出集合中的value
totalMap.put(s, value + 1); //将值的数据加1然后添加到集合中去
List<Long> errorQuestionIdList = errorQuestionIdMap.get(s);
errorQuestionIdList.add(tdQuestionVo.getQuestionId());
} else {
totalMap.put(s,1); //此时集合中没有该Key,所以将该字符作为键加入到集合中
totalMap.put(s, 1); //此时集合中没有该Key,所以将该字符作为键加入到集合中
List<Long> errorQuestionIdList = new ArrayList<>();
errorQuestionIdList.add(tdQuestionVo.getQuestionId());
errorQuestionIdMap.put(s, errorQuestionIdList);
}
}
}
@ -119,7 +248,8 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
for (String category : totalMap.keySet()) {
QusetionCategoryVo categoryVo = new QusetionCategoryVo()
.setCategory(category)
.setCategoryName(categoryMap.getOrDefault(category,"其他类型"))
.setErrorQuestionIdList(errorQuestionIdMap.get(category))
.setCategoryName(categoryMap.getOrDefault(category, "其他类型"))
.setNum(totalMap.get(category));
resultList.add(categoryVo);
}
@ -127,7 +257,112 @@ public class TdQuestionServiceImpl extends ServiceImpl<TdQuestionMapper, TdQuest
}
@Override
public int updateQuestion(QusetionVo qusetionVo) {
return this.getBaseMapper().updateQuestion(qusetionVo);
public int updateQuestion(QuestionVo questionVo) {
return this.getBaseMapper().updateQuestion(questionVo);
}
@Override
public Boolean insertQuestion(QuestionAddDto addDto) {
TdQuestion question = new TdQuestion();
BeanUtils.copyProperties(addDto,question);
//获取该车型最大的排序
if (Objects.isNull(question.getShowOrder())){
Integer sort = this.getBaseMapper().queryMaxSort(question.getCarTypeId());
if (Objects.isNull(sort)){
sort = 1;
}else {
sort = sort + 1;
}
question.setShowOrder(sort);
}
question.setIsActive(Constants.IS_ACTIVE_TRUE);
return this.save(question);
}
@Override
public Map<String, Integer> querySpecialNum(QuestionQueryDto queryDto) {
//校验题库版本是否一致
checkQuestionVersion(queryDto.getCarTypeId(), queryDto.getVersionId());
Map<String, Integer> resultMap = redisCache.getCacheObject(Constants.SPECIAL_NUM_PREFIX + queryDto.getCarTypeId() + "_" + queryDto.getSubject());
if (Objects.nonNull(resultMap)) {
return resultMap;
}
resultMap = this.getBaseMapper().querySpecialNum(queryDto);
if (CollectionUtil.isEmpty(resultMap)) {
return resultMap;
}
TdSysConfig tdSysConfig = configService.queryConfigByKey(Constants.REDIS_EXPIRE_TIME, Constants.DEFAULT_CARTYPE_ID);
if (Objects.isNull(tdSysConfig)) {
log.info("config is not exist");
throw new BusinessException("系统异常");
}
// 塞入redis中
redisCache.setCacheObject(Constants.SPECIAL_NUM_PREFIX + queryDto.getCarTypeId() + "_" + queryDto.getSubject(), resultMap, Long.parseLong(tdSysConfig.getConfigValue()));
return resultMap;
}
/**
*
*/
private void questionOptionHandler(List<QuestionVo> questionVos) {
if (CollectionUtil.isNotEmpty(questionVos)) {
for (QuestionVo questionVo : questionVos) {
//如果选项A没有值 则为判断题
List<QuestionVo.QuestionOption> optionList = new ArrayList<>();
if (StrUtil.isBlank(questionVo.getChooseA()) || StrUtil.equals(questionVo.getType(), Constants.QUESTION_TYPE_ONE)) {
optionList.add(new QuestionVo.QuestionOption("A", "正确", "1"));
optionList.add(new QuestionVo.QuestionOption("B", "错误", "2"));
} else {
//起码ABCD都有
optionList.add(new QuestionVo.QuestionOption("A", questionVo.getChooseA(), "1"));
optionList.add(new QuestionVo.QuestionOption("B", questionVo.getChooseB(), "2"));
optionList.add(new QuestionVo.QuestionOption("C", questionVo.getChooseC(), "3"));
optionList.add(new QuestionVo.QuestionOption("D", questionVo.getChooseD(), "4"));
if (StrUtil.isNotBlank(questionVo.getChooseE())) {
optionList.add(new QuestionVo.QuestionOption("E", questionVo.getChooseE(), "5"));
}
if (StrUtil.isNotBlank(questionVo.getChooseF())) {
optionList.add(new QuestionVo.QuestionOption("F", questionVo.getChooseF(), "6"));
}
if (StrUtil.isNotBlank(questionVo.getChooseG())) {
optionList.add(new QuestionVo.QuestionOption("G", questionVo.getChooseG(), "7"));
}
}
questionVo.setOptionList(optionList);
}
}
}
/**
*
*
* @param carTypeId
* @param version
*/
private void checkQuestionVersion(Integer carTypeId, Long version) {
if (Objects.isNull(carTypeId) || Objects.isNull(version)) {
return;
}
Long versionId = versionService.currentVersion(carTypeId);
if (!Objects.equals(versionId, version)) {
throw new BusinessException(ErrorCode.VERSION_ERROR, "题库已更新");
}
}
public static void main(String[] args) {
List<TestQuestionTypeDto> testQuestionTypeDtos = new ArrayList<>();
String jsonString = JSONArray.toJSONString(testQuestionTypeDtos);
System.out.println(jsonString);
List<TestQuestionTypeDto> testQuestionTypeDtos1 = JSONArray.parseArray(jsonString, TestQuestionTypeDto.class);
System.out.println(testQuestionTypeDtos1);
}
}

View File

@ -1,17 +1,27 @@
package com.jwl.driver.server.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.dto.SecurityUser;
import com.jwl.driver.server.dto.TestQueryDto;
import com.jwl.driver.server.dto.TestSubmitDto;
import com.jwl.driver.server.entity.TdQuestionTest;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.TdQuestionTestMapper;
import com.jwl.driver.server.service.ITdQuestionTestService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.util.SecurityUtil;
import com.jwl.driver.server.vo.TestTotalVo;
import io.swagger.models.auth.In;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.OptionalDouble;
/**
* <p>
@ -26,13 +36,47 @@ public class TdQuestionTestServiceImpl extends ServiceImpl<TdQuestionTestMapper,
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean testSubmit(TestSubmitDto submitDto) {
public TdQuestionTest testSubmit(TestSubmitDto submitDto) {
TdQuestionTest questionTest = new TdQuestionTest();
BeanUtils.copyProperties(submitDto,questionTest);
BeanUtils.copyProperties(submitDto, questionTest);
questionTest.setUserId(SecurityUtil.getUserId())
.setCreateTime(LocalDateTime.now());
boolean save = this.save(questionTest);
if (!save){
throw new BusinessException("考试成绩提交失败");
}
return this.save(questionTest);
return questionTest;
}
@Override
public TestTotalVo testTotal(TestQueryDto queryDto) {
TestTotalVo testTotalVo = new TestTotalVo();
LambdaQueryWrapper<TdQuestionTest> queryWrapper = new LambdaQueryWrapper<TdQuestionTest>()
.eq(TdQuestionTest::getCarTypeId, queryDto.getCarTypeId())
.eq(TdQuestionTest::getSubject, queryDto.getSubject())
.eq(TdQuestionTest::getUserId, SecurityUtil.getUserId())
.orderByDesc(TdQuestionTest::getCreateTime);
List<TdQuestionTest> list = this.list(queryWrapper);
Long passNum = list.stream().filter(s -> s.getScore() >= 90).count();
testTotalVo.setTestNum(list.size())
.setPassNum(passNum.intValue());
//取最近的五次
if (CollectionUtil.isNotEmpty(list) && list.size() > 5) {
list = list.subList(0, 5);
}
List<TdQuestionTest> recentTestList = CollectionUtil.reverse(list);
//最近五次的平均分
OptionalDouble averaged = recentTestList.stream().mapToInt(TdQuestionTest::getScore).average();
Integer average = 0;
if (averaged.isPresent()){
Double averageScore = averaged.getAsDouble();
average = averageScore.intValue();
}
testTotalVo.setRecentTestList(recentTestList)
.setRecentAverageScore(average);
return testTotalVo;
}
}

View File

@ -0,0 +1,90 @@
package com.jwl.driver.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.entity.TdQuestionVersion;
import com.jwl.driver.server.entity.TdSysConfig;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.TdQuestionVersionMapper;
import com.jwl.driver.server.redis.RedisCache;
import com.jwl.driver.server.service.ITdQuestionVersionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdSysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-09-03
*/
@Service
@Slf4j
public class TdQuestionVersionServiceImpl extends ServiceImpl<TdQuestionVersionMapper, TdQuestionVersion> implements ITdQuestionVersionService {
@Autowired
private RedisCache redisCache;
@Autowired
private ITdSysConfigService configService;
@Override
public Long currentVersion(Integer carTypeId) {
Integer value = redisCache.getCacheObject(Constants.QUESTION_VERSOPN_PREFIX + carTypeId);
if (value !=null){
return value.longValue();
}
LambdaQueryWrapper<TdQuestionVersion> cond = new LambdaQueryWrapper<TdQuestionVersion>()
.eq(TdQuestionVersion::getCarTypeId,carTypeId)
.eq(TdQuestionVersion::getIsActive,Constants.IS_ACTIVE_TRUE);
TdQuestionVersion tdQuestionVersion = this.getBaseMapper().selectOne(cond);
if (Objects.isNull(tdQuestionVersion)){
throw new BusinessException("题库版本异常");
}
TdSysConfig tdSysConfig = configService.queryConfigByKey(Constants.REDIS_EXPIRE_TIME, Constants.DEFAULT_CARTYPE_ID);
if (Objects.isNull(tdSysConfig)){
log.info("config is not exist");
throw new BusinessException("系统未知异常");
}
// 塞入redis中
redisCache.setCacheObject(Constants.QUESTION_VERSOPN_PREFIX + carTypeId,tdQuestionVersion.getVersionId(),Long.parseLong(tdSysConfig.getConfigValue()));
return tdQuestionVersion.getVersionId();
}
@Override
public Boolean addVersion(TdQuestionVersion versionDto) {
LambdaQueryWrapper<TdQuestionVersion> cond = new LambdaQueryWrapper<TdQuestionVersion>()
.eq(TdQuestionVersion::getCarTypeId,versionDto.getCarTypeId())
.eq(TdQuestionVersion::getIsActive,Constants.IS_ACTIVE_TRUE);
TdQuestionVersion tdQuestionVersion = this.getBaseMapper().selectOne(cond);
if (Objects.nonNull(tdQuestionVersion)){
tdQuestionVersion.setIsActive(Constants.IS_ACTIVE_FALSE);
this.getBaseMapper().updateById(tdQuestionVersion);
}
TdQuestionVersion newVersion = new TdQuestionVersion();
BeanUtils.copyProperties(versionDto,newVersion);
newVersion.setCreateTime(LocalDateTime.now())
.setIsActive(Constants.IS_ACTIVE_TRUE);
this.baseMapper.insert(newVersion);
//删除原redis
redisCache.deleteObject(Constants.QUESTION_VERSOPN_PREFIX + versionDto.getCarTypeId());
redisCache.deleteObjectLike(Constants.SPECIAL_NUM_PREFIX + versionDto.getCarTypeId() );
return Boolean.TRUE;
}
}

View File

@ -1,18 +1,22 @@
package com.jwl.driver.server.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.entity.TdSysConfig;
import com.jwl.driver.server.entity.TdSysConfigList;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.TdSysConfigListMapper;
import com.jwl.driver.server.redis.RedisCache;
import com.jwl.driver.server.service.ITdSysConfigListService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdSysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -24,17 +28,44 @@ import java.util.stream.Collectors;
* @since 2023-08-10
*/
@Service
@Slf4j
public class TdSysConfigListServiceImpl extends ServiceImpl<TdSysConfigListMapper, TdSysConfigList> implements ITdSysConfigListService {
@Autowired
private RedisCache redisCache;
@Autowired
private ITdSysConfigService configService;
@Override
public List<TdSysConfigList> querySysConfigList(String configKey, Integer carTypeId) {
List<TdSysConfigList> configLists = redisCache.getCacheObject(Constants.CONFIG_LIST_PREFIX + configKey + "_" + carTypeId);
if (CollectionUtil.isNotEmpty(configLists)) {
return configLists;
}
//redis中没有则查询数据库
LambdaQueryWrapper<TdSysConfigList> queryWrapper = new LambdaQueryWrapper<TdSysConfigList>()
.eq(TdSysConfigList::getCarTypeId, carTypeId)
.eq(TdSysConfigList::getConfigKey, configKey)
.eq(TdSysConfigList::getIsActive, Constants.IS_ACTIVE_TRUE)
.orderByAsc(TdSysConfigList::getShowOrder);
configLists = this.getBaseMapper().selectList(queryWrapper);
return this.getBaseMapper().selectList(queryWrapper);
if (CollectionUtil.isEmpty(configLists)) {
return configLists;
}
//获取redis缓存时间
TdSysConfig tdSysConfig = configService.queryConfigByKey(Constants.REDIS_EXPIRE_TIME, Constants.DEFAULT_CARTYPE_ID);
if (Objects.isNull(tdSysConfig)) {
log.info("config is not exist");
throw new BusinessException("系统异常");
}
// 塞入redis中
redisCache.setCacheObject(Constants.CONFIG_LIST_PREFIX + configKey + "_" + carTypeId, configLists, Long.parseLong(tdSysConfig.getConfigValue()));
return configLists;
}
@Override
@ -55,4 +86,10 @@ public class TdSysConfigListServiceImpl extends ServiceImpl<TdSysConfigListMappe
}
return resultMap;
}
@Override
public Integer querySysConfigListNum(String configKey, Integer carTypeId) {
List<TdSysConfigList> configLists = querySysConfigList(configKey, carTypeId);
return CollectionUtil.isEmpty(configLists) ? 0 : configLists.size();
}
}

View File

@ -1,21 +1,23 @@
package com.jwl.driver.server.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.entity.TdSysConfig;
import com.jwl.driver.server.entity.TdSysConfigList;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.TdSysConfigMapper;
import com.jwl.driver.server.redis.RedisCache;
import com.jwl.driver.server.service.ITdSysConfigService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -30,24 +32,50 @@ import java.util.stream.Collectors;
@Slf4j
public class TdSysConfigServiceImpl extends ServiceImpl<TdSysConfigMapper, TdSysConfig> implements ITdSysConfigService {
@Autowired
private RedisCache redisCache;
@Override
public TdSysConfig queryConfigByKey(String configKey, Integer carTypeId) {
log.info("获取系统配置参数configKey{}", configKey);
TdSysConfig config = redisCache.getCacheObject(Constants.CONFIG_PREFIX + configKey + "_" + carTypeId);
if (Objects.nonNull(config)){
return config;
}
LambdaQueryWrapper<TdSysConfig> queryWrapper = new QueryWrapper<TdSysConfig>().lambda()
.eq(TdSysConfig::getCarTypeId,carTypeId)
.eq(TdSysConfig::getConfigKey, configKey)
.eq(TdSysConfig::getIsActive, Constants.IS_ACTIVE_TRUE);
return getOne(queryWrapper);
config = getOne(queryWrapper);
if (Objects.isNull(config)){
return config;
}
//获取redis缓存时间
TdSysConfig tdSysConfig = null;
if (StrUtil.equals(configKey,Constants.REDIS_EXPIRE_TIME)){
tdSysConfig = config;
}else {
tdSysConfig = queryConfigByKey(Constants.REDIS_EXPIRE_TIME, Constants.DEFAULT_CARTYPE_ID);
}
if (Objects.isNull(tdSysConfig)) {
log.info("config is not exist");
throw new BusinessException("系统异常");
}
// 塞入redis中
redisCache.setCacheObject(Constants.CONFIG_PREFIX + configKey + "_" + carTypeId, config, Long.parseLong(tdSysConfig.getConfigValue()));
return config;
}
@Override
public String queryConfigValueByKey(String configKey, Integer carTypeId) {
log.info("获取系统配置参数configKey{}", configKey);
LambdaQueryWrapper<TdSysConfig> queryWrapper = new QueryWrapper<TdSysConfig>().lambda()
.eq(TdSysConfig::getCarTypeId,carTypeId)
.eq(TdSysConfig::getConfigKey, configKey)
.eq(TdSysConfig::getIsActive, Constants.IS_ACTIVE_TRUE);
TdSysConfig config = getOne(queryWrapper);
TdSysConfig config = queryConfigByKey(configKey,carTypeId);
if(null == config) {
return null;
}

View File

@ -1,10 +1,28 @@
package com.jwl.driver.server.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.dto.UserMemberDto;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.entity.TdMember;
import com.jwl.driver.server.entity.TdSysUserMember;
import com.jwl.driver.server.exception.BusinessException;
import com.jwl.driver.server.mapper.TdSysUserMemberMapper;
import com.jwl.driver.server.service.IOrderPayInfoService;
import com.jwl.driver.server.service.ITdMemberService;
import com.jwl.driver.server.service.ITdSysUserMemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.service.ITdSysUserService;
import com.jwl.driver.server.vo.UserMemberVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Objects;
/**
* <p>
@ -17,4 +35,69 @@ import org.springframework.stereotype.Service;
@Service
public class TdSysUserMemberServiceImpl extends ServiceImpl<TdSysUserMemberMapper, TdSysUserMember> implements ITdSysUserMemberService {
@Autowired
private IOrderPayInfoService payInfoService;
@Autowired
private ITdMemberService memberService;
@Autowired
private ITdSysUserMemberService userMemberService;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean purchaseMember(OrderPayInfo payInfo) {
final LocalDateTime nowTime = LocalDateTime.now();
if (Objects.isNull(payInfo)){
throw new BusinessException("订单信息不存在");
}
final Long userId = payInfo.getUserId();
final Integer memberId = Integer.parseInt(payInfo.getPurchaseProductId());
// 查询会员 不管有效无效
TdMember member = memberService.getById(memberId);
if (Objects.isNull(member)){
throw new BusinessException("购买的会员不存在");
}
//查看该用户是否存在有效会员
LambdaQueryWrapper<TdSysUserMember> cond = new LambdaQueryWrapper<TdSysUserMember>()
.eq(TdSysUserMember::getUserId,userId)
.eq(TdSysUserMember::getMemberId,memberId)
.gt(TdSysUserMember::getEndDate, nowTime);
TdSysUserMember userMember = this.getOne(cond);
//如果用户没购买该会员 或者该会员已过期就新建一个会员
if (Objects.isNull(userMember)){
userMember = new TdSysUserMember()
.setMemberId(memberId)
.setUserId(userId)
.setCreateTime(nowTime)
.setUpdateTime(nowTime)
.setStartDate(LocalDateTime.of(LocalDate.now(), LocalTime.MIN))
.setEndDate(LocalDateTime.of(LocalDate.now(), LocalTime.MIN).plusDays(1).minusSeconds(1));
boolean save = this.save(userMember);
if (!save){
throw new BusinessException("充值会员失败");
}
}
LocalDateTime endTime = userMember.getEndDate();
if (StrUtil.equals(member.getUnit(),"1")){
endTime = endTime.plusDays(member.getDuration());
}else if (StrUtil.equals(member.getUnit(),"2")){
endTime = endTime.plusMonths(member.getDuration());
} else if (StrUtil.equals(member.getUnit(),"3")) {
endTime = endTime.plusYears(member.getDuration());
}
userMember.setEndDate(endTime.minusDays(1));
boolean update = this.update(userMember, cond);
if (!update){
throw new BusinessException("会员充值失败");
}
return Boolean.TRUE;
}
@Override
public List<UserMemberVo> queryUserMemberList(UserMemberDto userMemberDto) {
return getBaseMapper().queryUserMemberList(userMemberDto);
}
}

View File

@ -2,8 +2,10 @@ package com.jwl.driver.server.service.impl;
import cn.hutool.core.util.PhoneUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jwl.driver.server.constant.Constants;
import com.jwl.driver.server.dto.DriverSchoolDto;
import com.jwl.driver.server.dto.LoginUserDto;
import com.jwl.driver.server.dto.SecurityUser;
import com.jwl.driver.server.entity.TdSysUser;
@ -12,11 +14,9 @@ import com.jwl.driver.server.mapper.TdSysUserMapper;
import com.jwl.driver.server.redis.RedisCache;
import com.jwl.driver.server.service.ITdSysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwl.driver.server.util.DateTimeUtil;
import com.jwl.driver.server.util.SecurityUtil;
import com.jwl.driver.server.util.SmsUtil;
import com.jwl.driver.server.util.TokenThreadUtil;
import com.jwl.driver.server.util.*;
import com.jwl.driver.server.vo.LoginUserVo;
import com.jwl.driver.server.vo.SchoolVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -49,7 +49,7 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
private Integer codeExpireTime;
@Override
public String code(String phone) {
public Boolean code(String phone) {
if (!PhoneUtil.isPhone(phone)) {
throw new BusinessException("手机号格式不正确");
@ -62,7 +62,7 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
String code = SmsUtil.sendMessage(phone);
redisCache.setCacheObject((Constants.MESSAGE_CODE_PREFIX + phone), code, codeExpireTime, TimeUnit.SECONDS);
return code;
return Boolean.TRUE;
}
@Override
@ -87,16 +87,37 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
TdSysUser tdSysUser = this.baseMapper.selectOne(cond);
//todo 用户基础信息填写这里还要完善一下
if (tdSysUser == null) {
tdSysUser = new TdSysUser()
.setUserName("车友")
.setAvatar("")
.setPhone(loginUserDto.getPhone())
.setCreateTime(LocalDateTime.now());
//根据id查询驾校信息
if(!StringUtil.isNullOrEmpty(loginUserDto.getId())){
String result = HttpUtils.sendGet("https://xueche.ahduima.com/duima/applet/school/"+loginUserDto.getId());
JSONObject jsonObject = JSONObject.parseObject(result);
if(jsonObject.get("data") != null){
SchoolVO schoolVO = JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("data")), SchoolVO.class);
tdSysUser.setSchoolId(schoolVO.getSchoolId())
.setSchoolName(schoolVO.getSchoolName())
.setSchoolPhone(schoolVO.getPhone());
}
}
int insert = this.getBaseMapper().insert(tdSysUser);
if (insert != 1) {
throw new BusinessException("用户注册异常");
}
}
//清除上一个人登陆的token信息
String oldToken = redisCache.getCacheObject(Constants.PHONE_PREFIX + tdSysUser.getPhone());
if (StrUtil.isNotBlank(oldToken)){
redisCache.deleteObject(Constants.PHONE_PREFIX + tdSysUser.getPhone());
redisCache.deleteObject(oldToken);
}
String token = UUID.randomUUID().toString();
LoginUserVo loginUserVo = new LoginUserVo();
BeanUtils.copyProperties(tdSysUser, loginUserVo);
@ -104,6 +125,7 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
loginUserVo.setDays(DateTimeUtil.getIntervalDays(loginUserVo.getCreateTime(),LocalDateTime.now()) + 1);
// 存入redis
redisCache.setCacheObject(token, tdSysUser, tokenExpireTime, TimeUnit.DAYS);
redisCache.setCacheObject(Constants.PHONE_PREFIX + tdSysUser.getPhone(), token, tokenExpireTime, TimeUnit.DAYS);
return loginUserVo;
}
@ -111,6 +133,11 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
public Boolean loginOut() {
String token = TokenThreadUtil.getToken();
if (StrUtil.isNotBlank(token)) {
TdSysUser tdSysUser = redisCache.getCacheObject(token);
if (Objects.nonNull(tdSysUser) && Objects.nonNull(tdSysUser.getPhone())){
redisCache.deleteObject(Constants.PHONE_PREFIX + tdSysUser.getPhone());
}
redisCache.deleteObject(token);
}
return Boolean.TRUE;
@ -136,7 +163,7 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
}
@Override
public Boolean bindSchool(LoginUserDto userDto) {
public Boolean bindSchool(DriverSchoolDto schoolDto) {
SecurityUser loginUser = SecurityUtil.getLoginUser();
LambdaQueryWrapper<TdSysUser> cond = new LambdaQueryWrapper<TdSysUser>()
@ -146,7 +173,9 @@ public class TdSysUserServiceImpl extends ServiceImpl<TdSysUserMapper, TdSysUser
if (Objects.isNull(tdSysUser)){
throw new BusinessException("用户不存在或者已被删除");
}
tdSysUser.setSchoolId(userDto.getSchoolId());
tdSysUser.setSchoolId(schoolDto.getSchoolId())
.setSchoolName(schoolDto.getSchoolName())
.setSchoolPhone(schoolDto.getSchoolPhone());
boolean result = this.updateById(tdSysUser);
if (!result){

View File

@ -1,20 +0,0 @@
package com.jwl.driver.server.service.impl;
import com.jwl.driver.server.entity.TdTestProject;
import com.jwl.driver.server.mapper.TdTestProjectMapper;
import com.jwl.driver.server.service.ITdTestProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Service
public class TdTestProjectServiceImpl extends ServiceImpl<TdTestProjectMapper, TdTestProject> implements ITdTestProjectService {
}

View File

@ -1,20 +0,0 @@
package com.jwl.driver.server.service.impl;
import com.jwl.driver.server.entity.TdTestProjectVideos;
import com.jwl.driver.server.mapper.TdTestProjectVideosMapper;
import com.jwl.driver.server.service.ITdTestProjectVideosService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Service
public class TdTestProjectVideosServiceImpl extends ServiceImpl<TdTestProjectVideosMapper, TdTestProjectVideos> implements ITdTestProjectVideosService {
}

View File

@ -0,0 +1,20 @@
package com.jwl.driver.server.service.impl;
import com.jwl.driver.server.entity.TdVideos;
import com.jwl.driver.server.mapper.TdVideosMapper;
import com.jwl.driver.server.service.ITdVideosService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-20
*/
@Service
public class TdVideosServiceImpl extends ServiceImpl<TdVideosMapper, TdVideos> implements ITdVideosService {
}

View File

@ -0,0 +1,46 @@
package com.jwl.driver.server.util;
import com.wechat.pay.java.core.util.IOUtil;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
/**
* @author
* @description
* @create 2023/8/24 14:41
*/
public class InputStreamUtil {
// 获取文件内容
public static String getContentStr(String filePath){
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
String contentStr;
try {
Throwable var2 = null;
try {
contentStr = IOUtil.toString(inputStream);
} catch (Throwable var13) {
var2 = var13;
throw var13;
} finally {
if (inputStream != null) {
if (var2 != null) {
try {
inputStream.close();
} catch (Throwable var12) {
var2.addSuppressed(var12);
}
} else {
inputStream.close();
}
}
}
} catch (IOException var15) {
throw new UncheckedIOException(var15);
}
return contentStr;
}
}

View File

@ -35,7 +35,8 @@ public class SmsUtil {
private static String url = "dysmsapi.aliyuncs.com";
private static String appkey = "LTAI4GH1CqJtaUVpmD1oYEUZ";
private static String secret = "DFG848ea8U0QaQcdiHAYznUrCWfJzn";
private static String smsFreeSignName = "对嘛科技";
// private static String smsFreeSignName = "对嘛科技";
private static String smsFreeSignName = "金武联";
//用于存储短信验证码
// private static Map<String, String> codeMap = new HashMap<>();

View File

@ -4,12 +4,14 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
@ApiModel("微信支付")
public class AppletPayVo {
@ApiModelProperty("支付金额")
private Double money;//金额
private BigDecimal money;//金额
@ApiModelProperty("小程序端 获取的code")
private String code;//小程序端 获取的code
@ -20,6 +22,9 @@ public class AppletPayVo {
@ApiModelProperty("支付描述")
private String description;
@ApiModelProperty("商户系统的订单类型")
private String tradeType;
@ApiModelProperty("商户系统的订单号")
private String outTradeNo;

View File

@ -4,11 +4,13 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@ApiModel("H5支付")
@Data
public class H5PayVo {
@ApiModelProperty("支付金额")
private Double money;//金额
private BigDecimal money;//金额
@ApiModelProperty("用户id")
private String userId;
@ -16,6 +18,9 @@ public class H5PayVo {
@ApiModelProperty("支付描述")
private String description;
@ApiModelProperty("商户系统的订单类型")
private String tradeType;
@ApiModelProperty("商户系统的订单号")
private String outTradeNo;

View File

@ -60,6 +60,12 @@ public class LoginUserVo {
@ApiModelProperty("驾校名称")
private String schoolName;
/**
*
*/
@ApiModelProperty("驾校电话")
private String schoolPhone;
/**
*
*/

View File

@ -89,7 +89,7 @@ public class MemberVo {
*
*/
@ApiModelProperty("会员描述")
private String desc;
private String description;
/**
*

View File

@ -0,0 +1,91 @@
package com.jwl.driver.server.vo;
import com.jwl.driver.server.entity.TdVideos;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* ;
* </p>
*
* @author Automated procedures
* @since 2023-08-10
*/
@Data
@Accessors(chain = true)
@ApiModel("考试项目出参")
public class ProjectVo implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("考试项目")
private Integer projectId;
/**
*
*/
@ApiModelProperty("类型")
private String type;
/**
*
*/
@ApiModelProperty("所属科目")
private String subject;
/**
*
*/
@ApiModelProperty("车型标识")
private Integer carTypeId;
/**
* A2:B2
*/
@ApiModelProperty("驾驶类型")
private String driveType;
/**
*
*/
@ApiModelProperty("描述")
private String description;
/**
*
*/
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
/**
*
*/
@ApiModelProperty("是否生效")
private String isActive;
/**
*
*/
@ApiModelProperty("显示序号")
private Integer showOrder;
/**
* url
*/
@ApiModelProperty("图片url")
private String imageUrl;
@ApiModelProperty("视频列表")
private List<TdVideos> videoList;
}

View File

@ -0,0 +1,217 @@
package com.jwl.driver.server.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author
* @description
* @create 2023/8/13 17:13
*/
@Data
@Accessors(chain = true)
@ApiModel("驾考题目出参")
public class QuestionVo {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("题目标识")
private Long questionId;
/**
*
*/
@ApiModelProperty("题目内容")
private String question;
/**
* A
*/
@ApiModelProperty("选项A")
private String chooseA;
/**
* B
*/
@ApiModelProperty("选项B")
private String chooseB;
/**
* C
*/
@ApiModelProperty("选项C")
private String chooseC;
/**
* D
*/
@ApiModelProperty("选项D")
private String chooseD;
/**
* E
*/
@ApiModelProperty("选项E")
private String chooseE;
/**
* F
*/
@ApiModelProperty("选项F")
private String chooseF;
/**
* G
*/
@ApiModelProperty("选项G")
private String chooseG;
/**
*
*/
@ApiModelProperty("正确答案")
private String trueAnswer;
/**
*
*/
@ApiModelProperty("未知")
private String cids;
/**
*
*/
@ApiModelProperty("题型分类")
private String category;
/**
* url
*/
@ApiModelProperty("题目图片url")
private String imageUrl;
/**
*
*/
@ApiModelProperty("未知")
private String sohuImg;
/**
*
*/
@ApiModelProperty("最佳回答")
private String bestAnswer;
/**
*
*/
@ApiModelProperty("答题技巧")
private String skillInfo;
/**
*
*/
@ApiModelProperty("章节标识")
private String chapter;
/**
* 1:12:4
*/
@ApiModelProperty("所属科目1:科目12:科目4")
private String subject;
/**
*
*/
@ApiModelProperty("选择")
private String options;
@ApiModelProperty("选项列表")
private List<QuestionOption> optionList;
/**
* 1 23
*/
@ApiModelProperty("题目类型1选择题 2判断题3多选题")
private String type;
/**
*
*/
@ApiModelProperty("显示序号")
private int showOrder;
/**
*
*/
@ApiModelProperty("车型")
private Integer carTypeId;
/**
*
*/
@ApiModelProperty("是否生效")
private String isActive;
/**
* vip
*/
@ApiModelProperty("是否VIP")
private Integer isVip;
/**
*
*/
@ApiModelProperty("是否易错")
private Integer isError;
/**
* v
*/
@ApiModelProperty("是否新规")
private Integer isNew;
/**
*
*/
@ApiModelProperty("考点")
private String examKeys;
/**
* 600
*/
@ApiModelProperty("精讯600题")
private Integer isVip2;
/**
* 1
*/
@ApiModelProperty("是否密卷1")
private Integer isExam1;
/**
* 2
*/
@ApiModelProperty("是否密卷2")
private Integer isExam2;
@Data
@Accessors
@AllArgsConstructor
public static class QuestionOption{
@ApiModelProperty("选项")
private String op;
@ApiModelProperty("选项描述")
private String opDesc;
@ApiModelProperty("选项值")
private String opValue;
}
}

View File

@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author
* @description
@ -35,4 +37,10 @@ public class QusetionCategoryVo {
@ApiModelProperty("类型数量")
private Integer num;
/**
* ID
*/
@ApiModelProperty("错题ID列表")
private List<Long> errorQuestionIdList;
}

View File

@ -0,0 +1,20 @@
package com.jwl.driver.server.vo;
import lombok.Data;
@Data
public class SchoolVO {
private Long schoolId;
/** 驾校名称 */
private String schoolName;
/** 负责人 */
private String leader;
/** 联系电话 */
private String phone;
/** 部门状态0正常 1停用 */
private String status;
}

View File

@ -0,0 +1,47 @@
package com.jwl.driver.server.vo;
import com.jwl.driver.server.entity.TdQuestionTest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author
* @description
* @create 2023/8/21 0:39
*/
@Data
@Accessors(chain = true)
@ApiModel("考试成绩统计出参")
public class TestTotalVo {
private static final long serialVersionUID = 1L;
/**
*
*/
@ApiModelProperty("考试次数")
private Integer testNum;
/**
*
*/
@ApiModelProperty("合格次数")
private Integer passNum;
/**
*
*/
@ApiModelProperty("最近考试平均得分(超过五次按最近五次计算)")
private Integer recentAverageScore;
/**
*
*/
@ApiModelProperty("最近考试情况(超过五次返回最近五次)")
private List<TdQuestionTest> recentTestList;
}

View File

@ -0,0 +1,70 @@
package com.jwl.driver.server.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@Accessors(chain = true)
@ApiModel("用户学员")
public class UserMemberVo {
@ApiModelProperty("用户标识")
private Long userId;
@ApiModelProperty("手机号")
private String phone;
/**
*
*/
@ApiModelProperty("会员结束时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDate;
/**
*
*/
@ApiModelProperty("会员开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startDate;
/**
*
*/
@ApiModelProperty("会员标识")
private Integer memberId;
/**
*
*/
@ApiModelProperty("会员名称")
private String memberName;
/**
*
*/
@ApiModelProperty("车型标识")
private Integer carTypeId;
@ApiModelProperty("车型")
private String carName;
/**
*
*/
@ApiModelProperty("科目")
private String subjects;
/**
*
*/
@ApiModelProperty("会员价格,单位元")
private BigDecimal price;
}

View File

@ -1,18 +1,32 @@
spring:
# redis 配置
redis:
host: 127.0.0.1
port: 6379
# host: 127.0.0.1
# port: 6379
# database: 8
# timeout: 5000
# auth: caolin123
host: 118.31.23.45
port: 6973
database: 8
timeout: 5000
auth: caolin123
password: c12&%3s7l=
# 数据库 配置
datasource:
url: jdbc:mysql://127.0.0.1:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
# 本地
# url: jdbc:mysql://127.0.0.1:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
# username: root
# password: 123456
# 测试库
url: jdbc:mysql://118.31.23.45:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
username: root
password: 123456
password: admin231280
# 生产库
# url: jdbc:mysql://114.55.169.15:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
# username: root
# password: Zhou202109

View File

@ -1,14 +1,14 @@
spring:
# redis 配置
redis:
host: 118.31.23.45
host: 127.0.0.1
port: 6379
database: 8
timeout: 5000
password: 123456
# 数据库 配置
datasource:
url: jdbc:mysql://118.31.23.45:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/driver_server?characterEncoding=utf-8&autoReconnect=true&maxReconnects=2&useSSL=false&allowPublicKeyRetrieval=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai
username: root
password: admin231280
password: Zhou202109

View File

@ -2,10 +2,10 @@ spring:
# redis 配置
redis:
host: 118.31.23.45
port: 6379
port: 6973
database: 8
timeout: 5000
password: 123456
password: c12&%3s7l=
# 数据库 配置
datasource:

View File

@ -7,7 +7,7 @@ spring:
application:
name: '@artifactId@'
profiles:
active: test
active: prod
#mybatis
mybatis-plus:
mapper-locations: classpath*:/mapper/**Mapper.xml
@ -35,19 +35,39 @@ driver:
auth-config:
# 约定为若 preAuth 为 true则所有请求除不需权限校验url集合noAuthEndPoints外都需要身份认证
# 为 false则所有请求除需要权限校验url集合needAuthEndPoints外都不需要身份认证
preAuth: true
preAuth: false
# 不需权限校验url集合
noAuthEndPoints:
- /driver-api/v2/api-docs
- /driver-api/swagger-resources
- /driver-api/favicon.ico
- /driver-api/tdSysUser/code
- /tdQuestion/duima/list
- /tdQuestion/duima/update
- /payNoticeLog
# - /driver-api/v2/api-docs
# - /driver-api/swagger-resources
# - /driver-api/favicon.ico
# - /driver-api/tdSysUser/code
# - /driver-api/payNoticeLog
# - /driver-api/tdQuestion/duima/list
# - /driver-api/tdQuestion/duima/update
# - /driver-api/tdQuestion/queryQuestionById
# - /driver-api/tdQuestion/queryQuestionByIdList
# - /driver-api/tdQuestion/queryQuestion
# - /driver-api/tdQuestion/getTestQuestion
# - /driver-api/tdQuestion/questionCategory
# - /driver-api/tdMember/queryMember
# - /driver-api/tdSysConfig/queryConfigByKey
# - /driver-api/tdSysConfig/queryConfigValueByKey
# - /driver-api/tdSysConfig/queryConfigByKeys
# - /driver-api/tdSysConfigList/querySysConfigList
# - /driver-api/tdSysConfigList/querySysConfigMap
# - /driver-api/tdCar/list
# - driver-api/tdTestProject/queryProjectList
# 需要权限校验url集合
needAuthEndPoints:
- /driver-api/tdSysUser/loginOut
- /driver-api/tdSysUser/queryUserMessage
- /driver-api/tdSysUser/bindSchool
- /driver-api/tdQuestionTest/testSubmit
- /driver-api/tdQuestionTest/testTotal
- /driver-api/tdMember/queryUserMember
- /driver-api/applet/pay/prepay
- /driver-api/H5/pay/prepay
# token 有效期1年
token:
@ -58,14 +78,13 @@ message:
code:
expireTime: 300
wechatpay:
appId: wx756a7425037609fb
appSecret: 3e8053032b16c574e38d554ddd438cfd
mchId: 1650477646
apiV3Key: JingWuLianJiaKao20120813ZhouHong
mchSerialNo: 52974C99DFCC518EA2E5AD20C3753E38B924868D
# 路径设置没生效 不知道原因
privateKeyPath: classpath*:/wechatPay/apiclient_key.pem
payNoticeUrl: https://jwl.ahduima.com/driver-api/payNoticeLog

View File

@ -12,7 +12,7 @@
tm.DURATION,
tm.SUBJECTS,
tm.UNIT,
tm.DESC,
tm.DESCRIPTION,
tm.IS_ACTIVE
from
td_member tm
@ -42,7 +42,7 @@
tm.DURATION,
tm.SUBJECTS,
tm.UNIT,
tm.DESC,
tm.DESCRIPTION,
tm.IS_ACTIVE
from
td_sys_user_member tsum

View File

@ -1,5 +1,5 @@
<?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.jwl.driver.server.mapper.TdTestProjectMapper">
<mapper namespace="com.jwl.driver.server.mapper.TdProjectMapper">
</mapper>

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jwl.driver.server.mapper.TdQuestionMapper">
<select id="queryQuestion" resultType="com.jwl.driver.server.vo.QusetionVo">
<select id="queryQuestion" resultType="com.jwl.driver.server.vo.QuestionVo">
select
tq.QUESTION_ID,
tq.QUESTION,
@ -19,6 +19,7 @@
tq.IMAGE_URL,
tq.SOHU_IMG,
tq.BEST_ANSWER,
tq.SKILL_INFO,
tq.CHAPTER,
tq.SUBJECT,
tq.OPTIONS,
@ -62,6 +63,30 @@
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.isError !=null">
and tq.IS_ERROR = #{queryDto.isError}
</if>
<if test="queryDto.isNew !=null">
and tq.IS_NEW = #{queryDto.isNew}
</if>
<if test="queryDto.isImage !=null">
and tq.IMAGE_URL is not null
</if>
<if test="queryDto.examKey !=null and queryDto.examKey != ''">
and find_in_set(#{queryDto.examKey},tq.EXAM_KEYS)
</if>
<if test="queryDto.isVip !=null">
and tq.IS_VIP = #{queryDto.isVip}
</if>
<if test="queryDto.isVip2 !=null">
and tq.IS_VIP2 = #{queryDto.isVip2}
</if>
<if test="queryDto.isExam1 !=null">
and tq.IS_EXAM1 = #{queryDto.isExam1}
</if>
<if test="queryDto.isExam2 !=null">
and tq.IS_EXAM2 = #{queryDto.isExam2}
</if>
<if test="queryDto.cid !=null and queryDto.cid !=''">
and find_in_set(#{queryDto.cid},tq.CIDS)
</if>
@ -76,7 +101,7 @@
order by tq.SHOW_ORDER asc
</select>
<select id="queryQuestionByRandom" resultType="com.jwl.driver.server.vo.QusetionVo">
<select id="queryQuestionByRandom" resultType="com.jwl.driver.server.vo.QuestionVo">
select
tq.QUESTION_ID,
tq.QUESTION,
@ -93,6 +118,7 @@
tq.IMAGE_URL,
tq.SOHU_IMG,
tq.BEST_ANSWER,
tq.SKILL_INFO,
tq.CHAPTER,
tq.SUBJECT,
tq.OPTIONS,
@ -119,37 +145,154 @@
<if test="queryDto.type !=null">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
and tq.CHAPTER = #{queryDto.chapter}
</if>
</where>
order by rand() limit ${queryDto.num};
</select>
<update id="updateQuestion" parameterType="com.jwl.driver.server.vo.QusetionVo">
<update id="updateQuestion" parameterType="com.jwl.driver.server.vo.QuestionVo">
update td_question
<trim prefix="SET" suffixOverrides=",">
<if test="qusetionVo.isVip !=null">
IS_VIP = #{qusetionVo.isVip},
<if test="questionVo.isVip !=null">
IS_VIP = #{questionVo.isVip},
</if>
<if test="qusetionVo.isError !=null">
IS_ERROR = #{qusetionVo.isError},
<if test="questionVo.skillInfo !=null and questionVo.skillInfo !=''">
SKILL_INFO = #{questionVo.skillInfo},
</if>
<if test="qusetionVo.isNew !=null">
IS_NEW = #{qusetionVo.isNew},
<if test="questionVo.isError !=null">
IS_ERROR = #{questionVo.isError},
</if>
<if test="qusetionVo.examKeys !=null">
EXAM_KEYS = #{qusetionVo.examKeys},
<if test="questionVo.isNew !=null">
IS_NEW = #{questionVo.isNew},
</if>
<if test="qusetionVo.isVip2 !=null">
IS_VIP2 = #{qusetionVo.isVip2},
<if test="questionVo.examKeys !=null">
EXAM_KEYS = #{questionVo.examKeys},
</if>
<if test="qusetionVo.isExam1 !=null">
IS_EXAM1 = #{qusetionVo.isExam1},
<if test="questionVo.isVip2 !=null">
IS_VIP2 = #{questionVo.isVip2},
</if>
<if test="qusetionVo.isExam2 !=null">
IS_EXAM2 = #{qusetionVo.isExam2},
<if test="questionVo.isExam1 !=null">
IS_EXAM1 = #{questionVo.isExam1},
</if>
<if test="questionVo.isExam2 !=null">
IS_EXAM2 = #{questionVo.isExam2},
</if>
</trim>
where QUESTION_ID = #{qusetionVo.questionId}
where QUESTION_ID = #{questionVo.questionId}
</update>
<select id="querySpecialNum" resultType="java.util.Map">
select count(IF(IS_NEW = '1', IS_NEW, NULL)) as newQuestionNum,
count(IF(IS_ERROR = '1', IS_ERROR, NULL)) as errorQuestionNum,
count(IF(TYPE = '1', TYPE, NULL)) as judgeQuestionNum,
count(IF(TYPE = '2', TYPE, NULL)) as radioQuestionNum,
count(IF(TYPE = '3', TYPE, NULL)) as multipleChoiceQuestionNum,
count(IFNULL(IMAGE_URL, NULL)) as imageQuestionNum
from td_question
where CAR_TYPE_ID = #{queryDto.carTypeId}
and SUBJECT = #{queryDto.subject}
and IS_ACTIVE = '0'
</select>
<select id="queryQuestionId" resultType="java.lang.Long">
select
tq.QUESTION_ID
from td_question tq
left join td_point_question tpq on tq.QUESTION_ID = tpq.QUESTION_ID and tq.CAR_TYPE_ID = tpq.CAR_TYPE_ID and
tpq.IS_ACTIVE = '0'
<where>
tq.IS_ACTIVE = '0'
<if test="queryDto.questionId !=null">
and tq.QUESTION_ID = #{queryDto.questionId}
</if>
<if test="queryDto.questionIdList !=null and queryDto.questionIdList.size() > 0">
and tq.QUESTION_ID in
<foreach collection="queryDto.questionIdList" open="(" item="item" separator="," close=")">
#{item}
</foreach>
</if>
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
and tq.CHAPTER = #{queryDto.chapter}
</if>
<if test="queryDto.question !=null and queryDto.question !=''">
and tq.QUESTION like concat('%' , #{queryDto.question} , '%')
</if>
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tq.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tq.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.isError !=null">
and tq.IS_ERROR = #{queryDto.isError}
</if>
<if test="queryDto.isNew !=null">
and tq.IS_NEW = #{queryDto.isNew}
</if>
<if test="queryDto.isImage !=null">
and tq.IMAGE_URL is not null
</if>
<if test="queryDto.examKey !=null and queryDto.examKey != ''">
and find_in_set(#{queryDto.examKey},tq.EXAM_KEYS)
</if>
<if test="queryDto.isVip !=null">
and tq.IS_VIP = #{queryDto.isVip}
</if>
<if test="queryDto.isVip2 !=null">
and tq.IS_VIP2 = #{queryDto.isVip2}
</if>
<if test="queryDto.isExam1 !=null">
and tq.IS_EXAM1 = #{queryDto.isExam1}
</if>
<if test="queryDto.isExam2 !=null">
and tq.IS_EXAM2 = #{queryDto.isExam2}
</if>
<if test="queryDto.cid !=null and queryDto.cid !=''">
and find_in_set(#{queryDto.cid},tq.CIDS)
</if>
<if test="queryDto.category !=null and queryDto.category !=''">
and find_in_set(#{queryDto.category},tq.CATEGORY)
</if>
<if test="queryDto.point !=null and queryDto.point !=''">
and tpq.POINT = #{queryDto.point}
</if>
</where>
group by tq.QUESTION_ID
order by tq.SHOW_ORDER asc
</select>
<select id="queryQuestionIdByRandom" resultType="java.lang.Long">
select
tq.QUESTION_ID
from td_question tq
<where>
tq.IS_ACTIVE = '0'
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tq.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tq.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
and tq.CHAPTER = #{queryDto.chapter}
</if>
</where>
order by rand() limit ${queryDto.num};
</select>
<select id="queryMaxSort" resultType="java.lang.Integer">
select
MAX(tq.SHOW_ORDER)
from td_question tq
where tq.CAR_TYPE_ID = #{carTypeId}
</select>
</mapper>

View File

@ -1,5 +1,5 @@
<?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.jwl.driver.server.mapper.TdTestProjectVideosMapper">
<mapper namespace="com.jwl.driver.server.mapper.TdQuestionVersionMapper">
</mapper>

View File

@ -2,4 +2,33 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jwl.driver.server.mapper.TdSysUserMemberMapper">
<select id="queryUserMemberList" resultType="com.jwl.driver.server.vo.UserMemberVo">
select
tm.MEMBER_ID,
tm.MEMBER_NAME,
tm.CAR_TYPE_ID,
tm.PRICE,
tm.SUBJECTS,
su.USER_ID,
su.PHONE,
c.CAR_NAME,
um.START_DATE,
um.END_DATE
from
td_sys_user_member um
left join td_member tm on um.MEMBER_ID = tm.MEMBER_ID
left join td_sys_user su on su.USER_ID = um.USER_ID
left join td_car c on c.CAR_TYPE_ID = TM.CAR_TYPE_ID
<where>
<if test="userMemberDto.phone !=null">
and su.PHONE like concat("%" + #{userMemberDto.phone} + "%")
</if>
<if test="userMemberDto.memberId !=null">
and tm.MEMBER_ID = #{userMemberDto.memberId}
</if>
</where>
order by um.CREATE_TIME
</select>
</mapper>

View File

@ -0,0 +1,5 @@
<?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.jwl.driver.server.mapper.TdVideosMapper">
</mapper>

View File

@ -0,0 +1,74 @@
package com.jwl.driver.server;
import com.jwl.driver.server.config.WechatPayConfig;
import com.jwl.driver.server.entity.OrderPayInfo;
import com.jwl.driver.server.service.IOrderPayInfoService;
import com.jwl.driver.server.service.ITdSysUserMemberService;
import com.jwl.driver.server.util.InputStreamUtil;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.util.IOUtil;
import com.wechat.pay.java.core.util.PemUtil;
import com.wechat.pay.java.service.payments.h5.H5Service;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.repository.init.ResourceReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
/**
* @author
* @description
* @create 2023/8/21 10:36
*/
@SpringBootTest
@Profile("dev")
public class WechatPayTest {
@Autowired
private WechatPayConfig wechatPayConfig;
@Autowired
private ITdSysUserMemberService userMemberService;
@Autowired
private IOrderPayInfoService payInfoService;
@Test
void createService() throws IOException {
Config config =
new RSAAutoCertificateConfig.Builder()
.merchantId(wechatPayConfig.getMchId())
.privateKey(PemUtil.loadPrivateKeyFromString(InputStreamUtil.getContentStr("wechatPay/apiclient_key.pem")))
// .privateKeyFromPath(wechatPayConfig.getPrivateKeyPath())
.merchantSerialNumber(wechatPayConfig.getMchSerialNo())
.apiV3Key(wechatPayConfig.getApiV3Key())
.build();
H5Service service = new H5Service.Builder().config(config).build();
}
@Test
void purchaseMember(){
String trade_state = "SUCCESS";
String outTradeNo = "1694594904308846592";
OrderPayInfo payInfo = payInfoService.getById(Long.parseLong(outTradeNo));
if(trade_state.equals("SUCCESS")) {
//各种业务逻辑
//1.订单详情表里修改数据
payInfoService.payNotice(payInfo,Boolean.FALSE);
//2.冲会员
userMemberService.purchaseMember(payInfo);
}else{
//还是各种业务逻辑
//1.订单详情表里修改数据
payInfoService.payNotice(payInfo,Boolean.FALSE);
}
}
}