提交 eae44a16 authored 作者: 吴德鹏's avatar 吴德鹏

首页统计

上级 cd97652d
package com.platform.controller;
import com.platform.entity.TbCfSearchEntity;
import com.platform.service.TbCfSearchService;
import com.platform.utils.PageUtils;
import com.platform.utils.Query;
import com.platform.utils.R;
import com.platform.vo.SearchKeywords;
import com.platform.vo.TopSearch;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* Controller
*
* @author lipengjun
* @date 2020-07-22 10:54:07
*/
@Controller
@RequestMapping("tbcfsearch")
public class TbCfSearchController {
@Autowired
private TbCfSearchService tbCfSearchService;
/**
* 查看列表
*/
@RequestMapping("/list")
@RequiresPermissions("tbcfsearch:list")
@ResponseBody
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<TbCfSearchEntity> tbCfSearchList = tbCfSearchService.queryList(query);
int total = tbCfSearchService.queryTotal(query);
PageUtils pageUtil = new PageUtils(tbCfSearchList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 查看信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("tbcfsearch:info")
@ResponseBody
public R info(@PathVariable("id") String id) {
TbCfSearchEntity tbCfSearch = tbCfSearchService.queryObject(id);
return R.ok().put("tbCfSearch", tbCfSearch);
}
/**
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("tbcfsearch:save")
@ResponseBody
public R save(@RequestBody TbCfSearchEntity tbCfSearch) {
tbCfSearchService.save(tbCfSearch);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("tbcfsearch:update")
@ResponseBody
public R update(@RequestBody TbCfSearchEntity tbCfSearch) {
tbCfSearchService.update(tbCfSearch);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("tbcfsearch:delete")
@ResponseBody
public R delete(@RequestBody String[] ids) {
tbCfSearchService.deleteBatch(ids);
return R.ok();
}
/**
* 查看所有列表
*/
@RequestMapping("/queryAll")
@ResponseBody
public R queryAll(@RequestParam Map<String, Object> params) {
List<TbCfSearchEntity> list = tbCfSearchService.queryList(params);
return R.ok().put("list", list);
}
/**
* 搜索关键字统计
*/
@RequestMapping("/getSearchKeywords")
@ResponseBody
public R getSearchKeywords() {
List<SearchKeywords> searchList = tbCfSearchService.getSearchKeywords();
return R.ok().put("list", searchList);
}
/**
* 热门搜索
*
* @return
*/
@RequestMapping("/getTopSearch")
@ResponseBody
public R getTopSearch() {
TopSearch topSearch = tbCfSearchService.getTopSearch();
return R.ok().put("topSearch", topSearch);
}
}
package com.platform.dao;
import com.platform.entity.TbCfSearchEntity;
import com.platform.vo.SearchKeywords;
import com.platform.vo.TopSearch;
import java.util.List;
/**
* Dao
*
* @author lipengjun
* @date 2020-07-22 10:54:07
*/
public interface TbCfSearchDao extends BaseDao<TbCfSearchEntity> {
List<SearchKeywords> getSearchKeywords();
TopSearch getTopSearch();
}
package com.platform.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 实体
* 表名 tb_cf_search
*
* @author lipengjun
* @date 2020-07-22 10:54:07
*/
public class TbCfSearchEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 搜索ID
*/
private String id;
/**
* 搜索关键字
*/
private String searchKeywords;
/**
* 用户ID
*/
private String userId;
/**
* 设置:搜索ID
*/
public void setId(String id) {
this.id = id;
}
/**
* 获取:搜索ID
*/
public String getId() {
return id;
}
/**
* 设置:搜索关键字
*/
public void setSearchKeywords(String searchKeywords) {
this.searchKeywords = searchKeywords;
}
/**
* 获取:搜索关键字
*/
public String getSearchKeywords() {
return searchKeywords;
}
/**
* 设置:用户ID
*/
public void setUserId(String userId) {
this.userId = userId;
}
/**
* 获取:用户ID
*/
public String getUserId() {
return userId;
}
}
package com.platform.service;
import com.platform.entity.TbCfSearchEntity;
import com.platform.vo.SearchKeywords;
import com.platform.vo.TopSearch;
import java.util.List;
import java.util.Map;
/**
* Service接口
*
* @author lipengjun
* @date 2020-07-22 10:54:07
*/
public interface TbCfSearchService {
/**
* 根据主键查询实体
*
* @param id 主键
* @return 实体
*/
TbCfSearchEntity queryObject(String id);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfSearchEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfSearch 实体
* @return 保存条数
*/
int save(TbCfSearchEntity tbCfSearch);
/**
* 根据主键更新实体
*
* @param tbCfSearch 实体
* @return 更新条数
*/
int update(TbCfSearchEntity tbCfSearch);
/**
* 根据主键删除
*
* @param id
* @return 删除条数
*/
int delete(String id);
/**
* 根据主键批量删除
*
* @param ids
* @return 删除条数
*/
int deleteBatch(String[] ids);
List<SearchKeywords> getSearchKeywords();
TopSearch getTopSearch();
}
package com.platform.service.impl;
import com.platform.dao.TbCfSearchDao;
import com.platform.entity.TbCfSearchEntity;
import com.platform.service.TbCfSearchService;
import com.platform.utils.IdUtil;
import com.platform.vo.SearchKeywords;
import com.platform.vo.TopSearch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* Service实现类
*
* @author lipengjun
* @date 2020-07-22 10:54:07
*/
@Service("tbCfSearchService")
public class TbCfSearchServiceImpl implements TbCfSearchService {
@Autowired
private TbCfSearchDao tbCfSearchDao;
@Override
public TbCfSearchEntity queryObject(String id) {
return tbCfSearchDao.queryObject(id);
}
@Override
public List<TbCfSearchEntity> queryList(Map<String, Object> map) {
return tbCfSearchDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfSearchDao.queryTotal(map);
}
@Override
public int save(TbCfSearchEntity tbCfSearch) {
tbCfSearch.setId(IdUtil.createIdbyUUID());
return tbCfSearchDao.save(tbCfSearch);
}
@Override
public int update(TbCfSearchEntity tbCfSearch) {
return tbCfSearchDao.update(tbCfSearch);
}
@Override
public int delete(String id) {
return tbCfSearchDao.delete(id);
}
@Override
public int deleteBatch(String[] ids) {
return tbCfSearchDao.deleteBatch(ids);
}
@Override
public List<SearchKeywords> getSearchKeywords() {
return tbCfSearchDao.getSearchKeywords();
}
@Override
public TopSearch getTopSearch() {
return tbCfSearchDao.getTopSearch();
}
}
package com.platform.vo;
/**
* @Auther: wudepeng
* @Date: 2020/07/22
* @Description:搜索关键字
*/
public class SearchKeywords {
//搜索关键字
private String searchKeywords;
//搜索次数
private Long count;
public String getSearchKeywords() {
return searchKeywords;
}
public void setSearchKeywords(String searchKeywords) {
this.searchKeywords = searchKeywords;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
}
package com.platform.vo;
/**
* @Auther: wudepeng
* @Date: 2020/07/23
* @Description:热门搜索
*/
public class TopSearch {
private Long total;
private Long average;
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public Long getAverage() {
return average;
}
public void setAverage(Long average) {
this.average = average;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.TbCfSearchDao">
<resultMap type="com.platform.entity.TbCfSearchEntity" id="tbCfSearchMap">
<result property="id" column="id"/>
<result property="searchKeywords" column="search_keywords"/>
<result property="userId" column="user_id"/>
</resultMap>
<select id="queryObject" resultType="com.platform.entity.TbCfSearchEntity">
select
`id`,
`search_keywords`,
`user_id`
from tb_cf_search
where id = #{id}
</select>
<select id="getSearchKeywords" resultType="com.platform.vo.SearchKeywords">
SELECT
search_keywords,
count( DISTINCT user_id ) count
FROM
tb_cf_search
GROUP BY
search_keywords
ORDER BY
count DESC
</select>
<select id="queryList" resultType="com.platform.entity.TbCfSearchEntity">
select
`id`,
`search_keywords`,
`user_id`
from tb_cf_search
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="getTopSearch" resultType="com.platform.vo.TopSearch">
SELECT
count( DISTINCT user_id ) total,
count( 1 ) / count( DISTINCT user_id ) average
FROM
tb_cf_search
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_search
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.platform.entity.TbCfSearchEntity">
insert into tb_cf_search(
`id`,
`search_keywords`,
`user_id`)
values(
#{id},
#{searchKeywords},
#{userId})
</insert>
<update id="update" parameterType="com.platform.entity.TbCfSearchEntity">
update tb_cf_search
<set>
<if test="searchKeywords != null">`search_keywords` = #{searchKeywords}, </if>
<if test="userId != null">`user_id` = #{userId}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete from tb_cf_search where id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_search where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
...@@ -624,14 +624,14 @@ ...@@ -624,14 +624,14 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for='el in 8'> <tr v-for='(s,i) in searchList'>
<td>1</td> <td>{{i+1}}</td>
<td class="active-color">新款连衣裙</td> <td class="active-color">{{s.searchKeywords}}</td>
<td>2233</td> <td>{{s.count}}</td>
<td> <td>
<span>128%</span> <span>128%</span>
<!-- 升 --> <!-- 升 -->
<svg v-if='el%2===0' xmlns="http://www.w3.org/2000/svg" <svg v-if='s%2===0' xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="8" height="9" xmlns:xlink="http://www.w3.org/1999/xlink" width="8" height="9"
viewBox="0 0 30 33"> viewBox="0 0 30 33">
<metadata><?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <metadata><?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
......
...@@ -10,6 +10,7 @@ let app = new Vue({ ...@@ -10,6 +10,7 @@ let app = new Vue({
newNum: 0, newNum: 0,
PVNumber: 0, PVNumber: 0,
FrequencyOfPaymentNumber: 0, FrequencyOfPaymentNumber: 0,
searchList: [],
datePicker: { datePicker: {
shortcuts: [ shortcuts: [
{ {
...@@ -748,6 +749,13 @@ let app = new Vue({ ...@@ -748,6 +749,13 @@ let app = new Vue({
}) })
}) })
}, },
getSearchKeywords() {
$.get('../tbcfsearch/getSearchKeywords', res => {
let list = JSON.parse(res).list;
console.log('123455', list)
this.searchList = list;
})
},
Percentage(num, total) { Percentage(num, total) {
if (num == 0 || total == 0) { if (num == 0 || total == 0) {
return 0; return 0;
...@@ -770,6 +778,7 @@ let app = new Vue({ ...@@ -770,6 +778,7 @@ let app = new Vue({
this.getCategory(); this.getCategory();
}, },
mounted() { mounted() {
this.getSearchKeywords();
this.initEchartsPV(); this.initEchartsPV();
this.initEchartsPayTheAmount(); this.initEchartsPayTheAmount();
this.initEchartsMiddle(); this.initEchartsMiddle();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论