Commit 623b7285 by 阮思源

优化用户搜索

parent da2b727e
...@@ -363,7 +363,7 @@ public class SearchBizImpl implements SearchBiz { ...@@ -363,7 +363,7 @@ public class SearchBizImpl implements SearchBiz {
if (StringUtil.isEmpty(wxId)){ if (StringUtil.isEmpty(wxId)){
throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!"); throw new BookBizException(BookBizException.PARAM_IS_ERROR,"参数有误!");
} }
searchRecordDao.deleteByWxId(wxId); searchRecordDao.updateUserDeleteByWxId(wxId,true);
} }
@ParamLog("填充出版社和用户信息") @ParamLog("填充出版社和用户信息")
......
...@@ -9,4 +9,6 @@ public interface SearchRecordDao extends BaseDao<SearchRecord> { ...@@ -9,4 +9,6 @@ public interface SearchRecordDao extends BaseDao<SearchRecord> {
void deleteByWxId(String wxId); void deleteByWxId(String wxId);
List<String> getRecent5WxIds(Long bookId); List<String> getRecent5WxIds(Long bookId);
void updateUserDeleteByWxId(String wxId, Boolean userDelete);
} }
...@@ -5,7 +5,9 @@ import com.pcloud.book.book.entity.SearchRecord; ...@@ -5,7 +5,9 @@ import com.pcloud.book.book.entity.SearchRecord;
import com.pcloud.common.core.dao.BaseDaoImpl; import com.pcloud.common.core.dao.BaseDaoImpl;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Component("searchRecordDao") @Component("searchRecordDao")
public class SearchRecordDaoImpl extends BaseDaoImpl<SearchRecord> implements SearchRecordDao { public class SearchRecordDaoImpl extends BaseDaoImpl<SearchRecord> implements SearchRecordDao {
...@@ -19,4 +21,12 @@ public class SearchRecordDaoImpl extends BaseDaoImpl<SearchRecord> implements Se ...@@ -19,4 +21,12 @@ public class SearchRecordDaoImpl extends BaseDaoImpl<SearchRecord> implements Se
public List<String> getRecent5WxIds(Long bookId) { public List<String> getRecent5WxIds(Long bookId) {
return super.getSqlSession().selectList(super.getStatement("getRecent5WxIds"),bookId); return super.getSqlSession().selectList(super.getStatement("getRecent5WxIds"),bookId);
} }
@Override
public void updateUserDeleteByWxId(String wxId, Boolean userDelete) {
Map<String,Object> map=new HashMap<>();
map.put("wxId",wxId);
map.put("userDelete",userDelete);
super.getSqlSession().update(super.getStatement("updateUserDeleteByWxId"),map);
}
} }
...@@ -39,4 +39,7 @@ public class SearchRecord extends BaseEntity { ...@@ -39,4 +39,7 @@ public class SearchRecord extends BaseEntity {
@ApiModelProperty("热门关键词id") @ApiModelProperty("热门关键词id")
private Long hotBookId; private Long hotBookId;
@ApiModelProperty("用户是否删除")
private Boolean userDelete;
} }
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
<result column="agent_id" property="agentId" jdbcType="BIGINT" /> <result column="agent_id" property="agentId" jdbcType="BIGINT" />
<result column="wx_id" property="wxId" jdbcType="VARCHAR" /> <result column="wx_id" property="wxId" jdbcType="VARCHAR" />
<result column="hot_book_id" property="hotBookId" jdbcType="BIGINT" /> <result column="hot_book_id" property="hotBookId" jdbcType="BIGINT" />
<result column="user_delete" property="userDelete" jdbcType="BOOLEAN" />
<result column="create_time" property="createTime" jdbcType="INTEGER" /> <result column="create_time" property="createTime" jdbcType="INTEGER" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id,content,book_id,agent_id,wx_id,hot_book_id,create_time id,content,book_id,agent_id,wx_id,hot_book_id,user_delete,create_time
</sql> </sql>
<insert id="insert" parameterType="com.pcloud.book.book.entity.SearchRecord" useGeneratedKeys="true" <insert id="insert" parameterType="com.pcloud.book.book.entity.SearchRecord" useGeneratedKeys="true"
...@@ -68,6 +69,7 @@ ...@@ -68,6 +69,7 @@
select <include refid="Base_Column_List"/> select <include refid="Base_Column_List"/>
from search_record from search_record
where wx_id=#{wxId} where wx_id=#{wxId}
and user_delete=0
group by content group by content
order by create_time desc order by create_time desc
</select> </select>
...@@ -84,4 +86,10 @@ ...@@ -84,4 +86,10 @@
limit 5 limit 5
</select> </select>
<update id="updateUserDeleteByWxId" parameterType="map" >
update search_record
set user_delete=#{userDelete}
where wx_id=#{wxId}
</update>
</mapper> </mapper>
\ No newline at end of file
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