查询用户标签
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.web.controller.yunbookmark;
|
package com.ruoyi.web.controller.yunbookmark;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -27,12 +29,27 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|||||||
* @date 2020-09-04
|
* @date 2020-09-04
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/system/usertag")
|
@RequestMapping("/usertag/tag")
|
||||||
public class SqUserTagController extends BaseController
|
public class SqUserTagController extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISqUserTagService sqUserTagService;
|
private ISqUserTagService sqUserTagService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用戶标签
|
||||||
|
*/
|
||||||
|
|
||||||
|
@GetMapping(value = "/selectTagByUserID/{userId}")
|
||||||
|
public AjaxResult selectSqUserTagByUserId(@PathVariable("userId") Long userId)
|
||||||
|
{
|
||||||
|
List<Map<String,Object>> map = sqUserTagService.selectSqUserTagByUserId(userId);
|
||||||
|
return AjaxResult.success(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签管理列表
|
* 查询标签管理列表
|
||||||
*/
|
*/
|
||||||
|
@ -2,20 +2,17 @@ package com.ruoyi.web.test.controller;
|
|||||||
|
|
||||||
|
|
||||||
import com.ruoyi.bookmark.mapper.SqMenuMapper;
|
import com.ruoyi.bookmark.mapper.SqMenuMapper;
|
||||||
import com.ruoyi.bookmark.service.impl.SqMenuServiceImpl;
|
import com.ruoyi.bookmark.service.ISqUserTagService;
|
||||||
import com.ruoyi.web.controller.yunbookmark.SqBookmarkController;
|
import com.ruoyi.web.controller.yunbookmark.SqBookmarkController;
|
||||||
import org.assertj.core.api.Assertions;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
|
||||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|
||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Auther: Wang
|
* @Auther: Wang
|
||||||
* @Date: 2020/08/08 18:51
|
* @Date: 2020/08/08 18:51
|
||||||
@ -28,6 +25,12 @@ public class SqBookmarkTest extends BaseSpringBootTest{
|
|||||||
private SqBookmarkController sqBookmarkController;
|
private SqBookmarkController sqBookmarkController;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SqMenuMapper sqMenuMapper;
|
private SqMenuMapper sqMenuMapper;
|
||||||
|
@Autowired
|
||||||
|
private ISqUserTagService iSqUserTagService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
@ -46,13 +49,34 @@ public class SqBookmarkTest extends BaseSpringBootTest{
|
|||||||
// logger.info(mvcResult.getResponse().getContentAsString());
|
// logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
@Test
|
// @Test
|
||||||
public void demo() throws Exception {
|
// public void demo() throws Exception {
|
||||||
Long[] menuIds={1L,4L,6L};
|
// Long[] menuIds={1L,4L,6L};
|
||||||
sqMenuMapper.updateCountAdd(menuIds,5);
|
// sqMenuMapper.updateCountAdd(menuIds,5);
|
||||||
|
//
|
||||||
|
// logger.info("执行完毕");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
/**
|
||||||
|
* @auther: Wang
|
||||||
|
* @date: 2020/09/04 23:58
|
||||||
|
* 功能描述: 测试查询用户的 标签
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void selectSqUserTagByUserId() throws Exception {
|
||||||
|
List<Map<String,Object>> map = iSqUserTagService.selectSqUserTagByUserId(1L);
|
||||||
logger.info("执行完毕");
|
logger.info("执行完毕");
|
||||||
|
for (Map<String, Object> list: map) {
|
||||||
|
for (Map.Entry<String,Object> entry: list.entrySet() ) {
|
||||||
|
System.out.println(entry.getKey()+"="+entry.getValue());
|
||||||
|
}
|
||||||
|
logger.info("========================================");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
package com.ruoyi.bookmark.mapper;
|
package com.ruoyi.bookmark.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ruoyi.bookmark.domain.SqUserTag;
|
import com.ruoyi.bookmark.domain.SqUserTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签管理Mapper接口
|
* 标签管理Mapper接口
|
||||||
*
|
*
|
||||||
* @author wang
|
* @author wang
|
||||||
* @date 2020-09-04
|
* @date 2020-09-04
|
||||||
*/
|
*/
|
||||||
public interface SqUserTagMapper
|
public interface SqUserTagMapper
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*通过用户userID查用户的所有标签
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public List<Map<String,Object>> selectSqUserTagByUserId(Long userId);
|
||||||
/**
|
/**
|
||||||
* 查询标签管理
|
* 查询标签管理
|
||||||
*
|
*
|
||||||
* @param id 标签管理ID
|
* @param id 标签管理ID
|
||||||
* @return 标签管理
|
* @return 标签管理
|
||||||
*/
|
*/
|
||||||
@ -21,7 +29,7 @@ public interface SqUserTagMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签管理列表
|
* 查询标签管理列表
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 标签管理集合
|
* @return 标签管理集合
|
||||||
*/
|
*/
|
||||||
@ -29,7 +37,7 @@ public interface SqUserTagMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增标签管理
|
* 新增标签管理
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -37,7 +45,7 @@ public interface SqUserTagMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改标签管理
|
* 修改标签管理
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -45,7 +53,7 @@ public interface SqUserTagMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标签管理
|
* 删除标签管理
|
||||||
*
|
*
|
||||||
* @param id 标签管理ID
|
* @param id 标签管理ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -53,7 +61,7 @@ public interface SqUserTagMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除标签管理
|
* 批量删除标签管理
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
package com.ruoyi.bookmark.service;
|
package com.ruoyi.bookmark.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ruoyi.bookmark.domain.SqUserTag;
|
import com.ruoyi.bookmark.domain.SqUserTag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签管理Service接口
|
* 标签管理Service接口
|
||||||
*
|
*
|
||||||
* @author wang
|
* @author wang
|
||||||
* @date 2020-09-04
|
* @date 2020-09-04
|
||||||
*/
|
*/
|
||||||
public interface ISqUserTagService
|
public interface ISqUserTagService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*通过用户userID查用户的所有标签
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public List<Map<String,Object>> selectSqUserTagByUserId(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签管理
|
* 查询标签管理
|
||||||
*
|
*
|
||||||
* @param id 标签管理ID
|
* @param id 标签管理ID
|
||||||
* @return 标签管理
|
* @return 标签管理
|
||||||
*/
|
*/
|
||||||
@ -21,7 +33,7 @@ public interface ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签管理列表
|
* 查询标签管理列表
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 标签管理集合
|
* @return 标签管理集合
|
||||||
*/
|
*/
|
||||||
@ -29,7 +41,7 @@ public interface ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增标签管理
|
* 新增标签管理
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -37,7 +49,7 @@ public interface ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改标签管理
|
* 修改标签管理
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -45,7 +57,7 @@ public interface ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除标签管理
|
* 批量删除标签管理
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的标签管理ID
|
* @param ids 需要删除的标签管理ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -53,7 +65,7 @@ public interface ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标签管理信息
|
* 删除标签管理信息
|
||||||
*
|
*
|
||||||
* @param id 标签管理ID
|
* @param id 标签管理ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.bookmark.service.impl;
|
package com.ruoyi.bookmark.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.bookmark.mapper.SqUserTagMapper;
|
import com.ruoyi.bookmark.mapper.SqUserTagMapper;
|
||||||
@ -9,19 +11,32 @@ import com.ruoyi.bookmark.service.ISqUserTagService;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 标签管理Service业务层处理
|
* 标签管理Service业务层处理
|
||||||
*
|
*
|
||||||
* @author wang
|
* @author wang
|
||||||
* @date 2020-09-04
|
* @date 2020-09-04
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SqUserTagServiceImpl implements ISqUserTagService
|
public class SqUserTagServiceImpl implements ISqUserTagService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private SqUserTagMapper sqUserTagMapper;
|
private SqUserTagMapper sqUserTagMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*通过用户userID查用户的所有标签
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String,Object>>selectSqUserTagByUserId(Long userId){
|
||||||
|
return sqUserTagMapper.selectSqUserTagByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签管理
|
* 查询标签管理
|
||||||
*
|
*
|
||||||
* @param id 标签管理ID
|
* @param id 标签管理ID
|
||||||
* @return 标签管理
|
* @return 标签管理
|
||||||
*/
|
*/
|
||||||
@ -33,7 +48,7 @@ public class SqUserTagServiceImpl implements ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询标签管理列表
|
* 查询标签管理列表
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 标签管理
|
* @return 标签管理
|
||||||
*/
|
*/
|
||||||
@ -45,7 +60,7 @@ public class SqUserTagServiceImpl implements ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增标签管理
|
* 新增标签管理
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -57,7 +72,7 @@ public class SqUserTagServiceImpl implements ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改标签管理
|
* 修改标签管理
|
||||||
*
|
*
|
||||||
* @param sqUserTag 标签管理
|
* @param sqUserTag 标签管理
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -69,7 +84,7 @@ public class SqUserTagServiceImpl implements ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除标签管理
|
* 批量删除标签管理
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的标签管理ID
|
* @param ids 需要删除的标签管理ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@ -81,7 +96,7 @@ public class SqUserTagServiceImpl implements ISqUserTagService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标签管理信息
|
* 删除标签管理信息
|
||||||
*
|
*
|
||||||
* @param id 标签管理ID
|
* @param id 标签管理ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.ruoyi.bookmark.mapper.SqUserTagMapper">
|
<mapper namespace="com.ruoyi.bookmark.mapper.SqUserTagMapper">
|
||||||
|
|
||||||
<resultMap type="SqUserTag" id="SqUserTagResult">
|
<resultMap type="SqUserTag" id="SqUserTagResult">
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="userId" column="user_id" />
|
<result property="userId" column="user_id" />
|
||||||
@ -18,19 +18,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectSqUserTagList" parameterType="SqUserTag" resultMap="SqUserTagResult">
|
<select id="selectSqUserTagList" parameterType="SqUserTag" resultMap="SqUserTagResult">
|
||||||
<include refid="selectSqUserTagVo"/>
|
<include refid="selectSqUserTagVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
<if test="tagId != null "> and tag_id = #{tagId}</if>
|
<if test="tagId != null "> and tag_id = #{tagId}</if>
|
||||||
<if test="icount != null "> and icount = #{icount}</if>
|
<if test="icount != null "> and icount = #{icount}</if>
|
||||||
<if test="iorder != null "> and iorder = #{iorder}</if>
|
<if test="iorder != null "> and iorder = #{iorder}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectSqUserTagById" parameterType="Long" resultMap="SqUserTagResult">
|
<select id="selectSqUserTagById" parameterType="Long" resultMap="SqUserTagResult">
|
||||||
<include refid="selectSqUserTagVo"/>
|
<include refid="selectSqUserTagVo"/>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertSqUserTag" parameterType="SqUserTag" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertSqUserTag" parameterType="SqUserTag" useGeneratedKeys="true" keyProperty="id">
|
||||||
insert into sq_user_tag
|
insert into sq_user_tag
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
@ -63,10 +63,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="deleteSqUserTagByIds" parameterType="String">
|
<delete id="deleteSqUserTagByIds" parameterType="String">
|
||||||
delete from sq_user_tag where id in
|
delete from sq_user_tag where id in
|
||||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
<select id="selectSqUserTagByUserId" parameterType="Long" resultType="java.util.Map">
|
||||||
|
SELECT u.id,u.user_id as userId,u.tag_id as tagId ,u.icount,u.iorder,t.name from sq_user_tag AS u,sq_tag as t WHERE u.tag_id=t.id AND u.user_id = 1 ORDER BY u.iorder
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
Reference in New Issue
Block a user