11111
This commit is contained in:
parent
3e9cef511a
commit
c25ffa9b2a
@ -0,0 +1,37 @@
|
||||
package com.ruoyi.web.controller.yunbookmark;
|
||||
|
||||
import com.ruoyi.bookmark.service.ISqUserServise;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Auther: Wang
|
||||
* @Date: 2021/10/29 17:32
|
||||
* 功能描述:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class PersonalMessage extends BaseController
|
||||
{
|
||||
|
||||
@Resource
|
||||
private ISqUserServise sqUserServise;
|
||||
|
||||
|
||||
/**
|
||||
* 获取個人的信息 >> 首頁的數據 >> redis
|
||||
*/
|
||||
@GetMapping("/getPersonalMessage")
|
||||
public AjaxResult getPersonalMessage()
|
||||
{
|
||||
return sqUserServise.getPersonalMessage(getAuthUser().getUserId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -3,11 +3,12 @@ package com.ruoyi.web.controller.yunbookmark;
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bookmark.pojo.SqTagReq;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.redis.RedisUtil;
|
||||
import com.ruoyi.common.utils.redis.KeyAll;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
@ -31,6 +32,9 @@ public class SqTagController extends BaseController
|
||||
@Autowired
|
||||
private ISqTagService sqTagService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -67,20 +71,41 @@ public class SqTagController extends BaseController
|
||||
public AjaxResult addByUser(@RequestBody SqTagReq req)
|
||||
{
|
||||
logger.info("[addByUser] 新增标签入参:"+ req.toString());
|
||||
|
||||
//判断是否存在
|
||||
SqTag sqTagGet = new SqTag();
|
||||
sqTagGet.setUserId(getAuthUser().getUserId());
|
||||
sqTagGet.setName(req.getName());
|
||||
List<SqTag> list = sqTagService.selectSqTagList(sqTagGet);
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
return new AjaxResult(600,"该书签已经存在!");
|
||||
}
|
||||
|
||||
SqTag sqTag = new SqTag();
|
||||
BeanUtils.copyProperties(req,sqTag);
|
||||
sqTag.setUserId(getAuthUser().getUserId());
|
||||
BeanUtils.copyProperties(req,sqTag);
|
||||
logger.info("[addByUser] 新增标签:"+ sqTag.toString());
|
||||
sqTagService.insertSqTag(sqTag);
|
||||
|
||||
return new AjaxResult(200,"操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改书签_标签
|
||||
*/
|
||||
@PutMapping("/editByUser")
|
||||
public AjaxResult editByUser(SqTagReq req)
|
||||
@PostMapping("/editByUser")
|
||||
public AjaxResult editByUser(@RequestBody SqTagReq req)
|
||||
{
|
||||
logger.info("[editByUser] 修改书签_标签入参:"+ req.toString());
|
||||
//判断是否存在
|
||||
SqTag sqTagGet = new SqTag();
|
||||
sqTagGet.setUserId(getAuthUser().getUserId());
|
||||
sqTagGet.setName(req.getName());
|
||||
List<SqTag> list = sqTagService.selectSqTagList(sqTagGet);
|
||||
if (!CollectionUtils.isEmpty(list)){
|
||||
return new AjaxResult(600,"该书签已经存在!");
|
||||
}
|
||||
|
||||
SqTag sqTag = new SqTag();
|
||||
BeanUtils.copyProperties(req,sqTag);
|
||||
sqTag.setUserId(getAuthUser().getUserId());
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.ruoyi.common.utils.redis;
|
||||
|
||||
/**
|
||||
* @Auther: Wang
|
||||
* @Date: 2021/10/29 17:46
|
||||
* 功能描述:
|
||||
*/
|
||||
public class KeyAll {
|
||||
|
||||
public static String COLON = ":";
|
||||
|
||||
//用户首页的数据信息 >> 标签的数量
|
||||
public static String PERSONAL_MESSAGE = "bookmark:personal_message:";
|
||||
|
||||
|
||||
}
|
@ -2,7 +2,6 @@ package com.ruoyi.bookmark.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.bookmark.domain.SqBookmarkTag;
|
||||
import com.ruoyi.bookmark.domain.SqTag;
|
||||
import com.ruoyi.common.mybatisMapper.MyMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -69,4 +69,9 @@ public interface ISqTagService
|
||||
public Map<String,Object> addtag(String tagName, Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* @auther: 获取当前用户的总标签数量
|
||||
* @date: 2021/10/29 17:54
|
||||
*/
|
||||
int countByuserId(Long userId);
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.ruoyi.bookmark.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
/**
|
||||
* @Auther: Wang
|
||||
* @Date: 2021/10/29 17:36
|
||||
* 功能描述:
|
||||
*/
|
||||
public interface ISqUserServise {
|
||||
/**
|
||||
*
|
||||
* 获取当前用户 首页的信息展示 redis
|
||||
*
|
||||
*/
|
||||
AjaxResult getPersonalMessage(Long userId);
|
||||
}
|
@ -133,8 +133,12 @@ public class SqTagServiceImpl implements ISqTagService
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int countByuserId(Long userId) {
|
||||
SqTag sqTag = new SqTag();
|
||||
sqTag.setUserId(userId);
|
||||
return sqTagMapper.selectCount(sqTag);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
package com.ruoyi.bookmark.service.impl;
|
||||
|
||||
import com.ruoyi.bookmark.service.ISqTagService;
|
||||
import com.ruoyi.bookmark.service.ISqUserServise;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisUtil;
|
||||
import com.ruoyi.common.utils.bookmarkhtml.Const;
|
||||
import com.ruoyi.common.utils.redis.KeyAll;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Auther: Wang
|
||||
* @Date: 2021/10/29 17:36
|
||||
* 功能描述:
|
||||
*/
|
||||
@Service
|
||||
public class SqUserServiseImpl implements ISqUserServise {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Autowired
|
||||
private ISqTagService sqTagService;
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult getPersonalMessage(Long userId) {
|
||||
|
||||
String key = KeyAll.PERSONAL_MESSAGE + userId.toString();
|
||||
if (!redisUtil.hasKey(key)){
|
||||
//数据不存在 新用户 进行初始化数据
|
||||
Map<Object, Object> mapPersonalMessage = new HashMap<>();
|
||||
//TAG 标签总数量
|
||||
// mapPersonalMessage.put("tagTotal",sqTagService.countByuserId(userId));
|
||||
}
|
||||
return AjaxResult.success(redisUtil.hGetAll(key));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user