ruoyi-api/ruoyi-api-management/src/main/java/com/ruoyi/management/api/factory/TManagementFallbackFactory.java
@@ -60,6 +60,11 @@ return R.fail("获取分享信息失败"+cause.getMessage()); } @Override public R<TSysSet> promptVoice() { return R.fail("获取提示音效失败"+cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-management/src/main/java/com/ruoyi/management/api/feignClient/ManagementClient.java
@@ -6,7 +6,6 @@ import com.ruoyi.management.api.factory.TManagementFallbackFactory; import com.ruoyi.management.api.model.*; import com.ruoyi.management.api.query.UseGuideQuery; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -39,7 +38,14 @@ * @return 获取分享图片、标题及可获积分数 */ @GetMapping("/tSysSet/shareInfo") @ApiOperation(value = "获取分享图片、标题及可获积分数", tags = {"获取分享图片、标题及可获积分数"}) R<TSysSet> shareInfo(); /** * 获取分享图片、标题及可获积分数 * * @return 获取分享图片、标题及可获积分数 */ @GetMapping("/tSysSet/promptVoice") R<TSysSet> promptVoice(); } ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/Constants.java
@@ -159,6 +159,83 @@ public static final Integer SIXTY = 60; /** * - 前缀 */ public static final String REDUCE = "-"; /** * 空字符串 */ public static final String EMPTY_STR = ""; /** * 0数字 */ public static final Integer ZERO = 0; /** * 1数字 */ public static final Integer ONE = 1; /** * 字符串 1 */ public static final String ONE_STR = "1"; /** * 字符串 2 */ public static final String TWO_STR = "2"; /** * 数字 2 */ public static final Integer TWO = 2; /** * 字符串 3 */ public static final String THREE_STR = "3"; /** * 数字 3 */ public static final Integer THREE = 3; /** * 字符串 4 */ public static final String FOUR_STR = "4"; /** * 数字 4 */ public static final Integer FOUR = 4; /** * 字符串5 */ public static final String FIVE_STR = "5"; /** * 数字 5 */ public static final Integer FIVE = 5; /** * 字符串6 */ public static final String SIX_STR = "6"; /** * 数字6 */ public static final Integer SIX = 6; /** * 字符串7 */ public static final String SEVEN_STR = "7"; /** * 数字7 */ public static final Integer SEVEN = 7; /** * 1数字 */ public static final Integer ONE_HUNDRED = 100; /** * 1000数字 */ public static final Integer ONE_THOUSAND = 1000; @@ -203,4 +280,29 @@ */ public static final String ERR_CODE = "errcode"; /** * 积分来源 - 完成学习 */ public static final String COMPLETE_LEARNING = "完成学习"; /** * 积分来源 - 完成游戏 */ public static final String COMPLETE_GAME = "完成游戏"; /** * 积分来源 - 完成听故事 */ public static final String COMPLETE_STORY= "完成听故事"; /** * 超级听力 */ public static final String HEARING= "超级听力"; /** * 超级听力 */ public static final String MEMORY= "超级记忆"; } ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/ExceptionCodeConstants.java
New file @@ -0,0 +1,26 @@ package com.ruoyi.common.core.constant; /** * @author HJL * @version 1.0 * @since 2024-05-30 10:06 */ public class ExceptionCodeConstants { /** * token失效 */ public static final Integer TOKEN_EXPIRE = 600; /** * 短信验证码无效或错误 */ public static final Integer PHONE_CODE_ERROR_OR_EXPIRE = 503; /** * 账号冻结 */ public static final Integer ACCOUNT_FREEZE = 502; } ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
@@ -220,17 +220,17 @@ String userkey = JwtUtils.getUserKeyStudy(token); user = redisService.getCacheObject(getTokenKeyStudy(userkey)); // 再次判断登录状态是否已过期 if (null == user) { throw new StudyLoginException("登录信息已过期,请重新登录!", 504); } // 优先判断当前账号是否已在其他设备登录 if (!user.getIsCanLogin()) { throw new StudyLoginException("当前登录账号在其他设备登录!", 505); } // 再次判断登录状态是否已过期 if (System.currentTimeMillis() > user.getExpireTime()) { throw new StudyLoginException("登录信息已过期,请重新登录!", 504); } // if (null == user) { // throw new StudyLoginException("登录信息已过期,请重新登录!", 504); // } // // 优先判断当前账号是否已在其他设备登录 // if (!user.getIsCanLogin()) { // throw new StudyLoginException("当前登录账号在其他设备登录!", 505); // } // // 再次判断登录状态是否已过期 // if (System.currentTimeMillis() > user.getExpireTime()) { // throw new StudyLoginException("登录信息已过期,请重新登录!", 504); // } return user; } return user; ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysRoleController.java
@@ -76,7 +76,7 @@ @ApiOperation("权限列表查询") @GetMapping("/listPage") public AjaxResult<PageInfo<SysRoleVO> > listPage(String roleName,int pageNumber,int pageSize) public AjaxResult<PageInfo<SysRole> > listPage(String roleName,int pageNumber,int pageSize) { PageInfo<SysRole> pageInfo = new PageInfo<>(pageNumber, pageSize); LambdaQueryWrapper<SysRole> wrapper = new LambdaQueryWrapper<>(); ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.goods.domain.*; import com.ruoyi.goods.dto.*; import com.ruoyi.goods.service.*; import com.ruoyi.goods.vo.ExchangeRecordVO; import com.ruoyi.goods.vo.GoodDetailVO; import com.ruoyi.goods.vo.TGoodsVO; import com.ruoyi.goods.vo.TOrderVO; @@ -17,7 +19,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import io.swagger.annotations.ApiOperationSupport; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; @@ -28,6 +30,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; /** * <p> @@ -158,7 +161,6 @@ @PostMapping("/addGoods") @ApiOperation(value = "添加", tags = {"后台-商品管理"}) public R addGoods(@RequestBody TGoods dto) { dto.setSurplus(dto.getTotal()); goodsService.save(dto); return R.ok("添加成功"); } @@ -201,15 +203,27 @@ * 兑换记录 */ @GetMapping("/exchangeRecord") @ApiOperation(value = "学习端-兑换记录", tags = {"学习端-兑换记录"}) public R<List<TOrder>> exchangeRecord() { return R.ok(orderService.lambdaQuery().eq(TOrder::getUserId, tokenService.getLoginUserStudy().getUserid()) .orderByDesc(TOrder::getCreateTime).list()); @ApiOperation(value = "学习端-兑换记录", tags = {"学习端-商城"}) public R<List<ExchangeRecordVO>> exchangeRecord() { List<ExchangeRecordVO> exchangeRecord = orderService.exchangeRecord(tokenService.getLoginUserStudy().getUserid()); for (ExchangeRecordVO record : exchangeRecord) { TGoods goods = goodsService.getById(record.getGoodsId()); List<String> typeList; if (null != goods) { List<TGoodsType> goodsTypes = goodsTypeService.lambdaQuery().in(TGoodsType::getId, Arrays.stream(goods.getTypeIds().split(",")).collect(Collectors.toList())) .eq(TGoodsType::getIsDelete, 0).list(); typeList = goodsTypes.stream().map(TGoodsType::getName).collect(Collectors.toList()); } else { typeList = new ArrayList<>(); } record.setGoodsType(typeList); } return R.ok(exchangeRecord); } @GetMapping("/exchangeRecordParent") @ApiOperation(value = "家长端-兑换记录", tags = {"家长端-兑换记录"}) public R<Page<TOrder>> exchangeRecordParent(Integer pageNumber,Integer pageSize) { public R<Page<TOrder>> exchangeRecordParent(Integer pageNumber, Integer pageSize) { if (tokenService.getLoginUser1() == null){ return R.tokenError("登录失效"); } @@ -243,6 +257,7 @@ */ @GetMapping("/confirm") @ApiOperation(value = "确认收货", tags = {"家长端-兑换记录"}) @ApiOperationSupport(order = 16) @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true) }) @@ -259,7 +274,8 @@ * 兑换记录 */ @GetMapping("/confirmStudy") @ApiOperation(value = "确认收货", tags = {"学习端-兑换记录"}) @ApiOperation(value = "确认收货", tags = {"学习端-商城"}) @ApiOperationSupport(order = 29) @ApiImplicitParams({ @ApiImplicitParam(value = "订单id", name = "id", dataType = "String", required = true) }) @@ -277,6 +293,7 @@ */ @GetMapping("/shopAddressParent") @ApiOperation(value = "获取用户收货地址", tags = {"家长端-获取用户收货地址"}) @ApiOperationSupport(order = 17) public R<List<Recipient>> shopAddressParent() { if (tokenService.getLoginUser1() == null) { return R.tokenError("登录失效"); @@ -290,6 +307,7 @@ */ @GetMapping("/setDefault") @ApiOperation(value = "设置默认地址", tags = {"家长端-设置默认地址"}) @ApiOperationSupport(order = 18) @ApiImplicitParams({ @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true) }) @@ -315,7 +333,8 @@ * 设置默认地址 */ @GetMapping("/setDefaultStudy") @ApiOperation(value = "设置默认地址", tags = {"学习端-设置默认地址"}) @ApiOperation(value = "设置默认地址", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 30) @ApiImplicitParams({ @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true) }) @@ -344,7 +363,8 @@ * @return */ @GetMapping("/getAddressById") @ApiOperation(value = "获取地址详情", tags = {"家长端-获取地址详情"}) @ApiOperation(value = "获取地址详情", tags = {"家长端-收货地址"}) @ApiOperationSupport(order = 19) @ApiImplicitParams({ @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true) }) @@ -363,7 +383,8 @@ * @return */ @GetMapping("/getAddressByIdStudy") @ApiOperation(value = "获取地址详情", tags = {"学习端-获取地址详情"}) @ApiOperation(value = "获取地址详情", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 31) @ApiImplicitParams({ @ApiImplicitParam(value = "地址id", name = "id", dataType = "String", required = true) }) @@ -379,7 +400,8 @@ * 获取用户收货地址 */ @GetMapping("/shopAddress") @ApiOperation(value = "获取用户收货地址", tags = {"学习端-获取用户收货地址"}) @ApiOperation(value = "获取用户收货地址列表", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 32) public R<List<Recipient>> shopAddress() { if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); @@ -392,7 +414,8 @@ * 新增收货地址/修改收货地址 */ @PostMapping("/addressSaveOrUpdate") @ApiOperation(value = "学习端-新增收货地址/修改收货地址", tags = {"学习端-新增收货地址/修改收货地址"}) @ApiOperation(value = "新增收货地址/修改收货地址", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 33) public R<String> addressSave(@RequestBody Recipient recipient) { recipient.setUserId(tokenService.getLoginUserStudy().getUserid()); if (recipient.getIsDefault() == 1){ @@ -413,6 +436,7 @@ */ @PostMapping("/addressSaveOrUpdateParent") @ApiOperation(value = "家长端-新增收货地址/修改收货地址", tags = {"家长端-新增收货地址/修改收货地址"}) @ApiOperationSupport(order = 20) public R<String> addressSaveOrUpdateParent(@RequestBody Recipient recipient) { if (tokenService.getLoginUser1() == null){ return R.tokenError("登录失效!"); @@ -449,11 +473,12 @@ * 删除收货地址 */ @GetMapping("/addressDelete") @ApiOperation(value = "学习端-删除收货地址", tags = {"学习端-删除收货地址"}) @ApiOperation(value = "删除收货地址", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 34) @ApiImplicitParams({ @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "String", required = true) @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "Integer", required = true) }) public R<String> addressDelete(@RequestParam String id) { public R<String> addressDelete(@RequestParam Integer id) { return R.ok(recipientService.removeById(id) ? "删除成功!" : "删除失败!"); } @@ -462,8 +487,9 @@ */ @GetMapping("/addressDeleteParent") @ApiOperation(value = "家长端-删除收货地址", tags = {"家长端-删除收货地址"}) @ApiOperationSupport(order = 21) @ApiImplicitParams({ @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "String", required = true) @ApiImplicitParam(value = "地址信息id", name = "id", dataType = "Integer", required = true) }) public R<String> addressDeleteParent(@RequestParam Integer id) { return R.ok(recipientService.removeById(id) ? "删除成功!" : "删除失败!"); @@ -472,6 +498,7 @@ @GetMapping("/getOrderAddressParent") @ApiOperation(value = "获取修改订单收货地址", tags = {"家长端-获取修改订单收货地址"}) @ApiOperationSupport(order = 22) public R<List<Recipient>> getOrderAddressParent() { if (tokenService.getLoginUser1() == null) { return R.tokenError("登录失效"); @@ -483,7 +510,8 @@ } @GetMapping("/getOrderAddress") @ApiOperation(value = "获取修改订单收货地址", tags = {"学习端-获取修改订单收货地址"}) @ApiOperation(value = "获取修改订单收货地址", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 35) public R<List<Recipient>> getOrderAddress() { if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); @@ -513,7 +541,8 @@ } @GetMapping("/updateOrderAddress") @ApiOperation(value = "修改订单收货地址", tags = {"学习端-修改订单收货地址"}) @ApiOperation(value = "修改订单收货地址", tags = {"学习端-收货地址"}) @ApiOperationSupport(order = 36) public R updateOrderAddress(@RequestParam Integer orderId, @RequestParam Integer recipientId) { if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); @@ -531,7 +560,8 @@ * 收货地址省市区三级联动 */ @GetMapping("/addressTree") @ApiOperation(value = "学习端-收货地址省市区三级联动", tags = {"学习端-收货地址省市区三级联动"}) @ApiOperation(value = "收货地址省市区三级联动", tags = {"学习端-商城"}) @ApiOperationSupport(order = 37) public R<List<Region>> addressTree() { return R.ok(regionService.addressTree()); } @@ -541,7 +571,8 @@ * 远程调用 */ @GetMapping("/goodRecommend") @ApiOperation(value = "学习端-可兑换商品推荐", tags = {"学习端-可兑换商品推荐"}) @ApiOperation(value = "可兑换商品推荐", tags = {"学习端-商城"}) @ApiOperationSupport(order = 38) public R<List<TGoodsVO>> goodRecommend() { return R.ok(goodsService.goodRecommend(tokenService.getLoginUserStudy().getUserid())); } @@ -550,7 +581,8 @@ * 获取所有商品分类 */ @GetMapping("/goodTypeStudy") @ApiOperation(value = "学习端-商品分类列表", tags = {"学习端-商品分类列表"}) @ApiOperation(value = "商品分类列表", tags = {"学习端-商城"}) @ApiOperationSupport(order = 39) public R<List<TGoodsType>> goodTypeStudy() { return R.ok(goodsTypeService.lambdaQuery().eq(TGoodsType::getIsDelete, 0).eq(TGoodsType::getIsDelete, 0).list()); } @@ -561,7 +593,8 @@ * @param goodId 商品id */ @GetMapping("/goodDetail") @ApiOperation(value = "学习端-商品详情", tags = {"学习端-商城"}) @ApiOperation(value = "商品详情", tags = {"学习端-商城"}) @ApiOperationSupport(order = 40) @ApiImplicitParams({ @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) }) @@ -582,6 +615,7 @@ */ @GetMapping("/goodDetailParent") @ApiOperation(value = "商品详情", tags = {"家长端-商城"}) @ApiOperationSupport(order = 24) @ApiImplicitParams({ @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) }) @@ -603,6 +637,7 @@ */ @GetMapping("/redeemNow") @ApiOperation(value = "商城立即兑换", tags = {"学习端-商城"}) @ApiOperationSupport(order = 41) @ApiImplicitParams({ @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) }) @@ -635,6 +670,7 @@ */ @GetMapping("/redeemNowParent") @ApiOperation(value = "商城立即兑换", tags = {"家长端-商城"}) @ApiOperationSupport(order = 25) @ApiImplicitParams({ @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true) }) @@ -685,7 +721,8 @@ } @PostMapping("/goodExchangeStudy") @ApiOperation(value = "学习端-商品兑换确认", tags = {"学习端-商品兑换确认"}) @ApiOperation(value = "商品兑换确认", tags = {"学习端-商城"}) @ApiOperationSupport(order = 42) public R goodExchangeStudy(@RequestBody GoodExchangeDTO goodExchange) { Recipient recipient = recipientService.getById(goodExchange.getRecipientId()); return goodsService.goodExchange(goodExchange, recipient); @@ -697,6 +734,7 @@ @PostMapping("/getOrderInfo/{id}") @ApiOperation(value = "查看详情", tags = {"后台-订单管理"}) @ApiOperationSupport(order = 11) public R<TOrderVO> getOrderInfo(@PathVariable("id") Integer id) { TOrder byId = orderService.getById(id); TGoods byId2 = goodsService.getById(byId.getGoodsId()); @@ -711,6 +749,7 @@ @PostMapping("/confirm1") @ApiOperation(value = "确认发货", tags = {"后台-订单管理"}) @ApiOperationSupport(order = 12) public R getGoodsInfo1(@RequestBody OrderDTO dto) { TOrder byId = orderService.getById(dto.getId()); byId.setState(2); @@ -723,6 +762,7 @@ @PostMapping("/listAll1") @ApiOperation(value = "列表查询", tags = {"后台-订单管理"}) @ApiOperationSupport(order = 13) public R<PageInfo<TOrderVO>> listAll1(@RequestBody OrderQuery query) throws ParseException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/domain/Recipient.java
@@ -3,12 +3,11 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import com.ruoyi.common.core.web.domain.BaseModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; import javax.validation.constraints.NotNull; /** * <p> @@ -73,6 +72,7 @@ * 地址 */ @ApiModelProperty(value = "是否为默认地址0否1是") @NotNull(message = "请选择:是否为默认收货地址") private Integer isDefault; @@ -151,15 +151,15 @@ @Override public String toString() { return "Recipient{" + "id=" + id + ", userId=" + userId + ", recipient=" + recipient + ", recipientPhone=" + recipientPhone + ", province=" + province + ", provinceCode=" + provinceCode + ", city=" + city + ", cityCode=" + cityCode + ", address=" + address + "}"; "id=" + id + ", userId=" + userId + ", recipient=" + recipient + ", recipientPhone=" + recipientPhone + ", province=" + province + ", provinceCode=" + provinceCode + ", city=" + city + ", cityCode=" + cityCode + ", address=" + address + "}"; } } ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/domain/TOrder.java
@@ -80,6 +80,7 @@ /** * 消耗积分 */ @ApiModelProperty(value = "消耗积分") private Integer integral; @ApiModelProperty(value = "收货人姓名") private String consigneeName; ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/dto/GoodQueryDTO.java
@@ -3,6 +3,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; import java.util.List; /** @@ -26,8 +27,10 @@ private String keywords; @ApiModelProperty(value = "页码,首页1", required = true) @NotNull(message = "请选择:当前页码数!") private Integer pageNumber; @ApiModelProperty(value = "页条数", required = true) @NotNull(message = "请选择:每页显示条数!") private Integer pageSize; } ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/mapper/TOrderMapper.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.goods.domain.TOrder; import com.ruoyi.goods.dto.OrderQuery; import com.ruoyi.goods.vo.ExchangeRecordVO; import com.ruoyi.goods.vo.TOrderVO; import org.apache.ibatis.annotations.Param; @@ -27,4 +28,12 @@ * @return 购买数量 */ Integer getGoodBuyNumber(@Param("goodId") Integer id); /** * 兑换记录 * * @param userid 用户id * @return 兑换记录 */ List<ExchangeRecordVO> exchangeRecord(Integer userid); } ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/ITOrderService.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.goods.domain.TOrder; import com.ruoyi.goods.dto.OrderQuery; import com.ruoyi.goods.vo.ExchangeRecordVO; import com.ruoyi.goods.vo.TOrderVO; import java.util.List; @@ -28,4 +29,11 @@ */ Integer getGoodBuyNumber(Integer id); /** * 兑换记录 * * @param userid 用户id * @return 兑换记录 */ List<ExchangeRecordVO> exchangeRecord(Integer userid); } ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TGoodsServiceImpl.java
@@ -4,7 +4,6 @@ import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.RedisConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.GlobalException; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.goods.domain.Recipient; import com.ruoyi.goods.domain.TGoods; @@ -26,6 +25,7 @@ import javax.annotation.Resource; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -61,6 +61,7 @@ String key = String.format(RedisConstants.GOOD_STOCK, goods.getId()); RSemaphore semaphore = redissonClient.getSemaphore(key); semaphore.trySetPermits(goods.getSurplus()); semaphore.expire(Constants.SIXTY, TimeUnit.MINUTES); return new GoodDetailVO(goods, recipient); } ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/TOrderServiceImpl.java
@@ -5,6 +5,7 @@ import com.ruoyi.goods.dto.OrderQuery; import com.ruoyi.goods.mapper.TOrderMapper; import com.ruoyi.goods.service.ITOrderService; import com.ruoyi.goods.vo.ExchangeRecordVO; import com.ruoyi.goods.vo.TOrderVO; import org.springframework.stereotype.Service; @@ -31,4 +32,9 @@ return baseMapper.getGoodBuyNumber(id); } @Override public List<ExchangeRecordVO> exchangeRecord(Integer userid) { return baseMapper.exchangeRecord(userid); } } ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/vo/ExchangeRecordVO.java
New file @@ -0,0 +1,100 @@ package com.ruoyi.goods.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; import java.util.List; /** * @author HJL * @version 1.0 * @since 2024-06-04 9:49 */ @Data public class ExchangeRecordVO { /** * 主键id */ @ApiModelProperty(value = "订单id") private Integer orderId; /** * 订单编号 */ @ApiModelProperty(value = "订单编号") private String orderNumber; /** * 用户id */ @ApiModelProperty(value = "下单用户id") private Integer userId; /** * 下单时间 */ @ApiModelProperty(value = "下单时间") private Date insertTime; @ApiModelProperty(value = "收货时间") private Date completeTime; /** * 商品id */ @ApiModelProperty(value = "商品id") private Integer goodsId; /** * 商品名称 */ @ApiModelProperty(value = "商品名称") private String goodsName; /** * 商品封面图 */ @ApiModelProperty(value = "商品封面图") private String coverImg; /** * 商品名称 */ @ApiModelProperty(value = "商品类型") private List<String> goodsType; /** * 购买数量 */ @ApiModelProperty(value = "购买数量") private Integer count; /** * 订单状态1待发货2已发货3已完成 */ @ApiModelProperty(value = "订单状态1待发货2已发货3已完成") private Integer state; /** * 快递名称 */ @ApiModelProperty(value = "快递名称") private String express; /** * 快递编号 */ @ApiModelProperty(value = "快递编号") private String expressNumber; /** * 发货时间 */ @ApiModelProperty(value = "发货时间") private Date expressTime; /** * 消耗积分 */ @ApiModelProperty(value = "消耗积分") private Integer integral; @ApiModelProperty(value = "收货人姓名") private String consigneeName; /** * 消耗积分 */ @ApiModelProperty(value = "收货人电话") private String consigneePhone; @ApiModelProperty(value = "收货人地址") private String consigneeAddress; } ruoyi-service/ruoyi-goods/src/main/resources/mapper/goods/TOrderMapper.xml
@@ -1,31 +1,40 @@ <?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.ruoyi.goods.mapper.TOrderMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.ruoyi.goods.domain.TOrder"> <id column="id" property="id" /> <result column="orderNumber" property="orderNumber" /> <result column="userId" property="userId" /> <result column="insertTime" property="insertTime" /> <result column="goodsId" property="goodsId" /> <result column="count" property="count" /> <result column="state" property="state" /> <result column="express" property="express" /> <result column="expressNumber" property="expressNumber" /> <result column="expressTime" property="expressTime" /> <result column="integral" property="integral" /> <id column="id" property="id"/> <result column="orderNumber" property="orderNumber"/> <result column="userId" property="userId"/> <result column="insertTime" property="insertTime"/> <result column="goodsId" property="goodsId"/> <result column="count" property="count"/> <result column="state" property="state"/> <result column="express" property="express"/> <result column="expressNumber" property="expressNumber"/> <result column="expressTime" property="expressTime"/> <result column="integral" property="integral"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, orderNumber, userId, insertTime, goodsId, count, state, express, expressNumber, expressTime, integral id, orderNumber, userId, insertTime, goodsId, count, state, express, expressNumber, expressTime, integral </sql> <select id="listAll" resultType="com.ruoyi.goods.vo.TOrderVO"> select t1.*,t2.name as name select t1.*, t2.name as name from t_order t1 left join t_goods t2 on t1.goodsId = t2.id where 1=1 left join t_goods t2 on t1.goodsId = t2.id where 1 = 1 <if test="null != req.state"> and t1.state = #{req.state} </if> @@ -40,6 +49,35 @@ </select> <select id="getGoodBuyNumber" resultType="java.lang.Integer"> SELECT IFNULL(SUM(count), 0) FROM t_order WHERE goodsId = #{goodId} SELECT IFNULL(SUM(count), 0) FROM t_order WHERE goodsId = #{goodId} </select> <resultMap id="exchangRecordMap" type="com.ruoyi.goods.vo.ExchangeRecordVO"> <id column="id" property="orderId"/> <result column="orderNumber" property="orderNumber"/> <result column="userId" property="userId"/> <result column="completeTime" property="completeTime"/> <result column="insertTime" property="insertTime"/> <result column="goodsId" property="goodsId"/> <result column="count" property="count"/> <result column="state" property="state"/> <result column="express" property="express"/> <result column="expressNumber" property="expressNumber"/> <result column="expressTime" property="expressTime"/> <result column="integral" property="integral"/> <result column="consigneePhone" property="consigneePhone"/> <result column="consigneeAddress" property="consigneeAddress"/> <result column="goodsName" property="goodsName"/> <result column="consigneeName" property="consigneeName"/> <result column="coverImg" property="coverImg"/> </resultMap> <select id="exchangeRecord" resultMap="exchangRecordMap"> select o.*, g.id as goodsId, g.name as goodsName,g.coverImg from t_order o left join t_goods g on o.goodsId = g.id where o.userId = #{userid} </select> </mapper> ruoyi-service/ruoyi-management/src/main/java/com/ruoyi/management/controller/TSysSetController.java
@@ -53,30 +53,34 @@ public AjaxResult getSysSet() { TSysSet byId = sysSetService.getById(1); SysSetVO sysSetVO = new SysSetVO(); BeanUtils.copyProperties(byId,sysSetVO); BeanUtils.copyProperties(byId, sysSetVO); return AjaxResult.success(sysSetVO); } @ApiOperation(value = "保存系统设置", tags = {"后台-系统设置"}) @PostMapping(value = "/saveSysSet") public AjaxResult saveSysSet(SysSetVO vo) { TSysSet byId = sysSetService.getById(1); BeanUtils.copyProperties(vo,byId); BeanUtils.copyProperties(vo, byId); byId.setId(1); sysSetService.updateById(byId); return AjaxResult.success("保存成功"); } @ApiOperation(value = "获取启动页", tags = {"后台-启动页管理"}) @PostMapping(value = "/getPage") public AjaxResult getPage() { List<TPage> list = pageService.list(); return AjaxResult.success(list); } @ApiOperation(value = "获取注意事项、启动页", tags = {"家长端-获取注意事项、启动页"}) @PostMapping(value = "/getPage1") public R<List<TPage>> getPage1() { List<TPage> list = pageService.list(); return R.ok(list); } @ApiOperation(value = "保存启动页", tags = {"后台-启动页管理"}) @PostMapping(value = "/setPage") public AjaxResult setPage(@RequestBody PageVO vo) { @@ -84,89 +88,92 @@ String page2 = vo.getPage2(); String page3 = vo.getPage3(); String page4 = vo.getPage4(); if (StringUtils.hasLength(page1)){ if (StringUtils.hasLength(page1)) { TPage type = pageService.getOne(new QueryWrapper<TPage>() .eq("type", 1)); TPage tPage = new TPage(); if (type == null){ if (type == null) { tPage.setImg(page1); tPage.setType(1); pageService.save(tPage); }else{ } else { type.setImg(page1); pageService.updateById(type); } } if (StringUtils.hasLength(page2)){ if (StringUtils.hasLength(page2)) { TPage type = pageService.getOne(new QueryWrapper<TPage>() .eq("type", 2)); TPage tPage = new TPage(); if (type == null){ if (type == null) { tPage.setImg(page2); tPage.setType(2); pageService.save(tPage); }else{ } else { type.setImg(page2); pageService.updateById(type); } } if (StringUtils.hasLength(page3)){ if (StringUtils.hasLength(page3)) { TPage type = pageService.getOne(new QueryWrapper<TPage>() .eq("type", 3)); TPage tPage = new TPage(); if (type == null){ if (type == null) { tPage.setImg(page3); tPage.setType(3); pageService.save(tPage); }else{ } else { type.setImg(page3); pageService.updateById(type); } } if (StringUtils.hasLength(page4)){ if (StringUtils.hasLength(page4)) { TPage type = pageService.getOne(new QueryWrapper<TPage>() .eq("type", 4)); if (type == null){ if (type == null) { TPage tPage = new TPage(); tPage.setImg(page4); tPage.setType(4); pageService.save(tPage); }else{ } else { type.setImg(page4); pageService.updateById(type); } } return AjaxResult.success("保存成功"); } @PostMapping("/agreement") @ApiOperation(value = "协议", tags = {"后台-协议管理"}) public AjaxResult agreement(@RequestBody AggrementDTO dto) { TProtocol protocol = protocolService.getById(dto.getType()); if(StringUtils.hasLength(dto.getContent())){ if (StringUtils.hasLength(dto.getContent())) { protocol.setContent(dto.getContent()); protocolService.updateById(protocol); return AjaxResult.success("修改成功"); }else{ } else { return AjaxResult.success(protocol.getContent()); } } @PostMapping("/agreement1/{type}") @ApiOperation(value = "协议", tags = {"家长端/学习端-获取协议"}) public R<String> agreement1(@PathVariable("type") Integer type) { public R<String> agreement1(@PathVariable("type") Integer type) { TProtocol protocol = protocolService.getOne(new QueryWrapper<TProtocol>() .eq("type",type)); .eq("type", type)); return R.ok(protocol.getContent()); } @PostMapping("/useGuide") @ApiOperation(value = "使用指南-列表查询", tags = {"后台-使用指南"}) public AjaxResult<PageInfo<TUseGuide>> agreement(String title, Integer pageNumber, Integer pageSize) { QueryWrapper<TUseGuide> wrapper = new QueryWrapper<>(); if (StringUtils.hasLength(title)){ wrapper.like("title",title); if (StringUtils.hasLength(title)) { wrapper.like("title", title); } List<String> strings = new ArrayList<>(); strings.add("insertTime"); @@ -178,13 +185,14 @@ res.setTotal(useGuides.size()); return AjaxResult.success(res); } @PostMapping("/useGuide1") @ApiOperation(value = "列表查询", tags = {"家长端-使用指南"}) public R<PageInfo<TUseGuide>> useGuide1(@RequestBody UseGuideQuery query) { query.setPageNumber((query.getPageNumber() - 1) * query.getPageSize()); QueryWrapper<TUseGuide> wrapper = new QueryWrapper<>(); if (StringUtils.hasLength(query.getTitle())){ wrapper.like("title",query.getTitle()); if (StringUtils.hasLength(query.getTitle())) { wrapper.like("title", query.getTitle()); } List<String> strings = new ArrayList<>(); strings.add("insertTime"); @@ -203,7 +211,7 @@ @PostMapping("/updateUseGuide") @ApiOperation(value = "使用指南-添加/编辑/查看详情", tags = {"使用指南"}) public AjaxResult<TUseGuide> updateUseGuide(@RequestBody UseGuidDTO dto) { switch (dto.getType()){ switch (dto.getType()) { case 1: TUseGuide useGuide = new TUseGuide(); useGuide.setTitle(dto.getTitle()); @@ -226,9 +234,10 @@ } return AjaxResult.success(new TUseGuide()); } @DeleteMapping("/delete") @ApiOperation(value = "使用指南-删除", tags = {"使用指南"}) public AjaxResult updateUseGuide( Integer id) { public AjaxResult updateUseGuide(Integer id) { // TUseGuide useGuide2 = useGuideService.getById(id); useGuideService.removeById(id); return AjaxResult.success("删除成功"); @@ -240,5 +249,11 @@ return R.ok(sysSetService.lambdaQuery().one()); } @ApiOperation(value = "获取正确及错误提示音效", tags = {"学习端-首页"}) @GetMapping(value = "/promptVoice") public R<TSysSet> promptVoice() { return R.ok(sysSetService.lambdaQuery().eq(TSysSet::getDisabled, 0).one()); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -2,10 +2,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.constant.RedisConstants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.GlobalException; import com.ruoyi.common.core.web.page.PageInfo; @@ -13,6 +11,7 @@ import com.ruoyi.common.security.service.TokenService; import com.ruoyi.goods.api.feignClient.GoodsClient; import com.ruoyi.goods.api.model.TGoodsVO; import com.ruoyi.management.api.feignClient.ManagementClient; import com.ruoyi.study.domain.*; import com.ruoyi.study.dto.*; import com.ruoyi.study.service.*; @@ -28,7 +27,6 @@ import javax.annotation.Resource; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -79,6 +77,8 @@ private TokenService tokenService; @Resource private ITSubjectRecordService subjectRecordService; @Resource private ManagementClient managementClient; @PostMapping("/storyList") // @ApiOperation(value = "配置学习类型选择故事", tags = {"题目管理"}) @@ -662,9 +662,6 @@ } /** * 可兑换商品推荐 */ @@ -673,6 +670,7 @@ public R<List<TGoodsVO>> studySchedule() { return R.ok(goodsClient.goodRecommend().getData()); } /** * 首次页面加载时调用,获取学习进度及学习时长等信息 * @@ -686,9 +684,10 @@ @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) }) public R<TUserStudy> studySchedule(@RequestParam Integer week, @RequestParam Integer day) { TUserStudy result = studyService.studySchedule(String.valueOf(tokenService.getLoginUserStudy().getUserid()), week, day); TUserStudy result = studyService.studySchedule(String.valueOf(tokenService.getLoginUserStudy().getUserid()), week); return R.ok(result); } /** * 查询周目列表 * @@ -705,6 +704,7 @@ List<StudyWeekDTO> result = studyService.weekList(type, quarter); return R.ok(result); } /** * 进入题组后,获取题组学习进度信息 * @@ -740,26 +740,21 @@ * @param day 所属day */ @GetMapping("/listenSelectPicture") @ApiOperation(value = "自主学习1-听音选图", tags = {"学习端-首页"}) @ApiOperation(value = "自主学习1-听音选图", tags = {"学习端-听-自主学习"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) }) public R<StudyListenResultVO> listenSelectPicture(@RequestParam Integer week, @RequestParam Integer day) { public R<StudyListenResultVO> listenSelectPicture(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { // 判断当前登录用户是否为 会员 Boolean isVip = userService.isVip(); LambdaQueryChainWrapper<TStudyListen> wrapper = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week) .eq(TStudyListen::getDay, day).eq(TStudyListen::getDisabled, 0); // 非会员只能查看非会员题目,会员可以查看所有题目 // if (!isVip) { // wrapper.eq(TStudyListen::getIsVip, 0); // } List<TStudyListen> studyListens = wrapper.list(); List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day); for (TStudyListen studyListen : studyListens) { if (studyListen.getIsVip() == 1){ if (studyListen.getIsVip() == 1) { // 需要会员查看 if (!isVip){ if (!isVip) { // 不是会员 return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); } @@ -775,24 +770,21 @@ * @param day 所属day */ @GetMapping("/pictureSelectVoice") @ApiOperation(value = "自主学习2-看图选音", tags = {"学习端-首页"}) @ApiOperation(value = "自主学习2-看图选音", tags = {"学习端-听-自主学习"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) }) public R<StudyLookResultVO> pictureSelectVoice(@RequestParam Integer week, @RequestParam Integer day) { public R<StudyLookResultVO> pictureSelectVoice(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { // 判断当前登录用户是否为 会员 Boolean isVip = userService.isVip(); LambdaQueryChainWrapper<TStudyLook> wrapper = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week) .eq(TStudyLook::getDay, day).eq(TStudyLook::getDisabled, 0); // 非会员只能查看非会员题目,会员可以查看所有题目 List<TStudyLook> lookList = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week) .eq(TStudyLook::getDay, day).eq(TStudyLook::getDisabled, 0).list(); List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day); for (TStudyLook studyListen : lookList) { if (studyListen.getIsVip() == 1){ if (studyListen.getIsVip() == 1) { // 需要会员查看 if (!isVip){ if (!isVip) { // 不是会员 return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); } @@ -808,25 +800,21 @@ * @param day 所属day */ @GetMapping("/induceExclude") @ApiOperation(value = "自主学习3-归纳排除", tags = {"学习端-首页"}) @ApiOperation(value = "自主学习3-归纳排除", tags = {"学习端-听-自主学习"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) }) public R<StudyInductionResultVO> induceExclude(@RequestParam Integer week, @RequestParam Integer day) { public R<StudyInductionResultVO> induceExclude(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { // 判断当前登录用户是否为 会员 Boolean isVip = userService.isVip(); LambdaQueryChainWrapper<TStudyInduction> wrapper = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week) .eq(TStudyInduction::getDay, day).eq(TStudyInduction::getDisabled, 0); // 非会员只能查看非会员题目,会员可以查看所有题目 // if (!isVip) { // wrapper.eq(TStudyInduction::getIsVip, 0); // } List<TStudyInduction> inductionList = wrapper.list(); List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day); for (TStudyInduction studyListen : inductionList) { if (studyListen.getIsVip() == 1){ if (studyListen.getIsVip() == 1) { // 需要会员查看 if (!isVip){ if (!isVip) { // 不是会员 return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); } @@ -842,25 +830,21 @@ * @param day 所属day */ @GetMapping("/questionsAndAnswers") @ApiOperation(value = "自主学习4-有问有答", tags = {"学习端-首页"}) @ApiOperation(value = "自主学习4-有问有答", tags = {"学习端-听-自主学习"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) }) public R<StudyAnswerResultVO> questionsAndAnswers(@RequestParam Integer week, @RequestParam Integer day) { public R<StudyAnswerResultVO> questionsAndAnswers(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { // 判断当前登录用户是否为 会员 Boolean isVip = userService.isVip(); LambdaQueryChainWrapper<TStudyAnswer> wrapper = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getWeek, week) .eq(TStudyAnswer::getDay, day).eq(TStudyAnswer::getDisabled, 0); // 非会员只能查看非会员题目,会员可以查看所有题目 // if (!isVip) { // wrapper.eq(TStudyAnswer::getIsVip, 0); // } List<TStudyAnswer> answerList = wrapper.list(); List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day); for (TStudyAnswer studyListen : answerList) { if (studyListen.getIsVip() == 1){ if (studyListen.getIsVip() == 1) { // 需要会员查看 if (!isVip){ if (!isVip) { // 不是会员 return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); } @@ -876,29 +860,27 @@ * @param day 所属day */ @GetMapping("/pictureMateVoice") @ApiOperation(value = "自主学习5-音图相配", tags = {"学习端-首页"}) @ApiOperation(value = "自主学习5-音图相配", tags = {"学习端-听-自主学习"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "周目", name = "week", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属day", name = "day", dataType = "Integer", required = true) }) public R<StudyPairResultVO> pictureMateVoice(@RequestParam Integer week, @RequestParam Integer day) { public R<StudyPairResultVO> pictureMateVoice(@RequestParam Integer quarter, @RequestParam Integer week, @RequestParam Integer day) { // 判断当前登录用户是否为 会员 Boolean isVip = userService.isVip(); LambdaQueryChainWrapper<TStudyPair> wrapper = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week) .eq(TStudyPair::getDay, day).eq(TStudyPair::getDisabled, 0); // 非会员只能查看非会员题目,会员可以查看所有题目 if (!isVip) { wrapper.eq(TStudyPair::getIsVip, 0); } TStudyPair pair = wrapper.one(); if (pair.getIsVip() == 1){ // 需要会员查看 if (!isVip){ // 不是会员 return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day); for (TStudyPair pair : pairList) { if (pair.getIsVip() == 1) { // 需要会员查看 if (!isVip) { // 不是会员 return R.vipError("以下内容仅限会员查看,请通过家长端成为会员!"); } } } return R.ok(studyService.pictureMateVoice(week, day, pair)); return R.ok(studyService.pictureMateVoice(week, day, pairList)); } /** @@ -907,23 +889,58 @@ * @param completeStudy 完成学习信息 */ @PostMapping("/completeLearning") @ApiOperation(value = "完成学习", tags = {"学习端-题目"}) @ApiOperation(value = "完成学习", tags = {"学习端-听-自主学习"}) public R<Boolean> completeLearning(@RequestBody CompleteStudyDTO completeStudy) { // 登录用户id Integer userId = tokenService.getLoginUserStudy().getUserid(); // 获取user详细信息,改变积分 // 判断是否已完成该题组 boolean update = true; if (completeStudy.getIsComplete()) { List<Integer> studyIds = completeStudy.getStudyIds(); Integer type = completeStudy.getType(); int sum; if (Constants.ONE.equals(type)) { List<TStudyListen> studyListens = studyListenService.lambdaQuery().in(TStudyListen::getId, studyIds) .eq(TStudyListen::getDisabled, 0).list(); sum = studyListens.stream().mapToInt(TStudyListen::getIntegral).sum(); } else if (Constants.TWO.equals(type)) { List<TStudyLook> studyListens = studyLookService.lambdaQuery().in(TStudyLook::getId, studyIds) .eq(TStudyLook::getDisabled, 0).list(); sum = studyListens.stream().mapToInt(TStudyLook::getIntegral).sum(); } else if (Constants.THREE.equals(type)) { List<TStudyInduction> studyListens = studyInductionService.lambdaQuery().in(TStudyInduction::getId, studyIds) .eq(TStudyInduction::getDisabled, 0).list(); sum = studyListens.stream().mapToInt(TStudyInduction::getIntegral).sum(); } else if (Constants.FOUR.equals(type)) { List<TStudyAnswer> studyListens = studyAnswerService.lambdaQuery().in(TStudyAnswer::getId, studyIds) .eq(TStudyAnswer::getDisabled, 0).list(); sum = studyListens.stream().mapToInt(TStudyAnswer::getIntegral).sum(); } else if (Constants.FIVE.equals(type)) { List<TStudyPair> studyListens = studyPairService.lambdaQuery().in(TStudyPair::getId, studyIds) .eq(TStudyPair::getDisabled, 0).list(); sum = studyListens.stream().mapToInt(TStudyPair::getIntegral).sum(); } else { return R.fail("题目信息异常!"); } // 获取user详细信息,改变积分 TUser user = userService.getById(userId); user.setIntegral(user.getIntegral() + completeStudy.getIntegral()); user.setIntegral(user.getIntegral() + sum); update = userService.updateById(user); // 生成积分明细记录 TIntegralRecord integralRecord = new TIntegralRecord(); integralRecord.setIntegral(String.valueOf(sum)); integralRecord.setMethod(Constants.COMPLETE_LEARNING); integralRecord.setUserId(userId); update = update && integralRecordService.save(integralRecord); } // 生成积分明细记录 TIntegralRecord integralRecord = new TIntegralRecord(); integralRecord.setIntegral(String.valueOf(completeStudy.getIntegral())); integralRecord.setMethod(completeStudy.getMethod()); integralRecord.setUserId(userId); return R.ok(update && integralRecordService.save(integralRecord)); // 学习配置列表 List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0).orderByAsc(TStudy::getWeek).list(); if (studyList.isEmpty()) { throw new GlobalException("学习配置列表未配置或数据失效!"); } // 更改学习记录 Boolean updateStudyRecord = userStudyService.exchangeStudyRecord(studyList, userId, completeStudy); return R.ok(update && updateStudyRecord); } /** @@ -933,74 +950,114 @@ * @param week 所属周目 */ @GetMapping("/gameHearing") @ApiOperation(value = "自主游戏1-超级听力", tags = {"学习端-游戏"}) @ApiOperation(value = "自主游戏1-超级听力", tags = {"学习端-听-自主游戏"}) @ApiImplicitParams({ @ApiImplicitParam(value = "季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) }) public R<StudyGamerResultVO> gameHearing(@RequestParam Integer difficulty, @RequestParam Integer week) { TGame game = gameService.lambdaQuery().eq(TGame::getWeek, week) .eq(TGame::getDisabled, 0).one(); public R<StudyGamerResultVO> gameHearing(@RequestParam Integer quarter, @RequestParam Integer difficulty, @RequestParam Integer week) { TGame game = gameService.gameHearing(quarter, week); if (null == game) { throw new GlobalException("当前季度该周目暂无配置游戏数据!"); } game.setIntegral(game.getIntegral().split(",")[difficulty]); game.setTime(game.getTime().split(",")[difficulty]); // 检验是否完成难度 studyService.checkDifficulty(difficulty, week, game); List<String> subjectId = getSubjectId(week); List<String> newSubjectId = subjectId.stream().map(data -> { if (data.startsWith(Constants.REDUCE)) { data = data.replace(Constants.REDUCE, Constants.EMPTY_STR); } return data; }).distinct().collect(Collectors.toList()); // 判断周目下题目是否足够 if (subjectId.size() < game.getCount()) { if (newSubjectId.size() < game.getCount()) { throw new GlobalException("当前周目下day1 - day5题目不足!"); } // 根据游戏设置数量获取图片及语音 List<String> subjectData = new ArrayList<>(); Random random = new Random(); // 获取列表大小 int dataSize = subjectId.size(); int dataSize = newSubjectId.size(); // 生成随机索引并获取数据 for (int i = 0; i < game.getCount(); i++) { // 生成随机索引 int randomIndex = random.nextInt(dataSize); // 获取对应的数据并加入结果列表 subjectData.add(subjectId.get(randomIndex)); subjectData.add(newSubjectId.get(randomIndex)); newSubjectId.remove(randomIndex); dataSize = newSubjectId.size(); } return R.ok(new StudyGamerResultVO(game, subjectService.lambdaQuery().in(TSubject::getId, subjectData).eq(TSubject::getState, 1).list())); List<TSubject> subjectList = getSubjectList(subjectData); return R.ok(new StudyGamerResultVO(game, subjectList)); } /** * 自主游戏2-超级记忆 * * @param difficulty 难度(0入门、1中级、2困难) * @param week 所属周目 * @param quarter 季度 * @param week 所属周目 */ @GetMapping("/gameMemory") @ApiOperation(value = "自主游戏2-超级记忆", tags = {"学习端-游戏"}) @ApiOperation(value = "自主游戏2-超级记忆", tags = {"学习端-听-自主游戏"}) @ApiImplicitParams({ @ApiImplicitParam(value = "难度(0入门、1中级、2困难)", name = "difficulty", dataType = "Integer", required = true), @ApiImplicitParam(value = "季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) }) public R<StudyGamerResultVO> gameMemory(@RequestParam Integer difficulty, @RequestParam Integer week) { TGame game = gameService.lambdaQuery().eq(TGame::getWeek, week).eq(TGame::getDisabled, 0).one(); // 检验是否完成难度 studyService.checkDifficulty(difficulty, week, game); public R<StudyGamerResultVO> gameMemory(@RequestParam Integer quarter, @RequestParam Integer week) { TGame game = gameService.gameHearing(quarter, week); if (null == game) { throw new GlobalException("当前季度该周目暂无配置游戏数据!"); } List<String> subjectId = getSubjectId(week); List<String> newSubjectId = subjectId.stream().map(data -> { if (data.startsWith(Constants.REDUCE)) { data = data.replace(Constants.REDUCE, Constants.EMPTY_STR); } return data; }).distinct().collect(Collectors.toList()); // 判断周目下题目是否足够 if (subjectId.size() < game.getCount()) { if (newSubjectId.size() < game.getAnswerCount()) { throw new GlobalException("当前周目下day1 - day5题目不足!"); } // 根据游戏设置数量获取图片及语音 List<String> subjectData = new ArrayList<>(); Random random = new Random(); // 获取列表大小 int dataSize = subjectId.size(); int dataSize = newSubjectId.size(); // 生成随机索引并获取数据 for (int i = 0; i < game.getCount(); i++) { // 生成随机索引 int randomIndex = random.nextInt(dataSize); // 获取对应的数据并加入结果列表 subjectData.add(subjectId.get(randomIndex)); subjectData.add(newSubjectId.get(randomIndex)); newSubjectId.remove(randomIndex); dataSize = newSubjectId.size(); } return R.ok(new StudyGamerResultVO(game, subjectService.lambdaQuery().in(TSubject::getId, subjectData).eq(TSubject::getState, 1).list())); List<TSubject> subjectList = getSubjectList(subjectData); // 格子翻倍,前端需要做连连看 List<TSubject> resultList = new ArrayList<>(); for (int i = 0; i < Constants.TWO; i++) { resultList.addAll(subjectList); } // 框架记忆数量翻倍,前端需要根据数量画格子 game.setAnswerCount(game.getAnswerCount() * 2); return R.ok(new StudyGamerResultVO(game, resultList)); } private List<TSubject> getSubjectList(List<String> subjectData) { List<TSubject> subjectList = new ArrayList<>(); for (String subjectDatum : subjectData) { if (subjectDatum.startsWith("-")) { subjectDatum = subjectDatum.replace("-", ""); } TSubject subject = subjectService.lambdaQuery().eq(TSubject::getId, subjectDatum) .eq(TSubject::getState, 1).one(); subjectList.add(subject); } return subjectList; } /** @@ -1010,7 +1067,7 @@ * @param completeStudy 学习信息 */ @PostMapping("/gameAchievement") @ApiOperation(value = "完成游戏-记录游戏测试成绩", tags = {"学习端-游戏"}) @ApiOperation(value = "完成游戏-记录游戏测试成绩", tags = {"学习端-听-自主游戏"}) public R<Boolean> gameAchievement(@RequestBody CompleteGameDTO completeStudy) { /* * 游戏测试需要根据正确率计算本次测试可获得积分 @@ -1018,16 +1075,30 @@ * 例如:游戏配置的积分是100,他的正确率是50%那么拿50分,下次他再玩这个游戏 正确率是60% 那么他该获得60分 但是上次已经拿了50 所以这次就只给他加10积分 */ Integer userid = tokenService.getLoginUserStudy().getUserid(); TGame game = gameService.getById(completeStudy.getGameId()); TGame game = gameService.lambdaQuery().eq(TGame::getId, completeStudy.getGameId()).eq(TGame::getDisabled, 0).one(); if (null == game) { throw new GlobalException("游戏信息异常!"); } // 积分明细 List<TIntegralRecord> integralRecordList = integralRecordService.lambdaQuery().eq(TIntegralRecord::getUserId, userid) .eq(TIntegralRecord::getGameId, game.getId()).eq(TIntegralRecord::getDisabled, 0).list(); Integer availableIntegral = gameService.countIntegral(userid, game, completeStudy, integralRecordList); // 本次游戏总共能获取的积分数量 Integer integral; if (completeStudy.getGameName().equals(Constants.HEARING)) { // 本次游戏总积分 integral = Integer.parseInt(game.getIntegral().split(",")[completeStudy.getDifficulty()]); } else if (completeStudy.getGameName().equals(Constants.MEMORY)) { integral = game.getAnswerIntegral(); } else { throw new GlobalException("该次游戏积分计算异常!"); } int gameAvailableIntegral = integral * (completeStudy.getAccuracy() / 100); Integer availableIntegral = gameService.countIntegral(userid, game, completeStudy, gameAvailableIntegral, integralRecordList); // 游戏测试记录 Boolean add = gameRecordService.add(completeStudy); // 可获得积分不为null时,才添加积分明细记录 if (null != availableIntegral) { add = add && integralRecordService.add(String.valueOf(availableIntegral), completeStudy.getMethod(), completeStudy.getGameId(), null); add = add && integralRecordService.add(String.valueOf(availableIntegral), Constants.COMPLETE_GAME, completeStudy.getGameId(), null); // 用户账户添加积分 TUser user = userService.getById(userid); user.setIntegral(user.getIntegral() + availableIntegral); @@ -1038,27 +1109,31 @@ private List<String> getSubjectId(Integer week) { // 当前week下day1 - day5所有题目 List<String> subjectId = redisService.getCacheList(RedisConstants.HEARING_TREE); if (null == subjectId || subjectId.isEmpty()) { List<String> listenSubject = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week) .eq(TStudyListen::getDisabled, 0).list().stream().map(TStudyListen::getSubject).collect(Collectors.toList()); List<String> inductionSubject = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week) .eq(TStudyInduction::getDisabled, 0).list().stream().map(TStudyInduction::getSubject).collect(Collectors.toList()); List<String> lookSubject = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week) .eq(TStudyLook::getDisabled, 0).list().stream().map(TStudyLook::getSubject).collect(Collectors.toList()); List<String> pairSubject = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week) .eq(TStudyPair::getDisabled, 0).list().stream().map(TStudyPair::getSubject).collect(Collectors.toList()); listenSubject.addAll(inductionSubject); listenSubject.addAll(lookSubject); listenSubject.addAll(pairSubject); // 获取具体subject信息 subjectId = new ArrayList<>(); for (String subject : listenSubject) { subjectId.addAll(Arrays.asList(subject.split(","))); } redisService.setCacheList(RedisConstants.HEARING_TREE, subjectId); redisService.expire(RedisConstants.HEARING_TREE, RedisConstants.THIRTY, TimeUnit.MINUTES); List<String> subjectId = new ArrayList<>(); List<String> listenSubject = studyListenService.lambdaQuery().eq(TStudyListen::getWeek, week) .eq(TStudyListen::getDisabled, 0).list().stream().map(TStudyListen::getSubject).collect(Collectors.toList()); List<String> inductionSubject = studyInductionService.lambdaQuery().eq(TStudyInduction::getWeek, week) .eq(TStudyInduction::getDisabled, 0).list().stream().map(TStudyInduction::getSubject).collect(Collectors.toList()); List<String> lookSubject = studyLookService.lambdaQuery().eq(TStudyLook::getWeek, week) .eq(TStudyLook::getDisabled, 0).list().stream().map(TStudyLook::getSubject).collect(Collectors.toList()); List<String> pairSubject = studyPairService.lambdaQuery().eq(TStudyPair::getWeek, week) .eq(TStudyPair::getDisabled, 0).list().stream().map(TStudyPair::getSubject).collect(Collectors.toList()); List<String> studyAnswerList = studyAnswerService.lambdaQuery().eq(TStudyAnswer::getWeek, week) .eq(TStudyAnswer::getDisabled, 0).list().stream().map(data -> String.valueOf(data.getSubject())).collect(Collectors.toList()); // 自主学习1-4需要单独处理 for (String s : listenSubject) { subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList())); } for (String s : inductionSubject) { subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList())); } for (String s : lookSubject) { subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList())); } for (String s : pairSubject) { subjectId.addAll(Arrays.stream(s.split(",")).collect(Collectors.toList())); } subjectId.addAll(studyAnswerList); return subjectId; } @@ -1068,18 +1143,18 @@ * @param week 周目 */ @GetMapping("/lookPictureDbu") @ApiOperation(value = "自主故事1-看图配音", tags = {"学习端-故事"}) @ApiOperation(value = "自主故事1-看图配音", tags = {"学习端-听-自主故事"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) }) public R<StudyStoryListenResultVO> lookPictureDbu(@RequestParam Integer week) { public R<StudyStoryListenResultVO> lookPictureDbu(@RequestParam Integer quarter, @RequestParam Integer week) { // 看图配音信息 TStoryListen listen = storyListenService.lambdaQuery().eq(TStoryListen::getWeek, week).one(); // 获取对应图片语音 TStoryListen listen = gettStoryListen(quarter, week); List<String> list = Arrays.asList(listen.getLookStory().split(",")); List<TSubject> subjectList; List<TStory> subjectList; if (!list.isEmpty()) { subjectList = subjectService.lambdaQuery().in(TSubject::getId, list).eq(TSubject::getState, 1).list(); subjectList = storyService.lambdaQuery().in(TStory::getId, list).eq(TStory::getDisabled, 0).list(); } else { subjectList = new ArrayList<>(); } @@ -1092,36 +1167,52 @@ * @param week 周目 */ @GetMapping("/frameworkMemory") @ApiOperation(value = "自主故事2-框架记忆", tags = {"学习端-故事"}) @ApiOperation(value = "自主故事2-框架记忆", tags = {"学习端-听-自主故事"}) @ApiImplicitParams({ @ApiImplicitParam(value = "所属季度", name = "quarter", dataType = "Integer", required = true), @ApiImplicitParam(value = "所属周目", name = "week", dataType = "Integer", required = true) }) public R<StudyStoryListenResultVO> frameworkMemory(@RequestParam Integer week) { // 看图配音信息 TStoryListen listen = storyListenService.lambdaQuery().eq(TStoryListen::getWeek, week).one(); public R<StudyStoryListenResultVO> frameworkMemory(@RequestParam Integer quarter, @RequestParam Integer week) { TStoryListen listen = gettStoryListen(quarter, week); // 获取对应图片语音 List<String> list = Arrays.asList(listen.getStory().split(",")); List<TSubject> subjectList; List<TStory> subjectList; if (!list.isEmpty()) { subjectList = subjectService.lambdaQuery().in(TSubject::getId, list).eq(TSubject::getState, 1).list(); subjectList = storyService.lambdaQuery().in(TStory::getId, list).eq(TStory::getDisabled, 0).list(); } else { subjectList = new ArrayList<>(); } return R.ok(new StudyStoryListenResultVO(listen,subjectList)); return R.ok(new StudyStoryListenResultVO(listen, subjectList)); } private TStoryListen gettStoryListen(Integer quarter, Integer week) { // 看图配音信息 List<TStoryListen> storyListenList = storyListenService.storyDetail(quarter, week); if (storyListenList.isEmpty()) { throw new GlobalException("当前季度该周目下未配置故事信息!"); } // 获取对应图片语音 TStoryListen listen; if (storyListenList.size() == Constants.ONE) { listen = storyListenList.get(Constants.ZERO); } else { // 随机获取一组题 Random rand = new Random(); listen = storyListenList.get(rand.nextInt(storyListenList.size())); } return listen; } /** * 完成故事类型 */ @GetMapping("/completeStory") @ApiOperation(value = "完成故事学习", tags = {"学习端-故事"}) @ApiOperation(value = "完成故事学习", tags = {"学习端-听-自主故事"}) @ApiImplicitParams({ @ApiImplicitParam(value = "积分数量", name = "integral", dataType = "Integer", required = true), @ApiImplicitParam(value = "故事id", name = "storyId", dataType = "Integer", required = true), @ApiImplicitParam(value = "完成答题/完成听故事", name = "method", dataType = "String", required = true) @ApiImplicitParam(value = "故事id", name = "storyId", dataType = "Integer", required = true) }) public R<Boolean> completeStory(@RequestParam Integer integral, @RequestParam Integer storyId, @RequestParam String method) { public R<Boolean> completeStory(@RequestParam Integer integral, @RequestParam Integer storyId) { TStoryListen storyListen = storyListenService.lambdaQuery().eq(TStoryListen::getId, storyId).eq(TStoryListen::getDisabled, 0).one(); if (null == storyListen) { throw new GlobalException("当前故事学习失败,故事信息异常,请重试!"); @@ -1134,7 +1225,7 @@ Boolean result = true; if (null == integralRecord) { // 添加积分明细记录 result = integralRecordService.add(String.valueOf(integral), method, null, storyId); result = integralRecordService.add(String.valueOf(integral), Constants.COMPLETE_STORY, null, storyId); TUser user = userService.lambdaQuery().eq(TUser::getId, userId).one(); // 添加积分 user.setIntegral(user.getIntegral() + integral); @@ -1156,11 +1247,12 @@ .eq(TGameRecord::getDisabled, 0).list(); return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); } @GetMapping("/record") @ApiOperation(value = "游戏测试成绩", tags = {"家长端-游戏测试成绩"}) public R<StudyRecordResultVO> record() { LoginUserParent loginUser1 = tokenService.getLoginUser1(); if (loginUser1 == null){ if (loginUser1 == null) { return R.tokenError("登陆失效,请重新登录"); } Integer userId = loginUser1.getUserid(); @@ -1169,11 +1261,11 @@ TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) .eq(TUserStudy::getDisabled, 0).one(); // 查询剩余周目 if (studyRecord!=null){ if (studyRecord != null) { int size = studyService.list(new QueryWrapper<TStudy>() .eq("type", 1)).size(); studyRecord.setSurplus(size-studyRecord.getWeek()); }else{ studyRecord.setSurplus(size - studyRecord.getWeek()); } else { TUserStudy tUserStudy = new TUserStudy(); tUserStudy.setSurplus(studyService.list(new QueryWrapper<TStudy>() .eq("type", 1)).size()); @@ -1184,12 +1276,14 @@ .eq(TGameRecord::getDisabled, 0).list(); return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList)); } @GetMapping("/getIntegral") @ApiOperation(value = "获取剩余积分", tags = {"家长端-获取剩余积分"}) public R<Integer> getIntegral() { Integer userId = tokenService.getLoginUser1().getUserid(); return R.ok(userService.getById(userId).getIntegral()); } @GetMapping("/getIntegralStudy") @ApiOperation(value = "获取剩余积分", tags = {"学习端-获取剩余积分"}) public R<Integer> getIntegralStudy() { @@ -1207,26 +1301,27 @@ public R<IPage<TIntegralRecord>> integralDetail(String time, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) { if(tokenService.getLoginUserStudy() == null){ if (tokenService.getLoginUserStudy() == null) { return R.tokenError("登录失效"); } return R.ok(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUserStudy().getUserid(), time)); } @GetMapping("/integralDetailParent") @ApiOperation(value = "个人中心-积分明细", tags = {"家长端"}) @ApiImplicitParams({ @ApiImplicitParam(value = "查询时间 格式yyyy-MM", name = "time", dataType = "Integer"), @ApiImplicitParam(value = "页码", name = "pageNumber", dataType = "Integer", required = true), @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true), @ApiImplicitParam(value = "每页显示条数", name = "pageSize", dataType = "Integer", required = true) }) public R<IPage<TIntegralRecord>> integralDetailParent(String time, @RequestParam("pageNumber") Integer pageNumber, @RequestParam("pageSize") Integer pageSize) { if(tokenService.getLoginUser1() == null){ @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) { if (tokenService.getLoginUser1() == null) { return R.tokenError("登录失效"); } return R.ok(integralRecordService.integralDetail(new Page<>(pageNumber, pageSize), tokenService.getLoginUser1().getUserid(), time)); return R.ok(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUser1().getUserid(), time)); } /** @@ -1256,6 +1351,7 @@ integralRecord.setUpdateTime(new Date()); return R.ok(integralRecordService.save(integralRecord)); } @GetMapping("/addIntegralDetail1") // @ApiOperation(value = "添加-积分明细", tags = {"添加-积分明细"}) @ApiImplicitParams({ @@ -1265,7 +1361,7 @@ public R addIntegralDetail1(@RequestParam("integral") String integral, @RequestParam("method") String method) { // 当前登录用户 LoginUserParent userStudy = tokenService.getLoginUser1(); if (userStudy == null){ if (userStudy == null) { return R.tokenError("登录失效"); } // 生成积分明细信息 @@ -1298,6 +1394,7 @@ } return R.ok(userService.updateById(user)); } @GetMapping("/exchangeIntegral1") // @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"}) public R<Boolean> exchangeIntegral1(@RequestParam("integral") Integer integral, @RequestParam("method") String method) { ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -104,6 +104,7 @@ @Autowired private PayMoneyUtil payMoneyUtil; @PostMapping("/pay") @ApiOperation(value = "购买会员支付操作", tags = {"家长端-个人中心"}) @ApiImplicitParams({ @@ -132,6 +133,7 @@ } return AjaxResult.success(); } @PostMapping("/order") @ApiOperation(value = "购买会员下单操作", tags = {"家长端-个人中心"}) @ApiImplicitParams({ @@ -661,9 +663,10 @@ */ @GetMapping("/userInfo") @ApiOperation(value = "用户详情", tags = {"学习端-用户详情"}) public R<TUser> userInfo() { return R.ok(userService.lambdaQuery().eq(TUser::getId, tokenService.getLoginUserStudy().getUserid()).one()); public R<UserPersonalCenterVO> userInfo() { TUser user = userService.lambdaQuery().eq(TUser::getId, tokenService.getLoginUserStudy().getUserid()).one(); TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, user.getId()).eq(TUserStudy::getDisabled, 0).one(); return R.ok(new UserPersonalCenterVO(user, userStudy)); } @PostMapping("/deleteUser") ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TGame.java
@@ -39,17 +39,17 @@ /** * 题目数量 */ @ApiModelProperty("题目数量") @ApiModelProperty("超级听力题目数量") private Integer count; /** * 积分逗号隔开 第一个对应入门第二个对应中级... */ @ApiModelProperty("对应可获取积分数量(第一个为入门难度;第二个为中级难度;第三个为困难难度)") @ApiModelProperty("超级听力对应可获取积分数量(第一个为入门难度;第二个为中级难度;第三个为困难难度)") private String integral; /** * 时间逗号隔开 第一个对应入门第二个对应中级... */ @ApiModelProperty("时间范围(第一个为入门难度;第二个为中级难度;第三个为困难难度)") @ApiModelProperty("超级听力时间范围(第一个为入门难度;第二个为中级难度;第三个为困难难度)") private String time; /** ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TSubjectRecord.java
@@ -58,5 +58,4 @@ @ApiModelProperty(value = "已回答正确的题目id 多个逗号隔开") private String completeSubject; } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/domain/TUserStudy.java
@@ -43,23 +43,28 @@ * 所属周目 */ @ApiModelProperty(value = "所属周目") private Integer week;/** private Integer week; /** * 故事名称 */ @ApiModelProperty(value = "学习进度dayXX") private Integer day;/** private Integer day; /** * 故事名称 */ @ApiModelProperty(value = "总学习时长 单位小时") private Integer totalStudy;/** private Integer totalStudy; /** * 故事名称 */ @ApiModelProperty(value = "今日学习时长 单位小时") private Integer todayStudy;/** private Integer todayStudy; /** * 故事名称 */ @ApiModelProperty(value = "本周学习时长") private Integer weekStudy;/** private Integer weekStudy; /** * 故事名称 */ @ApiModelProperty(value = "本月学习时长") ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteGameDTO.java
@@ -32,7 +32,7 @@ /** * 游戏名称 */ @ApiModelProperty("游戏名称") @ApiModelProperty("游戏名称(超级听力/超级记忆)") private String gameName; /** @@ -40,17 +40,5 @@ */ @ApiModelProperty("正确率") private Integer accuracy; /** * 根据正确率计算可获得积分数量 */ @ApiModelProperty("根据正确率计算可获得积分数量") private Integer availableIntegral; /** * 完成听故事、完成游戏、完成答题、完成每日学习、商城消费 */ @ApiModelProperty("完成听故事、完成游戏、完成答题、完成每日学习、商城消费") private String method; } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/CompleteStudyDTO.java
@@ -3,6 +3,9 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.NotNull; import java.util.List; /** * @author HJL * @version 1.0 @@ -12,16 +15,16 @@ public class CompleteStudyDTO { /** * 积分数量 * 题目id数组 */ @ApiModelProperty("积分数量") private Integer integral; @ApiModelProperty("题目类型(1:听音选图;2:看图选音;3:归纳排除;4:有问有答;5:音图相配)") private Integer type; /** * 完成听故事、完成游戏、完成答题、完成每日学习、商城消费 * 题目id数组 */ @ApiModelProperty("完成听故事、完成游戏、完成答题、完成每日学习、商城消费、分享") private String method; @ApiModelProperty("题目id数组") private List<Integer> studyIds; /** * 该学习是否完成 @@ -29,4 +32,11 @@ @ApiModelProperty("该学习是否完成(如果已完成再次进入学习并完成学习后,该字段传值 false)") private Boolean isComplete; /** * 学习时长 */ @ApiModelProperty("完成学习所用时长") @NotNull(message = "本次学习时长不能为空!") private Integer studyTime; } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/dto/StudyWeekDTO.java
@@ -14,7 +14,7 @@ public class StudyWeekDTO extends StudyDTO { @ApiModelProperty("完成后可获积分数") private Integer totalIntegral; private Long totalIntegral; @ApiModelProperty("所属季度") private Integer quarter; ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TGameMapper.java
@@ -2,6 +2,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TGame; import org.apache.ibatis.annotations.Param; /** * <p> @@ -13,4 +14,12 @@ */ public interface TGameMapper extends BaseMapper<TGame> { /** * 获取游戏详情 * * @param quarter 季度 * @param week 所属周目 * @return 游戏信息 */ TGame gameHearing(@Param("quarter") Integer quarter, @Param("week") Integer week); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStoryListenMapper.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TStoryListen; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +16,12 @@ */ public interface TStoryListenMapper extends BaseMapper<TStoryListen> { /** * 获取故事详情 * * @param quarter 季度 * @param week 周 * @return 故事信息 */ List<TStoryListen> storyDetail(@Param("quarter") Integer quarter, @Param("week") Integer week); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStudyAnswerMapper.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TStudyAnswer; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +16,13 @@ */ public interface TStudyAnswerMapper extends BaseMapper<TStudyAnswer> { /** * 自主学习4-有问有答 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 有问有答 */ List<TStudyAnswer> questionsAndAnswers(@Param("quarter") Integer quarter, @Param("week") Integer week, @Param("day") Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStudyInductionMapper.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TStudyInduction; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +16,13 @@ */ public interface TStudyInductionMapper extends BaseMapper<TStudyInduction> { /** * 自主学习3-归纳排除 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 归纳排除 */ List<TStudyInduction> induceExclude(@Param("quarter") Integer quarter, @Param("week") Integer week, @Param("day") Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStudyListenMapper.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TStudyListen; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +16,13 @@ */ public interface TStudyListenMapper extends BaseMapper<TStudyListen> { /** * 自主学习1-听音选图 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 听音选图 */ List<TStudyListen> listenSelectPicture(@Param("quarter") Integer quarter, @Param("week") Integer week, @Param("day") Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStudyLookMapper.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TStudyLook; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +16,13 @@ */ public interface TStudyLookMapper extends BaseMapper<TStudyLook> { /** * 自主学习2-看图选音 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 听音选图 */ List<TStudyLook> pictureSelectVoice(@Param("quarter") Integer quarter, @Param("week") Integer week, @Param("day") Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/mapper/TStudyPairMapper.java
@@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.study.domain.TStudyPair; import org.apache.ibatis.annotations.Param; import java.util.List; /** * <p> @@ -13,4 +16,13 @@ */ public interface TStudyPairMapper extends BaseMapper<TStudyPair> { /** * 自主学习5-音图相配 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 音图相配 */ List<TStudyPair> pictureMateVoice(@Param("quarter") Integer quarter, @Param("week") Integer week, @Param("day") Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITGameService.java
@@ -20,11 +20,22 @@ /** * 根据正确率计算用户本次游戏可获得的积分数量 * * @param userid 用户id * @param game 游戏信息 * @param integralRecordList 积分明细信息 * @param completeStudy 游戏测试信息 * @param userid 用户id * @param game 游戏信息 * @param integralRecordList 积分明细信息 * @param completeStudy 游戏测试信息 * @param gameAvailableIntegral 本次游戏可获得积分数量 * @return 可获得积分数量 */ Integer countIntegral(Integer userid ,TGame game, CompleteGameDTO completeStudy, List<TIntegralRecord> integralRecordList); Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy, Integer gameAvailableIntegral, List<TIntegralRecord> integralRecordList); /** * 获取游戏详情 * * @param quarter 季度 * @param week 所属周目 * @return 游戏信息 */ TGame gameHearing(Integer quarter, Integer week); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStoryListenService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStoryListen; import java.util.List; /** * <p> * 听故事 服务类 @@ -13,4 +15,12 @@ */ public interface ITStoryListenService extends IService<TStoryListen> { /** * 获取故事详情 * * @param quarter 季度 * @param week 周 * @return 故事信息 */ List<TStoryListen> storyDetail(Integer quarter, Integer week); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyAnswerService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStudyAnswer; import java.util.List; /** * <p> * 自主游戏 服务类 @@ -13,4 +15,13 @@ */ public interface ITStudyAnswerService extends IService<TStudyAnswer> { /** * 自主学习4-有问有答 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 有问有答 */ List<TStudyAnswer> questionsAndAnswers(Integer quarter, Integer week, Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyInductionService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStudyInduction; import java.util.List; /** * <p> * 自主游戏 服务类 @@ -13,4 +15,13 @@ */ public interface ITStudyInductionService extends IService<TStudyInduction> { /** * 自主学习3-归纳排除 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 归纳排除 */ List<TStudyInduction> induceExclude(Integer quarter, Integer week, Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyListenService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStudyListen; import java.util.List; /** * <p> * 自主游戏 服务类 @@ -13,4 +15,13 @@ */ public interface ITStudyListenService extends IService<TStudyListen> { /** * 自主学习1-听音选图 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 听音选图 */ List<TStudyListen> listenSelectPicture(Integer quarter, Integer week, Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyLookService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStudyLook; import java.util.List; /** * <p> * 自主游戏 服务类 @@ -13,4 +15,13 @@ */ public interface ITStudyLookService extends IService<TStudyLook> { /** * 自主学习2-看图选音 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 听音选图 */ List<TStudyLook> pictureSelectVoice(Integer quarter, Integer week, Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyPairService.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStudyPair; import java.util.List; /** * <p> * 自主游戏 服务类 @@ -13,4 +15,13 @@ */ public interface ITStudyPairService extends IService<TStudyPair> { /** * 自主学习5-音图相配 * * @param quarter 季度 * @param week 周目 * @param day 所属day * @return 音图相配 */ List<TStudyPair> pictureMateVoice(Integer quarter, Integer week, Integer day); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITStudyService.java
@@ -31,10 +31,9 @@ * * @param userId 用户id * @param week 周目 * @param day 所属day * @return 学习信息 */ TUserStudy studySchedule(String userId, Integer week, Integer day); TUserStudy studySchedule(String userId, Integer week); /** * 自主学习1-听音选图 @@ -93,6 +92,6 @@ * @param pair 音图相配 * @return 题目信息 */ StudyPairResultVO pictureMateVoice(Integer week, Integer day, TStudyPair pair); StudyPairResultVO pictureMateVoice(Integer week, Integer day, List<TStudyPair> pair); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/ITUserStudyService.java
@@ -1,7 +1,11 @@ package com.ruoyi.study.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.study.domain.TStudy; import com.ruoyi.study.domain.TUserStudy; import com.ruoyi.study.dto.CompleteStudyDTO; import java.util.List; /** * <p> @@ -18,15 +22,24 @@ * * @param userId 用户id * @param week 周目 * @param day 所属day * @return 学习信息 */ TUserStudy studySchedule(String userId, Integer week, Integer day); TUserStudy studySchedule(String userId, Integer week); /** * 根据条件清空用户学习时长 * 定时任务 清空用户学习时长 * * @param time 今日/本周/本月 */ void resettingStudyRecord(String time); /** * 更改学习进度 * * @param studyList 学习配置列表 * @param userId 用户id * @param completeStudy 学习情况 * @return 更改结果 */ Boolean exchangeStudyRecord(List<TStudy> studyList, Integer userId, CompleteStudyDTO completeStudy); } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TGameServiceImpl.java
@@ -23,21 +23,26 @@ public class TGameServiceImpl extends ServiceImpl<TGameMapper, TGame> implements ITGameService { @Override public Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy, List<TIntegralRecord> integralRecordList) { // 本次游戏可获得积分数量 Integer availableIntegral = completeStudy.getAvailableIntegral(); public Integer countIntegral(Integer userid, TGame game, CompleteGameDTO completeStudy, Integer gameAvailableIntegral, List<TIntegralRecord> integralRecordList) { // 积分明细集合为空,当前为第一次完成游戏 if (integralRecordList.isEmpty()) { return availableIntegral; return gameAvailableIntegral; } else { // 积分明细不为空,根据正确率及已获取积分数量计算本次答题可获取的积分数量 List<Integer> integralList = integralRecordList.stream().map(TIntegralRecord::getIntegral).collect(Collectors.toList()).stream().map(Integer::parseInt).collect(Collectors.toList()); List<Integer> integralList = integralRecordList.stream().map(TIntegralRecord::getIntegral).collect(Collectors.toList()) .stream().map(Integer::parseInt).collect(Collectors.toList()); int sumIntegral = integralList.stream().mapToInt(Integer::intValue).sum(); if (availableIntegral > sumIntegral) { return availableIntegral - sumIntegral; if (gameAvailableIntegral > sumIntegral) { return gameAvailableIntegral - sumIntegral; } else { return null; } } } @Override public TGame gameHearing(Integer quarter, Integer week) { return baseMapper.gameHearing(quarter, week); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStoryListenServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.study.mapper.TStoryListenMapper; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 听故事 服务实现类 @@ -17,4 +19,8 @@ @Service public class TStoryListenServiceImpl extends ServiceImpl<TStoryListenMapper, TStoryListen> implements ITStoryListenService { @Override public List<TStoryListen> storyDetail(Integer quarter, Integer week) { return baseMapper.storyDetail(quarter, week); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyAnswerServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.study.service.ITStudyAnswerService; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 自主游戏 服务实现类 @@ -17,4 +19,8 @@ @Service public class TStudyAnswerServiceImpl extends ServiceImpl<TStudyAnswerMapper, TStudyAnswer> implements ITStudyAnswerService { @Override public List<TStudyAnswer> questionsAndAnswers(Integer quarter, Integer week, Integer day) { return baseMapper.questionsAndAnswers(quarter, week, day); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyInductionServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.study.service.ITStudyInductionService; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 自主游戏 服务实现类 @@ -17,4 +19,8 @@ @Service public class TStudyInductionServiceImpl extends ServiceImpl<TStudyInductionMapper, TStudyInduction> implements ITStudyInductionService { @Override public List<TStudyInduction> induceExclude(Integer quarter, Integer week, Integer day) { return baseMapper.induceExclude(quarter, week, day); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyListenServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.study.service.ITStudyListenService; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 自主游戏 服务实现类 @@ -17,4 +19,8 @@ @Service public class TStudyListenServiceImpl extends ServiceImpl<TStudyListenMapper, TStudyListen> implements ITStudyListenService { @Override public List<TStudyListen> listenSelectPicture(Integer quarter, Integer week, Integer day) { return baseMapper.listenSelectPicture(quarter, week, day); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyLookServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.study.mapper.TStudyLookMapper; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 自主游戏 服务实现类 @@ -17,4 +19,8 @@ @Service public class TStudyLookServiceImpl extends ServiceImpl<TStudyLookMapper, TStudyLook> implements ITStudyLookService { @Override public List<TStudyLook> pictureSelectVoice(Integer quarter, Integer week, Integer day) { return baseMapper.pictureSelectVoice(quarter, week, day); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyPairServiceImpl.java
@@ -6,6 +6,8 @@ import com.ruoyi.study.mapper.TStudyPairMapper; import org.springframework.stereotype.Service; import java.util.List; /** * <p> * 自主游戏 服务实现类 @@ -17,4 +19,8 @@ @Service public class TStudyPairServiceImpl extends ServiceImpl<TStudyPairMapper, TStudyPair> implements ITStudyPairService { @Override public List<TStudyPair> pictureMateVoice(Integer quarter, Integer week, Integer day) { return baseMapper.pictureMateVoice(quarter, week, day); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -1,6 +1,7 @@ package com.ruoyi.study.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.exception.GlobalException; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.security.service.TokenService; @@ -51,62 +52,105 @@ } @Override public TUserStudy studySchedule(String userId, Integer week, Integer day) { return userStudyService.studySchedule(userId, week, day); public TUserStudy studySchedule(String userId, Integer week) { return userStudyService.studySchedule(userId, week); } @Override public void checkDifficulty(Integer difficulty, Integer week, TGame game) { // 判断用户是否完成上一个等级 Integer level = GAME_DIFFICULTY_MAP.get(String.valueOf(difficulty)); if (null == level) { throw new GlobalException("游戏等级异常,请重试!"); } // 获取用户游戏进度 Integer userId = tokenService.getLoginUserStudy().getUserid(); List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId).eq(TGameRecord::getGameId, game.getId()).list(); boolean contains = list.stream().map(TGameRecord::getGameDifficulty).collect(Collectors.toList()).contains(level); if (!contains) { throw new GlobalException("请先完成上一难度再挑战当前难度!"); if (!Constants.ZERO.equals(difficulty)) { Integer level = GAME_DIFFICULTY_MAP.get(String.valueOf(difficulty)); if (null == level) { throw new GlobalException("游戏等级异常,请重试!"); } // 获取用户游戏进度 Integer userId = tokenService.getLoginUserStudy().getUserid(); List<TGameRecord> list = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId).eq(TGameRecord::getGameId, game.getId()).list(); boolean contains = list.stream().map(TGameRecord::getGameDifficulty).collect(Collectors.toList()).contains(level); if (!contains) { throw new GlobalException("请先完成上一难度再挑战当前难度!"); } } } @Override public StudyListenResultVO listenSelectPicture(Integer week, Integer day, List<TStudyListen> studyListens) { if (studyListens.isEmpty()) { throw new GlobalException("当前学习周目题目数量不足!"); } // 随机获取一组题 Random rand = new Random(); TStudyListen data = studyListens.get(rand.nextInt(studyListens.size())); TStudyListen data; if (studyListens.size() == 1) { data = studyListens.get(0); } else { data = studyListens.get(rand.nextInt(studyListens.size())); } List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); return new StudyListenResultVO(data, subjectList); } @Override public StudyLookResultVO pictureSelectVoice(Integer week, Integer day, List<TStudyLook> lookList) { if (lookList.isEmpty()) { throw new GlobalException("当前学习周目题目数量不足!"); } // 随机获取一组题 Random rand = new Random(); TStudyLook data = lookList.get(rand.nextInt(lookList.size())); TStudyLook data; if (lookList.size() == 1) { data = lookList.get(0); } else { data = lookList.get(rand.nextInt(lookList.size())); } List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); return new StudyLookResultVO(data, subjectList); } @Override public StudyInductionResultVO induceExclude(Integer week, Integer day, List<TStudyInduction> inductionList) { if (inductionList.isEmpty()) { throw new GlobalException("当前学习周目题目数量不足!"); } // 随机获取一组题 Random rand = new Random(); TStudyInduction data = inductionList.get(rand.nextInt(inductionList.size())); List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); TStudyInduction data; if (inductionList.size() == 1) { data = inductionList.get(0); } else { data = inductionList.get(rand.nextInt(inductionList.size())); } String[] ids = data.getSubject().split(","); List<TSubject> subjectList = new ArrayList<>(); for (String id : ids) { if (id.startsWith("-")) { id = id.replace("-", ""); } subjectList.add(subjectService.getById(id)); } return new StudyInductionResultVO(data, subjectList); } @Override public StudyAnswerResultVO questionsAndAnswers(Integer week, Integer day, List<TStudyAnswer> answerList) { if (answerList.isEmpty()) { throw new GlobalException("当前学习周目题目数量不足!"); } // 随机获取一组题 Random rand = new Random(); TStudyAnswer data = answerList.get(rand.nextInt(answerList.size())); TStudyAnswer data; TStudyAnswer dataTwo; if (answerList.size() == 1) { data = answerList.get(0); dataTwo = answerList.get(0); } else { data = answerList.get(rand.nextInt(answerList.size())); dataTwo = answerList.get(rand.nextInt(answerList.size())); } AnswerVO one = new AnswerVO(); BeanUtils.copyProperties(data, one); answerList.remove(data); TStudyAnswer dataTwo = answerList.get(rand.nextInt(answerList.size())); AnswerVO two = new AnswerVO(); BeanUtils.copyProperties(dataTwo, two); // 获取问题题目 和 回答题目 @@ -127,9 +171,20 @@ } @Override public StudyPairResultVO pictureMateVoice(Integer week, Integer day, TStudyPair pair) { List<TSubject> subjectList = getSubjects(pair.getSubject().split(",")); return new StudyPairResultVO(pair, subjectList); public StudyPairResultVO pictureMateVoice(Integer week, Integer day, List<TStudyPair> pair) { if (pair.isEmpty()) { throw new GlobalException("当前学习周目题目数量不足!"); } // 随机获取一组题 Random rand = new Random(); TStudyPair data; if (pair.size() == 1) { data = pair.get(0); } else { data = pair.get(rand.nextInt(pair.size())); } List<TSubject> subjectList = getSubjects(data.getSubject().split(",")); return new StudyPairResultVO(data, subjectList); } /** @@ -139,7 +194,13 @@ * @return 图片及语音集合 */ private List<TSubject> getSubjects(String[] ids) { return subjectService.lambdaQuery().in(TSubject::getId, Arrays.asList(ids)).list(); List<TSubject> list = new ArrayList<>(); for (String id : ids) { TSubject data = subjectService.lambdaQuery().eq(TSubject::getId, id) .eq(TSubject::getDisabled, 0).one(); list.add(data); } return list; } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
@@ -1,14 +1,19 @@ package com.ruoyi.study.service.impl; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.study.domain.TStudy; import com.ruoyi.study.domain.TUserStudy; import com.ruoyi.study.dto.CompleteStudyDTO; import com.ruoyi.study.mapper.TUserStudyMapper; import com.ruoyi.study.service.ITUserStudyService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; import java.util.Map; /** * <p> @@ -21,11 +26,26 @@ @Service public class TUserStudyServiceImpl extends ServiceImpl<TUserStudyMapper, TUserStudy> implements ITUserStudyService { /** * 所属day map */ private static final Map<String, Integer> DAY_MAP = new HashMap<>(12); static { DAY_MAP.put(Constants.ONE_STR, Constants.TWO); DAY_MAP.put(Constants.TWO_STR, Constants.THREE); DAY_MAP.put(Constants.THREE_STR, Constants.FOUR); DAY_MAP.put(Constants.FOUR_STR, Constants.FIVE); DAY_MAP.put(Constants.FIVE_STR, Constants.ONE); // DAY_MAP.put(Constants.SIX_STR, Constants.SEVEN); // DAY_MAP.put(Constants.SEVEN_STR, Constants.ONE); } @Override public TUserStudy studySchedule(String userId, Integer week, Integer day) { return lambdaQuery().eq(TUserStudy::getUserId, userId) .eq(TUserStudy::getDay, day).eq(TUserStudy::getWeek, week) .eq(TUserStudy::getDisabled, 0).one(); public TUserStudy studySchedule(String userId, Integer week) { LambdaQueryChainWrapper<TUserStudy> wrapper = lambdaQuery().eq(TUserStudy::getUserId, userId); wrapper = null != week ? wrapper.eq(TUserStudy::getWeek, week) : wrapper; return wrapper.eq(TUserStudy::getDisabled, 0).one(); } @Override @@ -44,6 +64,7 @@ break; default: } // 自旋重试 int number = 0; boolean update = this.updateBatchById(list); while (!update) { @@ -54,4 +75,55 @@ number++; } } @Override public Boolean exchangeStudyRecord(List<TStudy> studyList, Integer userId, CompleteStudyDTO completeStudy) { Integer studyTime = completeStudy.getStudyTime(); // 学习记录 TUserStudy userStudyRecord = lambdaQuery().eq(TUserStudy::getUserId, userId) .eq(TUserStudy::getDisabled, 0).one(); Integer type = completeStudy.getType(); if (Constants.ONE.equals(type)) { userStudyRecord.setListen(Constants.ONE_HUNDRED); } else if (Constants.TWO.equals(type)) { userStudyRecord.setLook(Constants.ONE_HUNDRED); } else if (Constants.THREE.equals(type)) { userStudyRecord.setInduction(Constants.ONE_HUNDRED); } else if (Constants.FOUR.equals(type)) { userStudyRecord.setAnswer(Constants.ONE_HUNDRED); } else if (Constants.FIVE.equals(type)) { // 类型五,说明当前day已经全部完成,更新学习记录的 day Integer nextDay = DAY_MAP.get(String.valueOf(userStudyRecord.getDay())); userStudyRecord.setDay(nextDay); // 学习day已切换更新学习进度及学习时长 userStudyRecord.setListen(Constants.ZERO); userStudyRecord.setLook(Constants.ZERO); userStudyRecord.setInduction(Constants.ZERO); userStudyRecord.setAnswer(Constants.ZERO); userStudyRecord.setPair(Constants.ZERO); // 下一day为 1说明该周目已完成,应更改为下一周目 if (Constants.ONE.equals(nextDay)) { // 获取下一周目信息 int index = -1; for (int i = 0; i < studyList.size(); i++) { if (studyList.get(i).getWeek().equals(userStudyRecord.getWeek())) { index = i; break; } } int nextIndex = (index + 1) % studyList.size(); TStudy nextStudy = studyList.get(nextIndex); // 更新学习进度及学习时长 userStudyRecord.setWeek(nextStudy.getWeek()); } } // 更新学习时长 userStudyRecord.setTotalStudy(userStudyRecord.getTotalStudy() + studyTime); userStudyRecord.setTodayStudy(userStudyRecord.getTodayStudy() + studyTime); userStudyRecord.setWeekStudy(userStudyRecord.getWeekStudy() + studyTime); userStudyRecord.setMonthStudy(userStudyRecord.getMonthStudy() + studyTime); // 更新学习进度及学习时长 return this.updateById(userStudyRecord); } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/PromptVoiceVO.java
New file @@ -0,0 +1,24 @@ package com.ruoyi.study.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author HJL * @version 1.0 * @since 2024-06-04 17:00 */ @Data public class PromptVoiceVO { @ApiModelProperty("正确音效") private String correct; @ApiModelProperty("错误音效") private String error; public PromptVoiceVO(String correct, String error) { this.correct = correct; this.error = error; } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/StudyStoryListenResultVO.java
@@ -1,11 +1,10 @@ package com.ruoyi.study.vo; import com.ruoyi.study.domain.TStory; import com.ruoyi.study.domain.TStoryListen; import com.ruoyi.study.domain.TSubject; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import java.util.List; @@ -14,10 +13,9 @@ * @version 1.0 * @since 2024-05-22 14:39 */ @EqualsAndHashCode(callSuper = true) @Data @ApiModel(value = "自主故事-看图配音&&框架记忆返回信息类") public class StudyStoryListenResultVO extends StudyModelVO { public class StudyStoryListenResultVO { /** * 自主故事-看图配音&&框架记忆题目信息 @@ -25,8 +23,14 @@ @ApiModelProperty("自主故事-看图配音&&框架记忆题目信息") private TStoryListen data; public StudyStoryListenResultVO(TStoryListen data, List<TSubject> subjectList) { /** * 自主学习题目所包含录音图片等 */ @ApiModelProperty("故事列表") private List<TStory> storyList; public StudyStoryListenResultVO(TStoryListen data, List<TStory> storyList) { this.data = data; super.setSubjectList(subjectList); this.storyList = storyList; } } ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/UserPersonalCenterVO.java
New file @@ -0,0 +1,26 @@ package com.ruoyi.study.vo; import com.ruoyi.study.domain.TUser; import com.ruoyi.study.domain.TUserStudy; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @author HJL * @version 1.0 * @since 2024-06-04 9:38 */ @Data public class UserPersonalCenterVO { @ApiModelProperty("用户信息") private TUser user; @ApiModelProperty("用户学习信息(学习时长、学习进度)") private TUserStudy userStudy; public UserPersonalCenterVO(TUser user, TUserStudy userStudy) { this.user = user; this.userStudy = userStudy; } } ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TGameMapper.xml
@@ -1,7 +1,13 @@ <?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.ruoyi.study.mapper.TGameMapper"> <select id="gameHearing" resultType="com.ruoyi.study.domain.TGame"> select g.* from t_game g left join t_study s on g.studyId = s.id where g.disabled = 0 and s.disabled = 0 and g.week = #{week} and s.quarter = #{quarter} </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStoryListenMapper.xml
@@ -17,4 +17,8 @@ id, week, story, sort, lookStory, lookSort </sql> <select id="storyDetail" resultMap="BaseResultMap"> select * from t_story_listen sl left join t_study s on sl.studyId = s.id where sl.disabled = 0 and s.disabled = 0 and sl.week = #{week} and s.quarter = #{quarter} </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyAnswerMapper.xml
@@ -2,5 +2,16 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.study.mapper.TStudyAnswerMapper"> <select id="questionsAndAnswers" resultType="com.ruoyi.study.domain.TStudyAnswer"> select sl.* from t_study_answer sl left join t_study s on sl.studyId = s.id <where> sl.disabled = 0 and s.disabled = 0 and sl.day = #{day} and sl.week = #{week} and s.quarter = #{quarter} </where> </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyInductionMapper.xml
@@ -2,6 +2,16 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.study.mapper.TStudyInductionMapper"> <select id="induceExclude" resultType="com.ruoyi.study.domain.TStudyInduction"> select sl.* from t_study_induction sl left join t_study s on sl.studyId = s.id <where> sl.disabled = 0 and s.disabled = 0 and sl.day = #{day} and sl.week = #{week} and s.quarter = #{quarter} </where> </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyListenMapper.xml
@@ -2,6 +2,13 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.study.mapper.TStudyListenMapper"> <select id="listenSelectPicture" resultType="com.ruoyi.study.domain.TStudyListen"> select sl.* from t_study_listen sl left join t_study s on sl.studyId = s.id <where> sl.disabled = 0 and s.disabled = 0 and sl.day = #{day} and sl.week = #{week} and s.quarter = #{quarter} </where> </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyLookMapper.xml
@@ -2,5 +2,13 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.study.mapper.TStudyLookMapper"> <select id="pictureSelectVoice" resultType="com.ruoyi.study.domain.TStudyLook"> select sl.* from t_study_look sl left join t_study s on sl.studyId = s.id <where> sl.disabled = 0 and s.disabled = 0 and sl.day = #{day} and sl.week = #{week} and s.quarter = #{quarter} </where> </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyMapper.xml
@@ -1,22 +1,28 @@ <?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.ruoyi.study.mapper.TStudyMapper"> <!-- 通用查询映射结果 --> <resultMap id="BaseResultMap" type="com.ruoyi.study.domain.TStudy"> <id column="id" property="id" /> <result column="week" property="week" /> <result column="day" property="day" /> <result column="listen" property="listen" /> <result column="type" property="type" /> <result column="integral" property="integral" /> <result column="sort" property="sort" /> <result column="title" property="title" /> <id column="id" property="id"/> <result column="week" property="week"/> <result column="day" property="day"/> <result column="listen" property="listen"/> <result column="type" property="type"/> <result column="integral" property="integral"/> <result column="sort" property="sort"/> <result column="title" property="title"/> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, week, day, listen, type, integral, sort, title id, week, day, listen, type, integral, sort, title </sql> <select id="weekList" resultType="com.ruoyi.study.dto.StudyWeekDTO"> @@ -25,7 +31,8 @@ COALESCE(SUM(g.integral), 0) AS totalIntegral, s.week, s.title, s.quarter,s.id s.quarter, s.id FROM t_study s LEFT JOIN t_study_answer sa ON s.id = sa.studyId LEFT JOIN t_study_induction si ON s.id = si.studyId @@ -34,6 +41,22 @@ LEFT JOIN t_study_pair sp ON s.id = sp.studyId LEFT JOIN t_story_listen sl ON s.id = sl.studyId LEFT JOIN t_game g ON s.id = g.studyId GROUP BY s.week, s.title, s.quarter,s.id; <where> s.disabled = 0 and sa.disabled = 0 and si.disabled = 0 and st.disabled = 0 and sk.disabled = 0 and sp.disabled = 0 and sl.disabled = 0 and g.disabled = 0 <if test="quarter != null and quarter != ''"> and s.quarter = #{quarter} </if> <if test="type != null and quarter != ''"> and s.type = #{type} </if> </where> GROUP BY s.week, s.title, s.quarter, s.id; </select> </mapper> ruoyi-service/ruoyi-study/src/main/resources/mapper/sutdy/TStudyPairMapper.xml
@@ -2,6 +2,16 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.study.mapper.TStudyPairMapper"> <select id="pictureMateVoice" resultType="com.ruoyi.study.domain.TStudyPair"> select sl.* from t_study_pair sl left join t_study s on sl.studyId = s.id <where> sl.disabled = 0 and s.disabled = 0 and sl.day = #{day} and sl.week = #{week} and s.quarter = #{quarter} </where> </select> </mapper>