热词统计,热词功能改版

This commit is contained in:
Chopper 2022-04-19 09:28:26 +08:00
parent 6ae9692358
commit 947a82eac5
22 changed files with 653 additions and 109 deletions

View File

@ -1,4 +1,16 @@
/** 增加签到日期 **/
ALTER TABLE li_member_sign ADD day int DEFAULT NULL COMMENT '签到日 ';
ALTER TABLE li_member_sign DROP INDEX uk_member_day;
ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day';
ALTER TABLE li_member_sign add unique uk_member_day (member_id, day) COMMENT 'uk_member_day';
/** 添加历史热词表 **/
CREATE TABLE `li_hot_words_history` (
`id` bigint NOT NULL COMMENT 'ID',
`create_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '创建者',
`create_time` datetime(6) DEFAULT NULL COMMENT '创建时间',
`delete_flag` bit(1) DEFAULT NULL COMMENT '是否删除',
`update_by` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL COMMENT '修改者',
`update_time` datetime(6) DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

View File

@ -14,6 +14,7 @@ import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
import cn.lili.modules.search.service.EsGoodsSearchService;
import cn.lili.modules.search.service.HotWordsService;
import cn.lili.modules.statistics.aop.PageViewPoint;
import cn.lili.modules.statistics.aop.enums.PageViewEnum;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -62,6 +63,9 @@ public class GoodsBuyerController {
@Autowired
private EsGoodsSearchService goodsSearchService;
@Autowired
private HotWordsService hotWordsService;
@ApiOperation(value = "通过id获取商品信息")
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, paramType = "path", dataType = "Long")
@GetMapping(value = "/get/{goodsId}")
@ -117,7 +121,7 @@ public class GoodsBuyerController {
@ApiOperation(value = "获取搜索热词")
@GetMapping("/hot-words")
public ResultMessage<List<String>> getGoodsHotWords(Integer count) {
List<String> hotWords = goodsSearchService.getHotWords(count);
List<String> hotWords = hotWordsService.getHotWords(count);
return ResultUtil.data(hotWords);
}

View File

@ -1,11 +1,24 @@
package cn.lili.timetask.handler.impl.hotwords;
import cn.hutool.json.JSONUtil;
import cn.lili.cache.Cache;
import cn.lili.cache.CachePrefix;
import cn.lili.common.utils.StringUtils;
import cn.lili.modules.search.entity.dos.HotWordsHistory;
import cn.lili.modules.search.service.HotWordsHistoryService;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.HotWordsSetting;
import cn.lili.modules.system.entity.dto.HotWordsSettingItem;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import cn.lili.timetask.handler.EveryDayExecute;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.DefaultTypedTuple;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* @author paulG
@ -18,13 +31,54 @@ public class HotWordsEveryDayTaskExecute implements EveryDayExecute {
@Autowired
private Cache cache;
@Autowired
private HotWordsHistoryService hotWordsHistoryService;
@Autowired
private SettingService settingService;
/**
* 执行每日任务
*/
@Override
public void execute() {
//获取大于0分的热词
Set<DefaultTypedTuple> tuples = cache.zRangeByScore(CachePrefix.HOT_WORD.getPrefix(), 1, Integer.MAX_VALUE);
//如果任务不为空
if (!CollectionUtils.isEmpty(tuples)) {
//因为是第二天统计第一天的数据所以这里获取昨天凌晨的时间
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 1);
//批量保存热词
List<HotWordsHistory> hotWordsHistories = new ArrayList<>();
for (DefaultTypedTuple tuple : tuples) {
String keywords = (String) tuple.getValue();
Double score = tuple.getScore();
hotWordsHistories.add(new HotWordsHistory(calendar.getTime(), keywords, score.intValue()));
}
hotWordsHistoryService.saveBatch(hotWordsHistories);
}
//移除昨日的热搜词
cache.remove(CachePrefix.HOT_WORD.getPrefix());
//设置今日默认热词
Setting setting = settingService.get(SettingEnum.HOT_WORDS.name());
if (setting == null) {
return;
}
HotWordsSetting hotWordsSetting = JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class);
List<HotWordsSettingItem> hotWordsSettingItems = hotWordsSetting.getHotWordsSettingItems();
if (hotWordsSettingItems != null && !hotWordsSettingItems.isEmpty()) {
for (HotWordsSettingItem hotWordsSettingItem : hotWordsSettingItems) {
cache.zAdd(CachePrefix.HOT_WORD.getPrefix(), hotWordsSettingItem.getScore(), hotWordsSettingItem.getKeywords());
}
}
}
}

View File

@ -28,6 +28,14 @@ public class DateUtil {
public static Long getDayOfStart() {
return DateUtil.getDateline()/(60*24*60);
}
/**
* 当天的开始时间
*
* @return 今天开始时间
*/
public static Long getDayOfStart(Date date) {
return date.getTime()/(60*24*60);
}
/**
* 当天的开始时间

View File

@ -149,13 +149,13 @@ public class StoreFlowServiceImpl extends ServiceImpl<StoreFlowMapper, StoreFlow
.eq(StoreFlow::getFlowType, FlowTypeEnum.PAY));
storeFlow.setNum(afterSale.getNum());
storeFlow.setCategoryId(payStoreFlow.getCategoryId());
//佣金
//佣金 = 佣金/订单商品数量* 售后商品数量
storeFlow.setCommissionPrice(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getCommissionPrice(), payStoreFlow.getNum()), afterSale.getNum()));
//分销佣金
//分销佣金 =分校佣金/订单商品数量* 售后商品数量
storeFlow.setDistributionRebate(CurrencyUtil.mul(CurrencyUtil.div(payStoreFlow.getDistributionRebate(), payStoreFlow.getNum()), afterSale.getNum()));
//流水金额
//流水金额 = 实际退款金额
storeFlow.setFinalPrice(afterSale.getActualRefundPrice());
//最终结算金额
//最终结算金额 =
storeFlow.setBillPrice(CurrencyUtil.add(storeFlow.getFinalPrice(), storeFlow.getDistributionRebate(), storeFlow.getCommissionPrice()));
//获取第三方支付流水号
RefundLog refundLog = refundLogService.queryByAfterSaleSn(afterSale.getSn());

View File

@ -0,0 +1,47 @@
package cn.lili.modules.search.entity.dos;
import cn.lili.mybatis.BaseEntity;
import cn.lili.mybatis.BaseIdEntity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* HotWordsHistory
*
* @author Chopper
* @version v1.0
* 2022-04-14 09:39
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("li_hot_words_history")
public class HotWordsHistory extends BaseIdEntity {
/**
*
*/
private String keywords;
/**
* 分数
*/
private Integer score;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date createTime;
}

View File

@ -0,0 +1,80 @@
package cn.lili.modules.search.entity.dto;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.statistics.entity.dto.StatisticsQueryParam;
import cn.lili.modules.statistics.util.StatisticsDateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
/**
* 商品查询条件
*
* @author pikachu
* @since 2020-02-24 19:27:20
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class HotWordsSearchParams extends PageVO {
private static final long serialVersionUID = 2544015852728566887L;
@NotNull(message = "搜索热词不能为空")
@ApiModelProperty(value = "热词")
private String keywords;
@ApiModelProperty(value = "快捷搜索", allowableValues = "TODAY, YESTERDAY, LAST_SEVEN, LAST_THIRTY")
private String searchType;
@ApiModelProperty(value = "类型YEAR、月MONTH")
private String timeType;
@ApiModelProperty(value = "年份")
private Integer year;
@ApiModelProperty(value = "月份")
private Integer month;
//临时参数 不作为前端传递
private Date startTIme;
private Date endTime;
public <T> QueryWrapper<T> queryWrapper() {
//组织查询时间
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
StatisticsQueryParam statisticsQueryParam = new StatisticsQueryParam();
BeanUtils.copyProperties(this, statisticsQueryParam);
Date[] dates = StatisticsDateUtil.getDateArray(statisticsQueryParam);
//获取当前时间
Calendar calendar = Calendar.getInstance();
calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (StringUtils.isNotEmpty(keywords)) {
queryWrapper.like("keywords", keywords);
}
queryWrapper.between("create_time", dates[0], dates[1]);
startTIme = dates[0];
endTime = dates[1];
return queryWrapper;
}
}

View File

@ -0,0 +1,33 @@
package cn.lili.modules.search.entity.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Date;
/**
* 在线会员
*
* @author Chopper
* @since 2021-02-21 09:59
*/
@Data
public class HotWordsHistoryVO {
/**
* 时间
*/
private Date createTime;
/**
*
*/
private String keywords;
/**
* 分数
*/
private Integer score;
}

View File

@ -0,0 +1,32 @@
package cn.lili.modules.search.mapper;
import cn.lili.modules.search.entity.dos.CustomWords;
import cn.lili.modules.search.entity.dos.HotWordsHistory;
import cn.lili.modules.search.entity.vo.HotWordsHistoryVO;
import cn.lili.modules.statistics.entity.vo.OrderStatisticsDataVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 搜索热词历史记录数据处理层
*
* @author paulG
* @since 2020/10/15
**/
public interface HotWordsHistoryMapper extends BaseMapper<HotWordsHistory> {
/**
* 获取订单统计数据
*
* @param queryWrapper 查询条件
* @return 订单统计列表
*/
@Select("SELECT score,keywords,DATE_FORMAT(create_time,'%Y-%m-%d') AS create_time FROM li_hot_words_history " +" ${ew.customSqlSegment}")
List<HotWordsHistory> statistics(@Param(Constants.WRAPPER) Wrapper queryWrapper);
}

View File

@ -26,28 +26,6 @@ public interface EsGoodsSearchService {
*/
SearchPage<EsGoodsIndex> searchGoods(EsGoodsSearchDTO searchDTO, PageVO pageVo);
/**
* 获取热门关键词
*
* @param count 热词数量
* @return 热词集合
*/
List<String> getHotWords(Integer count);
/**
* 设置热门关键词
*
* @param hotWords 热词分数
*/
void setHotWords(HotWordsDTO hotWords);
/**
* 删除热门关键词
*
* @param keywords 热词
*/
void deleteHotWords(String keywords);
/**
* 获取筛选器
*

View File

@ -0,0 +1,41 @@
package cn.lili.modules.search.service;
import cn.lili.modules.search.entity.dos.CustomWords;
import cn.lili.modules.search.entity.dos.HotWordsHistory;
import cn.lili.modules.search.entity.dto.HotWordsDTO;
import cn.lili.modules.search.entity.dto.HotWordsSearchParams;
import cn.lili.modules.search.entity.vo.HotWordsHistoryVO;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.poi.ss.formula.functions.T;
import java.util.Date;
import java.util.List;
/**
* HotWordsService
*
* @author Chopper
* @version v1.0
* 2022-04-14 09:35
*/
public interface HotWordsHistoryService extends IService<HotWordsHistory> {
/**
* 热词统计
*
* @param hotWordsSearchParams
* @return
*/
List<HotWordsHistory> statistics(HotWordsSearchParams hotWordsSearchParams);
/**
* 根据时间查询
*
* @param queryTime 查询时间
* @return
*/
List<HotWordsHistory> queryByDay(Date queryTime);
}

View File

@ -0,0 +1,38 @@
package cn.lili.modules.search.service;
import cn.lili.modules.search.entity.dto.HotWordsDTO;
import java.util.List;
/**
* HotWordsService
*
* @author Chopper
* @version v1.0
* 2022-04-14 09:35
*/
public interface HotWordsService {
/**
* 获取热门关键词
*
* @param count 热词数量
* @return 热词集合
*/
List<String> getHotWords(Integer count);
/**
* 设置热门关键词
*
* @param hotWords 热词分数
*/
void setHotWords(HotWordsDTO hotWords);
/**
* 删除热门关键词
*
* @param keywords 热词
*/
void deleteHotWords(String keywords);
}

View File

@ -100,38 +100,6 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
return SearchHitSupport.searchPageFor(search, searchQuery.getPageable());
}
@Override
public List<String> getHotWords(Integer count) {
if (count == null) {
count = 0;
}
List<String> hotWords = new ArrayList<>();
// redis 排序中下标从0开始所以这里需要 -1 处理
count = count - 1;
Set<ZSetOperations.TypedTuple<Object>> set = cache.reverseRangeWithScores(CachePrefix.HOT_WORD.getPrefix(), count);
if (set == null || set.isEmpty()) {
return new ArrayList<>();
}
for (ZSetOperations.TypedTuple<Object> defaultTypedTuple : set) {
hotWords.add(Objects.requireNonNull(defaultTypedTuple.getValue()).toString());
}
return hotWords;
}
@Override
public void setHotWords(HotWordsDTO hotWords) {
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint());
}
/**
* 删除热门关键词
*
* @param keywords 热词
*/
@Override
public void deleteHotWords(String keywords) {
cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords);
}
@Override
public EsGoodsRelatedInfo getSelector(EsGoodsSearchDTO goodsSearch, PageVO pageVo) {
@ -177,6 +145,7 @@ public class EsGoodsSearchServiceImpl implements EsGoodsSearchService {
return this.restTemplate.get(id, EsGoodsIndex.class);
}
/**
* 转换搜索结果为聚合商品展示信息
*

View File

@ -0,0 +1,73 @@
package cn.lili.modules.search.serviceimpl;
import cn.lili.modules.search.entity.dos.HotWordsHistory;
import cn.lili.modules.search.entity.dto.HotWordsSearchParams;
import cn.lili.modules.search.mapper.HotWordsHistoryMapper;
import cn.lili.modules.search.service.HotWordsHistoryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 历史热词
*
* @author paulG
* @since 2020/10/15
**/
@Service
public class HotWordsHistoryServiceImpl extends ServiceImpl<HotWordsHistoryMapper, HotWordsHistory> implements HotWordsHistoryService {
@Override
public List<HotWordsHistory> statistics(HotWordsSearchParams hotWordsSearchParams) {
QueryWrapper queryWrapper = hotWordsSearchParams.queryWrapper();
List<HotWordsHistory> list = baseMapper.statistics(queryWrapper);
return initData(list, hotWordsSearchParams);
}
@Override
public List<HotWordsHistory> queryByDay(Date queryTime) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("create_time", queryTime);
return list(queryWrapper);
}
/**
* 历史统计查询
*
* @param source
* @return
*/
private List<HotWordsHistory> initData(List<HotWordsHistory> source, HotWordsSearchParams hotWordsSearchParams) {
//结果集
List<HotWordsHistory> onlineMemberVOS = new ArrayList<>();
//时间初始化
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT-8:00"));
calendar.setTime(hotWordsSearchParams.getStartTIme());
//判定是否超出时间 如果结束时间在循环时间之后则跳出循环
while (hotWordsSearchParams.getEndTime().after(calendar.getTime())) {
// //筛选时间相等的查询结果
Optional<HotWordsHistory> first = source.stream().filter(item -> item.getCreateTime().equals(calendar.getTime())).findFirst();
if (first.isPresent()) {
onlineMemberVOS.add(first.get());
} else {
onlineMemberVOS.add(new HotWordsHistory(hotWordsSearchParams.getKeywords(), 0, calendar.getTime()));
}
// for (HotWordsHistory hotWordsHistory : source) {
// System.out.println(hotWordsHistory.getCreateTime().getTime() + "-" + calendar.getTime().getTime());
// if (hotWordsHistory.getCreateTime().equals(calendar.getTime())) {
// onlineMemberVOS.add(hotWordsHistory);
// } else {
// onlineMemberVOS.add(new HotWordsHistory(hotWordsSearchParams.getKeywords(), 0, calendar.getTime()));
// }
// }
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1);
}
return onlineMemberVOS;
}
}

View File

@ -0,0 +1,68 @@
package cn.lili.modules.search.serviceimpl;
import cn.lili.cache.Cache;
import cn.lili.cache.CachePrefix;
import cn.lili.modules.search.entity.dto.HotWordsDTO;
import cn.lili.modules.search.mapper.HotWordsHistoryMapper;
import cn.lili.modules.search.service.HotWordsService;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
/**
* HotWordsServiceImpl
*
* @author Chopper
* @version v1.0
* 2022-04-14 09:35
*/
@Service
public class HotWordsServiceImpl implements HotWordsService {
/**
* 缓存
*/
@Autowired
private Cache<Object> cache;
@Override
public List<String> getHotWords(Integer count) {
if (count == null) {
count = 0;
}
List<String> hotWords = new ArrayList<>();
// redis 排序中下标从0开始所以这里需要 -1 处理
count = count - 1;
Set<ZSetOperations.TypedTuple<Object>> set = cache.reverseRangeWithScores(CachePrefix.HOT_WORD.getPrefix(), count);
if (set == null || set.isEmpty()) {
return new ArrayList<>();
}
for (ZSetOperations.TypedTuple<Object> defaultTypedTuple : set) {
hotWords.add(Objects.requireNonNull(defaultTypedTuple.getValue()).toString());
}
return hotWords;
}
@Override
public void setHotWords(HotWordsDTO hotWords) {
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), hotWords.getKeywords(), hotWords.getPoint());
}
/**
* 删除热门关键词
*
* @param keywords 热词
*/
@Override
public void deleteHotWords(String keywords) {
cache.zRemove(CachePrefix.HOT_WORD.getPrefix(), keywords);
}
}

View File

@ -70,7 +70,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
//结算基础信息
bill.setStartTime(startTime);
bill.setEndTime(DateUtil.yesterday());
bill.setEndTime(endTime);
bill.setBillStatus(BillStatusEnum.OUT.name());
bill.setStoreId(storeId);
bill.setStoreName(store.getStoreName());

View File

@ -0,0 +1,28 @@
package cn.lili.modules.system.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 搜索热词
*
* @author Bulbasaur
* @since 2021/5/16 11:10 下午
*/
@Data
public class HotWordsSetting implements Serializable {
//热词1-5默认分数1-5
@ApiModelProperty(value = "热词默认配置")
private List<HotWordsSettingItem> hotWordsSettingItems = new ArrayList<>();
@ApiModelProperty("每日保存数量")
private Integer saveNum;
}

View File

@ -0,0 +1,41 @@
package cn.lili.modules.system.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 积分签到设置
*
* @author Chopper
* @since 2021-02-26 11:48
*/
@Data
public class HotWordsSettingItem implements Comparable<HotWordsSettingItem>, Serializable {
@ApiModelProperty(value = "热词")
private String keywords;
@ApiModelProperty(value = "默认分数")
private Integer score;
public Integer getScore() {
if (score == null || score < 0) {
return 0;
}
return score;
}
public void setScore(Integer score) {
this.score = score;
}
@Override
public int compareTo(HotWordsSettingItem pointSettingItem) {
return pointSettingItem.getScore();
}
}

View File

@ -44,5 +44,7 @@ public enum SettingEnum {
//支付宝支付设置
ALIPAY_PAYMENT,
//微信支付设置
WECHAT_PAYMENT;
WECHAT_PAYMENT,
//热词设置
HOT_WORDS
}

View File

@ -1,47 +0,0 @@
package cn.lili.controller.hotwords;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.search.entity.dto.HotWordsDTO;
import cn.lili.modules.search.service.EsGoodsSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 管理端,app版本控制器
*
* @author Chopper
* @since 2018-07-04 21:50:52
*/
@RestController
@Api(tags = "管理端,系统设置扩展接口")
@RequestMapping("/manager/hotwords/hotwords")
public class HotWordsManagerController {
@Autowired
private EsGoodsSearchService esGoodsSearchService;
@ApiOperation(value = "获取热词")
@GetMapping
public ResultMessage<Object> getHotWords() {
return ResultUtil.data(esGoodsSearchService.getHotWords(100));
}
@ApiOperation(value = "设置热词")
@PostMapping
public ResultMessage<Object> paymentForm(@Validated HotWordsDTO hotWords) {
esGoodsSearchService.setHotWords(hotWords);
return ResultUtil.success();
}
@ApiOperation(value = "设置热词")
@DeleteMapping("/{words}")
public ResultMessage<Object> deleteWords(@PathVariable String words) {
esGoodsSearchService.deleteHotWords(words);
return ResultUtil.success();
}
}

View File

@ -0,0 +1,79 @@
package cn.lili.controller.other;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.search.entity.dto.HotWordsDTO;
import cn.lili.modules.search.entity.dto.HotWordsSearchParams;
import cn.lili.modules.search.service.HotWordsHistoryService;
import cn.lili.modules.search.service.HotWordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 管理端,热词管理
*
* @author Chopper
* @since 2018-07-04 21:50:52
*/
@RestController
@Api(tags = "管理端,热词管理")
@RequestMapping("/manager/hotwords/hotwords")
public class HotWordsManagerController {
@Autowired
private HotWordsService hotWordsService;
@Autowired
private HotWordsHistoryService hotWordsHistoryService;
@ApiOperation(value = "获取热词")
@GetMapping
public ResultMessage<Object> getHotWords() {
return ResultUtil.data(hotWordsService.getHotWords(100));
}
@ApiOperation(value = "设置热词")
@PostMapping
public ResultMessage<Object> setHotWords(@Validated HotWordsDTO hotWords) {
hotWordsService.setHotWords(hotWords);
return ResultUtil.success();
}
@ApiOperation(value = "删除热词")
@DeleteMapping
public ResultMessage<Object> deleteWords(String words) {
hotWordsService.deleteHotWords(words);
return ResultUtil.success();
}
@ApiOperation(value = "历史热词")
@GetMapping("/history")
public ResultMessage<Object> deleteWords(HistorySearchParams historySearchParams) {
return ResultUtil.data(hotWordsHistoryService.queryByDay(historySearchParams.getDate()));
}
@ApiOperation(value = "热词统计")
@GetMapping("/statistics")
public ResultMessage<Object> deleteWords(HotWordsSearchParams hotWordsSearchParams) {
return ResultUtil.data(hotWordsHistoryService.statistics(hotWordsSearchParams));
}
}
@Data
class HistorySearchParams {
@DateTimeFormat(pattern = "yyyy-MM-dd")
@NotNull(message = "查询日期不能为空")
private Date date;
}

View File

@ -185,6 +185,10 @@ public class SettingManagerController {
return setting == null ?
ResultUtil.data(new ImSetting()) :
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ImSetting.class));
case HOT_WORDS:
return setting == null ?
ResultUtil.data(new HotWordsSetting()) :
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class));
default:
throw new ServiceException(ResultCode.SETTING_NOT_TO_SET);
}