Commit cd0121b3 authored by nie'hong's avatar nie'hong

修改-保存用户最后一次进入的学习内容

parent 29924daf
...@@ -14,6 +14,8 @@ import cn.chnmuseum.party.model.*; ...@@ -14,6 +14,8 @@ import cn.chnmuseum.party.model.*;
import cn.chnmuseum.party.service.*; import cn.chnmuseum.party.service.*;
import cn.chnmuseum.party.service.impl.*; import cn.chnmuseum.party.service.impl.*;
import cn.chnmuseum.party.web.controller.base.BaseController; import cn.chnmuseum.party.web.controller.base.BaseController;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...@@ -31,6 +33,7 @@ import org.apache.shiro.authc.DisabledAccountException; ...@@ -31,6 +33,7 @@ import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.IncorrectCredentialsException; import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authz.annotation.RequiresAuthentication; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
...@@ -108,6 +111,8 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -108,6 +111,8 @@ public class ChinaMobileRestApiController extends BaseController {
private static final String SHIRO_LOGIN_COUNT = "shiro_login_count_"; private static final String SHIRO_LOGIN_COUNT = "shiro_login_count_";
//用户登录是否被锁定 一小时 redisKey 前缀 //用户登录是否被锁定 一小时 redisKey 前缀
private static final String SHIRO_IS_LOCK = "shiro_is_lock_"; private static final String SHIRO_IS_LOCK = "shiro_is_lock_";
// 用户上次进入的学习内容
private static final String LAST_CONTENT = "last_content_";
@ApiOperation(value = "获取机顶盒密钥", notes = "获取机顶盒密钥") @ApiOperation(value = "获取机顶盒密钥", notes = "获取机顶盒密钥")
@GetMapping("/equitment/key") @GetMapping("/equitment/key")
...@@ -477,7 +482,9 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -477,7 +482,9 @@ public class ChinaMobileRestApiController extends BaseController {
// videoList.addAll(datumList.stream().filter(x -> FileTypeEnum.VIDEO.name().equalsIgnoreCase(x.getFileType())).collect(Collectors.toList())); // videoList.addAll(datumList.stream().filter(x -> FileTypeEnum.VIDEO.name().equalsIgnoreCase(x.getFileType())).collect(Collectors.toList()));
// 填充编号 // 填充编号
setBoardSerial(exhibitionBoard); setBoardSerial(exhibitionBoard);
// 删除用户最后一次进入某学习项目的缓存
String userId = getUserId();
stringRedisTemplate.delete(LAST_CONTENT + userId);
} }
return getResult(page); return getResult(page);
} }
...@@ -557,6 +564,10 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -557,6 +564,10 @@ public class ChinaMobileRestApiController extends BaseController {
// 填充编号 // 填充编号
this.setBoardSerial(exhibitionBoard); this.setBoardSerial(exhibitionBoard);
// 记录用户最后一次进入的学习内容,这里记录是从学习内容进入展板参看资料是需要部分显示,但该接口只接收了展板id,没有学习内容id
// 另外,防止中移那边从项目进入展板参考资料和从内容进入参考资料使用同一个接口,需要在app进入项目时删除记录的该缓存
String userId = getUserId();
stringRedisTemplate.opsForValue().set(LAST_CONTENT + userId, learningContentId);
} }
return getResult(page); return getResult(page);
} }
...@@ -804,10 +815,23 @@ public class ChinaMobileRestApiController extends BaseController { ...@@ -804,10 +815,23 @@ public class ChinaMobileRestApiController extends BaseController {
@RequiresAuthentication //@RequiresPermissions("learning:project:page") @RequiresAuthentication //@RequiresPermissions("learning:project:page")
@ApiOperation(value = "展板参考资料分页查询", notes = "展板参考资料分页查询") @ApiOperation(value = "展板参考资料分页查询", notes = "展板参考资料分页查询")
public Map<String, Object> getBoardRefMaterial(@PathVariable(value = "boardId") String boardId) { public Map<String, Object> getBoardRefMaterial(@PathVariable(value = "boardId") String boardId) {
// 用户最后一次进入的学习内容
String userId = getUserId();
String s = stringRedisTemplate.opsForValue().get(LAST_CONTENT + userId);
List<String> list = null;
if (StringUtils.isNotEmpty(s)) {
LambdaQueryWrapper<LearningContentAsset> queryWrapper = Wrappers.<LearningContentAsset>lambdaQuery();
queryWrapper.eq(LearningContentAsset::getLearningContentId, s);
queryWrapper.select(LearningContentAsset::getAssetId);
list = this.learningContentAssetService.listObjs(queryWrapper, Object::toString);
}
final ExhibitionBoard exhibitionBoard = this.exhibitionBoardService.getById(boardId); final ExhibitionBoard exhibitionBoard = this.exhibitionBoardService.getById(boardId);
final LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId()); final LambdaQueryWrapper<Asset> assetQueryWrapper = Wrappers.<Asset>lambdaQuery().eq(Asset::getRefItemId, exhibitionBoard.getId());
assetQueryWrapper.eq(Asset::getPublished, true); assetQueryWrapper.eq(Asset::getPublished, true);
assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name()); assetQueryWrapper.eq(Asset::getFileCat, FileCatEnum.EXHIBITION_BOARD_DATUM.name());
if (CollectionUtil.isNotEmpty(list)) {
assetQueryWrapper.in(Asset::getId, list);
}
final Page<Asset> datumList = this.assetService.page(this.getPage(), assetQueryWrapper); final Page<Asset> datumList = this.assetService.page(this.getPage(), assetQueryWrapper);
return getResult(datumList); return getResult(datumList);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment