编辑书签标签,1.添加书签到总标签库避免重复数据,2.个人用户书签统计,引用统计,3.文章标签修改
This commit is contained in:
		| @@ -5,25 +5,35 @@ import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.ruoyi.common.annotation.Excel; | ||||
| import com.ruoyi.common.core.domain.BaseEntity; | ||||
|  | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.GeneratedValue; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
|  | ||||
| /** | ||||
|  * 书签标签管理对象 sq_bookmark_tag | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| @Table(name="sq_bookmark_tag") | ||||
| public class SqBookmarkTag | ||||
| { | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** ID */ | ||||
|     @Id | ||||
|     @GeneratedValue(generator = "JDBC")//返回自增长主键 | ||||
|     private Long id; | ||||
|  | ||||
|     /** 书签ID */ | ||||
|     @Excel(name = "书签ID") | ||||
|     @Column(name = "bookmark_id") | ||||
|     private Long bookmarkId; | ||||
|  | ||||
|     /** 标签ID */ | ||||
|     @Excel(name = "标签ID") | ||||
|     @Column(name = "tag_id") | ||||
|     private Long tagId; | ||||
|  | ||||
|     public void setId(Long id) | ||||
|   | ||||
| @@ -6,8 +6,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.ruoyi.common.annotation.Excel; | ||||
| import com.ruoyi.common.core.domain.TreeEntity; | ||||
|  | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.Transient; | ||||
| import javax.persistence.*; | ||||
| import java.util.Date; | ||||
|  | ||||
| /** | ||||
| @@ -16,11 +15,13 @@ import java.util.Date; | ||||
|  * @author wanghao | ||||
|  * @date 2020-08-06 | ||||
|  */ | ||||
| @Table(name="sq_menu") | ||||
| public class SqMenu | ||||
| { | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** 书签菜单ID */ | ||||
|     /** ID */ | ||||
|     @Id | ||||
|     @GeneratedValue(generator = "JDBC")//返回自增长主键 | ||||
|     @Column(name = "menu_id") | ||||
|     private Long menuId; | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,10 @@ import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.ruoyi.common.annotation.Excel; | ||||
| import com.ruoyi.common.core.domain.BaseEntity; | ||||
|  | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.GeneratedValue; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
| import java.util.Date; | ||||
|  | ||||
| /** | ||||
| @@ -14,39 +18,48 @@ import java.util.Date; | ||||
|  * @author ruoyi | ||||
|  * @date 2020-09-05 | ||||
|  */ | ||||
| @Table(name="sq_tag") | ||||
| public class SqTag | ||||
| { | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** 书签标签id */ | ||||
|     @Id | ||||
|     @GeneratedValue(generator = "JDBC")//此处加上注解 | ||||
|     private Long id; | ||||
|  | ||||
|     /** 标签名字 */ | ||||
|     @Excel(name = "标签名字") | ||||
|     @Column(name = "name") | ||||
|     private String name; | ||||
|  | ||||
|     /** 引用数量 */ | ||||
|     @Excel(name = "引用数量") | ||||
|     @Column(name = "icount") | ||||
|     private Integer icount; | ||||
|  | ||||
|     /** 谁增加的该标签 */ | ||||
|     @Excel(name = "谁增加的该标签") | ||||
|     @Column(name = "user_Id") | ||||
|     private Long userId; | ||||
|  | ||||
|     /** S系统标签,P书签标签,B便签书签 */ | ||||
|     @Excel(name = "S系统标签,P书签标签,B便签书签") | ||||
|     @Column(name = "tag_type") | ||||
|     private String tagType; | ||||
|  | ||||
|     /** 链接 */ | ||||
|     @Excel(name = "链接") | ||||
|     @Column(name = "url") | ||||
|     private String url; | ||||
|  | ||||
|     /** 状态 */ | ||||
|     @Excel(name = "状态") | ||||
|     @Column(name = "status") | ||||
|     private Integer status; | ||||
|  | ||||
|     /** 创建时间 */ | ||||
|     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     @Column(name = "create_time") | ||||
|     private Date createTime; | ||||
|  | ||||
|     public void setId(Long id) | ||||
|   | ||||
| @@ -5,77 +5,89 @@ import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.ruoyi.common.annotation.Excel; | ||||
| import com.ruoyi.common.core.domain.BaseEntity; | ||||
|  | ||||
| import javax.persistence.Column; | ||||
| import javax.persistence.GeneratedValue; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
|  | ||||
| /** | ||||
|  * 标签管理对象 sq_user_tag | ||||
|  *  | ||||
|  * | ||||
|  * @author wang | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| @Table(name="sq_user_tag") | ||||
| public class SqUserTag extends BaseEntity | ||||
| { | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** ID */ | ||||
|     @Id | ||||
|     @GeneratedValue(generator = "JDBC")//此处加上注解 | ||||
|     private Long id; | ||||
|  | ||||
|     /** 用户ID */ | ||||
|     @Excel(name = "用户ID") | ||||
|     @Column(name = "user_id") | ||||
|     private Long userId; | ||||
|  | ||||
|     /** 书签ID */ | ||||
|     @Excel(name = "书签ID") | ||||
|     @Column(name = "tag_id") | ||||
|     private Long tagId; | ||||
|  | ||||
|     /** 书签引用的数量 */ | ||||
|     @Excel(name = "书签引用的数量") | ||||
|     @Column(name = "icount") | ||||
|     private Integer icount; | ||||
|  | ||||
|     /** 书签排序 */ | ||||
|     @Excel(name = "书签排序") | ||||
|     @Column(name = "iorder") | ||||
|     private Integer iorder; | ||||
|  | ||||
|     public void setId(Long id)  | ||||
|     public void setId(Long id) | ||||
|     { | ||||
|         this.id = id; | ||||
|     } | ||||
|  | ||||
|     public Long getId()  | ||||
|     public Long getId() | ||||
|     { | ||||
|         return id; | ||||
|     } | ||||
|     public void setUserId(Long userId)  | ||||
|     public void setUserId(Long userId) | ||||
|     { | ||||
|         this.userId = userId; | ||||
|     } | ||||
|  | ||||
|     public Long getUserId()  | ||||
|     public Long getUserId() | ||||
|     { | ||||
|         return userId; | ||||
|     } | ||||
|     public void setTagId(Long tagId)  | ||||
|     public void setTagId(Long tagId) | ||||
|     { | ||||
|         this.tagId = tagId; | ||||
|     } | ||||
|  | ||||
|     public Long getTagId()  | ||||
|     public Long getTagId() | ||||
|     { | ||||
|         return tagId; | ||||
|     } | ||||
|     public void setIcount(Integer icount)  | ||||
|     public void setIcount(Integer icount) | ||||
|     { | ||||
|         this.icount = icount; | ||||
|     } | ||||
|  | ||||
|     public Integer getIcount()  | ||||
|     public Integer getIcount() | ||||
|     { | ||||
|         return icount; | ||||
|     } | ||||
|     public void setIorder(Integer iorder)  | ||||
|     public void setIorder(Integer iorder) | ||||
|     { | ||||
|         this.iorder = iorder; | ||||
|     } | ||||
|  | ||||
|     public Integer getIorder()  | ||||
|     public Integer getIorder() | ||||
|     { | ||||
|         return iorder; | ||||
|     } | ||||
| @@ -90,4 +102,14 @@ public class SqUserTag extends BaseEntity | ||||
|             .append("iorder", getIorder()) | ||||
|             .toString(); | ||||
|     } | ||||
|     public SqUserTag(){ | ||||
|  | ||||
|     } | ||||
|     public SqUserTag(Long userId, Long tagId){ | ||||
|         this.userId=userId; | ||||
|         this.tagId = tagId; | ||||
|         this.icount=1; | ||||
|         this.iorder=1; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -3,8 +3,10 @@ package com.ruoyi.bookmark.mapper; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import com.ruoyi.bookmark.domain.SqBookmark; | ||||
| import com.ruoyi.bookmark.domain.SqBookmarkTag; | ||||
| import com.ruoyi.bookmark.domain.SqTag; | ||||
| import com.ruoyi.common.mybatisMapper.MyMapper; | ||||
|  | ||||
| /** | ||||
|  * 书签标签管理Mapper接口 | ||||
| @@ -12,7 +14,7 @@ import com.ruoyi.bookmark.domain.SqTag; | ||||
|  * @author ruoyi | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| public interface SqBookmarkTagMapper | ||||
| public interface SqBookmarkTagMapper extends MyMapper<SqBookmarkTag> | ||||
| { | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -1,7 +1,10 @@ | ||||
| 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; | ||||
|  | ||||
| /** | ||||
|  * 书签_标签Mapper接口 | ||||
| @@ -9,7 +12,7 @@ import com.ruoyi.bookmark.domain.SqTag; | ||||
|  * @author ruoyi | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| public interface SqTagMapper | ||||
| public interface SqTagMapper extends MyMapper<SqTag> | ||||
| { | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,10 @@ package com.ruoyi.bookmark.mapper; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import com.ruoyi.bookmark.domain.SqTag; | ||||
| import com.ruoyi.bookmark.domain.SqUserTag; | ||||
| import com.ruoyi.common.mybatisMapper.MyMapper; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
|  | ||||
| /** | ||||
|  * 标签管理Mapper接口 | ||||
| @@ -11,9 +14,28 @@ import com.ruoyi.bookmark.domain.SqUserTag; | ||||
|  * @author wang | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| public interface SqUserTagMapper | ||||
| public interface SqUserTagMapper  extends MyMapper<SqUserTag> | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * 批量减少用戶 标签引用的 数量 -1 | ||||
|      * | ||||
|      * @param tags 标签串 | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int updateCountReduce(@Param("tags")Long[] tags, @Param("userId")Long userId); | ||||
|  | ||||
|     /** | ||||
|      * 批量添加 用戶 标签引用的 数量 +1 | ||||
|      * | ||||
|      * @param tags 标签串 | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int updateCountAdd(@Param("tags")Long[] tags, @Param("userId")Long userId); | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      *通过用户userID查用户的所有标签 | ||||
|   | ||||
| @@ -1,19 +1,28 @@ | ||||
| package com.ruoyi.bookmark.service; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import com.ruoyi.bookmark.domain.SqBookmarkTag; | ||||
|  | ||||
| /** | ||||
|  * 书签标签管理Service接口 | ||||
|  *  | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| public interface ISqBookmarkTagService  | ||||
| public interface ISqBookmarkTagService | ||||
| { | ||||
|     /** | ||||
|      * 查询该篇文章的 所有书签 | ||||
|      * | ||||
|      * @param | ||||
|      * @return 书签_标签 | ||||
|      */ | ||||
|     public List<Map<String,Object>> selectSqTaListById(Long bookmarkId); | ||||
|     /** | ||||
|      * 查询书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 书签标签管理ID | ||||
|      * @return 书签标签管理 | ||||
|      */ | ||||
| @@ -21,7 +30,7 @@ public interface ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 查询书签标签管理列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param sqBookmarkTag 书签标签管理 | ||||
|      * @return 书签标签管理集合 | ||||
|      */ | ||||
| @@ -29,7 +38,7 @@ public interface ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 新增书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param sqBookmarkTag 书签标签管理 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -37,7 +46,7 @@ public interface ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 修改书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param sqBookmarkTag 书签标签管理 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -45,7 +54,7 @@ public interface ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 批量删除书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param ids 需要删除的书签标签管理ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -53,7 +62,7 @@ public interface ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 删除书签标签管理信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 书签标签管理ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|   | ||||
| @@ -15,6 +15,27 @@ public interface ISqUserTagService | ||||
| { | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 批量减少用戶 标签引用的 数量 -1 | ||||
|      * | ||||
|      * @param tags 标签串 | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int updateCountReduce(Long[] tags,Long userId); | ||||
|  | ||||
|     /** | ||||
|      * 批量添加 用戶 标签引用的 数量 +1 | ||||
|      * | ||||
|      * @param tags 标签串 | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public int updateCountAdd(Long[] tags,Long userId); | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      *通过用户userID查用户的所有标签 | ||||
|      * | ||||
|   | ||||
| @@ -1,14 +1,32 @@ | ||||
| package com.ruoyi.bookmark.service.impl; | ||||
|  | ||||
| import java.text.ParseException; | ||||
| import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import com.ruoyi.bookmark.domain.SqBookmarkTag; | ||||
| import com.ruoyi.bookmark.domain.SqTag; | ||||
| import com.ruoyi.bookmark.domain.SqUserTag; | ||||
| import com.ruoyi.bookmark.mapper.SqBookmarkTagMapper; | ||||
| import com.ruoyi.bookmark.mapper.SqTagMapper; | ||||
| import com.ruoyi.bookmark.mapper.SqUserTagMapper; | ||||
| import com.ruoyi.common.core.domain.entity.SysUser; | ||||
| import com.ruoyi.common.utils.DateUtils; | ||||
| import com.sun.org.apache.bcel.internal.generic.NEW; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| import com.ruoyi.bookmark.mapper.SqBookmarkMapper; | ||||
| import com.ruoyi.bookmark.domain.SqBookmark; | ||||
| import com.ruoyi.bookmark.service.ISqBookmarkService; | ||||
| import sun.dc.pr.PRError; | ||||
|  | ||||
| import javax.print.DocFlavor; | ||||
|  | ||||
| /** | ||||
|  * 书签管理Service业务层处理 | ||||
| @@ -19,9 +37,19 @@ import com.ruoyi.bookmark.service.ISqBookmarkService; | ||||
| @Service | ||||
| public class SqBookmarkServiceImpl implements ISqBookmarkService | ||||
| { | ||||
|     public static Logger logger =  LoggerFactory.getLogger(SqBookmarkServiceImpl.class); | ||||
|     @Autowired | ||||
|     private SqBookmarkMapper sqBookmarkMapper; | ||||
|  | ||||
|     @Autowired | ||||
|     private SqBookmarkTagMapper sqBookmarkTagMapper; | ||||
|  | ||||
|     @Autowired | ||||
|     private SqTagMapper sqTagMapper; | ||||
|  | ||||
|     @Autowired | ||||
|     private SqUserTagMapper sqUserTagMapper; | ||||
|  | ||||
|     @Override | ||||
|     public List<SqBookmark> selectByID(Long userID) { | ||||
|  | ||||
| @@ -86,6 +114,114 @@ public class SqBookmarkServiceImpl implements ISqBookmarkService | ||||
|     @Override | ||||
|     public int updateSqBookmark(SqBookmark sqBookmark) | ||||
|     { | ||||
|         //删除书签 现在的标签 | ||||
|         SqBookmarkTag sqBookmarkTag=new SqBookmarkTag(); | ||||
|         sqBookmarkTag.setBookmarkId(sqBookmark.getBookmarkId()); | ||||
|         sqBookmarkTagMapper.delete(sqBookmarkTag); | ||||
|         //删除的书签ID | ||||
|         String deletetag=""; | ||||
|         //新增的书签ID | ||||
|         String addtag=""; | ||||
|         //传入的标签 | ||||
|         List<Map<String,Object>> listmap=sqBookmark.getSqTags(); | ||||
|         //给文章添加标签 | ||||
|         Long[] tags= new Long[listmap.size()]; | ||||
|  | ||||
|         //文章添加书签 | ||||
|         SqBookmarkTag bookamrktag=new SqBookmarkTag(); | ||||
|         int i=0; | ||||
|         for (Map<String,Object> map:listmap) { | ||||
|             for (Map.Entry<String, Object> entry : map.entrySet()){ | ||||
|  | ||||
|                 if(Integer.parseInt(String.valueOf(map.get("tagId")))<0){ | ||||
|                    //创建新的标签 返回id给map    并且添加用户的个人书签记录 | ||||
|                     //1.新增标签 | ||||
|                         //1.1查询书签是否存在 | ||||
|                         SqTag sqTag=new SqTag(); | ||||
|                         SqUserTag sqUserTag =new SqUserTag(); | ||||
|                         sqTag.setName(String.valueOf(map.get("name"))); | ||||
|                         List<SqTag> taglist=sqTagMapper.selectSqTagList(sqTag); | ||||
|                         //存在返回ID | ||||
|                         if (taglist!=null&&!taglist.isEmpty()){ | ||||
|                             map.put("tagId",taglist.get(0).getId()); | ||||
|                             logger.debug("传入的新标签 tagid="+taglist.get(0).getId()); | ||||
|                             //添加到用戶个人书签里面去 | ||||
|                             //1.用户是否已经有这个书签记录了 | ||||
|                             sqUserTag.setUserId(sqBookmark.getUserid()); | ||||
|                             sqUserTag.setTagId(taglist.get(0).getId()); | ||||
|  | ||||
|                           List<SqUserTag> sqUserTags = sqUserTagMapper.selectSqUserTagList(sqUserTag); | ||||
|  | ||||
|                           if (sqUserTags!=null&&!sqUserTags.isEmpty()){ | ||||
|                               addtag +=sqUserTags.get(0).getTagId().toString()+","; | ||||
|                           }else { | ||||
|                               sqUserTag.setIcount(1); | ||||
|                               sqUserTag.setIorder(1); | ||||
|                               sqUserTagMapper.insertSqUserTag(sqUserTag); | ||||
|                           } | ||||
|  | ||||
|                         }else { | ||||
|                             //不存在 >>创建 返回ID | ||||
|                             sqTag.setUserId(sqBookmark.getUserid()); | ||||
|                             sqTag.setTagType("P"); | ||||
|                             sqTag.setIcount(1); | ||||
|                             sqTag.setStatus(0); | ||||
|                             try { | ||||
|                                 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 | ||||
|                                 Date dateStart = df.parse(df.format(new Date())); | ||||
|                                 sqTag.setCreateTime(dateStart); | ||||
|                             } catch (ParseException e) { | ||||
|                                 e.printStackTrace(); | ||||
|                             } | ||||
|  | ||||
|                             int tagid=sqTagMapper.insertUseGeneratedKeys(sqTag); | ||||
|                             logger.debug("传入的新标签 tagid="+sqTag.getId()); | ||||
|                             map.put("tagId",sqTag.getId()); | ||||
|                             //添加到用戶个人书签里面去 | ||||
|                             sqUserTag.setUserId(sqBookmark.getUserid()); | ||||
|                             sqUserTag.setTagId(Long.valueOf(sqTag.getId())); | ||||
|                             sqUserTag.setIcount(1); | ||||
|                             sqUserTag.setIorder(1); | ||||
|                             sqUserTagMapper.insertSqUserTag(sqUserTag); | ||||
|                         } | ||||
|  | ||||
|                 } | ||||
|                 if (!String.valueOf(map.get("name")).equals("TAGDELETE")){ | ||||
|                     //给文章添加书签 | ||||
|                     bookamrktag.setBookmarkId(sqBookmark.getBookmarkId()); | ||||
|                     bookamrktag.setTagId(Long.valueOf(map.get("tagId").toString())); | ||||
|                     sqBookmarkTagMapper.insertSqBookmarkTag(bookamrktag); | ||||
|                 }else{ | ||||
|                     deletetag += map.get("tagId").toString()+","; | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         //个人标签引用数量 批量-1 | ||||
|        String[] tagreduce=deletetag.split(","); | ||||
|  | ||||
|         if (tagreduce!=null&&tagreduce.length>0){ | ||||
|         Long[] num = new Long[tagreduce.length]; | ||||
|         for (int idx = 0; idx < tagreduce.length; idx++) { | ||||
|             if(!tagreduce[idx].equals("")&&tagreduce[idx]!=null){ | ||||
|             num[idx] = Long.parseLong(tagreduce[idx]); | ||||
|             } | ||||
|         } | ||||
|         sqUserTagMapper.updateCountReduce(num,sqBookmark.getUserid()); | ||||
|         } | ||||
|  | ||||
|         //个人标签引用数量 批量+1 | ||||
|         String[] tagadd=addtag.split(","); | ||||
|         if (tagadd!=null&&tagadd.length>0) { | ||||
|             Long[] add = new Long[tagadd.length]; | ||||
|             for (int idx = 0; idx < tagadd.length; idx++) { | ||||
|                 if(!tagadd[idx].equals("")&&tagadd[idx]!=null) { | ||||
|                     add[idx] = Long.parseLong(tagadd[idx]); | ||||
|                 } | ||||
|             } | ||||
|             sqUserTagMapper.updateCountAdd(add, sqBookmark.getUserid()); | ||||
|         } | ||||
|         return sqBookmarkMapper.updateSqBookmark(sqBookmark); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| package com.ruoyi.bookmark.service.impl; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| import com.ruoyi.bookmark.mapper.SqBookmarkTagMapper; | ||||
| @@ -9,19 +11,32 @@ import com.ruoyi.bookmark.service.ISqBookmarkTagService; | ||||
|  | ||||
| /** | ||||
|  * 书签标签管理Service业务层处理 | ||||
|  *  | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  * @date 2020-09-04 | ||||
|  */ | ||||
| @Service | ||||
| public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService  | ||||
| public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService | ||||
| { | ||||
|  | ||||
|  | ||||
|  | ||||
|     @Autowired | ||||
|     private SqBookmarkTagMapper sqBookmarkTagMapper; | ||||
|  | ||||
|     /** | ||||
|      * 查询该篇文章的 所有书签 | ||||
|      * | ||||
|      * @param | ||||
|      * @return 书签_标签 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<Map<String,Object>> selectSqTaListById(Long bookmarkId){ | ||||
|         return sqBookmarkTagMapper.selectSqTaListById(bookmarkId); | ||||
|     } | ||||
|     /** | ||||
|      * 查询书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 书签标签管理ID | ||||
|      * @return 书签标签管理 | ||||
|      */ | ||||
| @@ -33,7 +48,7 @@ public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 查询书签标签管理列表 | ||||
|      *  | ||||
|      * | ||||
|      * @param sqBookmarkTag 书签标签管理 | ||||
|      * @return 书签标签管理 | ||||
|      */ | ||||
| @@ -45,7 +60,7 @@ public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 新增书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param sqBookmarkTag 书签标签管理 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -57,7 +72,7 @@ public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 修改书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param sqBookmarkTag 书签标签管理 | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -69,7 +84,7 @@ public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 批量删除书签标签管理 | ||||
|      *  | ||||
|      * | ||||
|      * @param ids 需要删除的书签标签管理ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
| @@ -81,7 +96,7 @@ public class SqBookmarkTagServiceImpl implements ISqBookmarkTagService | ||||
|  | ||||
|     /** | ||||
|      * 删除书签标签管理信息 | ||||
|      *  | ||||
|      * | ||||
|      * @param id 书签标签管理ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|   | ||||
| @@ -22,6 +22,35 @@ public class SqUserTagServiceImpl implements ISqUserTagService | ||||
|     private SqUserTagMapper sqUserTagMapper; | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 批量减少用戶 标签引用的 数量 -1 | ||||
|      * | ||||
|      * @param tags 标签串 | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @Override | ||||
|     public int updateCountReduce(Long[] tags,Long userId){ | ||||
|         return sqUserTagMapper.updateCountReduce(tags,userId); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 批量添加 用戶 标签引用的 数量 +1 | ||||
|      * | ||||
|      * @param tags 标签串 | ||||
|      * @param userId 用户ID | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     @Override | ||||
|     public int updateCountAdd(Long[] tags,Long userId){ | ||||
|         return sqUserTagMapper.updateCountAdd(tags,userId); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      *通过用户userID查用户的所有标签 | ||||
|      * | ||||
|   | ||||
| @@ -61,4 +61,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|         </foreach> | ||||
|     </delete> | ||||
|  | ||||
|  | ||||
| </mapper> | ||||
|   | ||||
| @@ -22,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     <select id="selectSqTagList" parameterType="SqTag" resultMap="SqTagResult"> | ||||
|         <include refid="selectSqTagVo"/> | ||||
|         <where> | ||||
|             <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if> | ||||
|             <if test="name != null  and name != ''"> and name =  #{name}</if> | ||||
|             <if test="icount != null "> and icount = #{icount}</if> | ||||
|             <if test="userId != null "> and user_Id = #{userId}</if> | ||||
|             <if test="tagType != null  and tagType != ''"> and tag_type = #{tagType}</if> | ||||
| @@ -45,7 +45,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|             <if test="tagType != null">tag_type,</if> | ||||
|             <if test="url != null">url,</if> | ||||
|             <if test="status != null">status,</if> | ||||
|             <if test="createTime != null">create_time,</if> | ||||
|             create_time | ||||
|          </trim> | ||||
|         <trim prefix="values (" suffix=")" suffixOverrides=","> | ||||
|             <if test="name != null">#{name},</if> | ||||
| @@ -54,7 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|             <if test="tagType != null">#{tagType},</if> | ||||
|             <if test="url != null">#{url},</if> | ||||
|             <if test="status != null">#{status},</if> | ||||
|             <if test="createTime != null">#{createTime},</if> | ||||
|             now() | ||||
|          </trim> | ||||
|     </insert> | ||||
|  | ||||
|   | ||||
| @@ -81,7 +81,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||||
|     ORDER BY u.iorder | ||||
|     </select> | ||||
|  | ||||
|     <update id="updateCountReduce" > | ||||
|         <foreach item="tagId" collection="tags" separator=";" > | ||||
|             update sq_user_tag set icount=icount-1 WHERE user_id=#{userId} and tag_id = #{tagId} | ||||
|         </foreach> | ||||
|     </update> | ||||
|  | ||||
|  | ||||
|     <update id="updateCountAdd" > | ||||
|         <foreach item="tagId" collection="tags" separator=";" > | ||||
|             update sq_user_tag set icount=icount+1 WHERE user_id=#{userId} and tag_id = #{tagId} | ||||
|         </foreach> | ||||
|     </update> | ||||
|  | ||||
|  | ||||
| </mapper> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user