记得上下班打卡 | git大法好,push需谨慎

Commit 0bbe7f7d authored by 胡佳晨's avatar 胡佳晨

提交 五条人需求 活动状态和banner

parent 17b80e87
...@@ -46,6 +46,9 @@ public class SweetConstant { ...@@ -46,6 +46,9 @@ public class SweetConstant {
public final static String REDIS_KEY_SWEET_CITY_VOTE = "sweet:cityVote"; public final static String REDIS_KEY_SWEET_CITY_VOTE = "sweet:cityVote";
public final static String REDIS_KEY_SWEET_CITY_VOTE_USER = ":user:"; public final static String REDIS_KEY_SWEET_CITY_VOTE_USER = ":user:";
public final static String REDIS_KEY_SWEET_CITY_VOTE_STAT_UPDATE_TIME = ":updateTime"; public final static String REDIS_KEY_SWEET_CITY_VOTE_STAT_UPDATE_TIME = ":updateTime";
public final static String REDIS_KEY_SWEET_CITY_VOTE_START = "sweet:cityVote:startTime:";//活动开始时间
public final static String REDIS_KEY_SWEET_CITY_VOTE_END = "sweet:cityVote:endTime:";//活动结束时间
public final static String REDIS_KEY_SWEET_CITY_VOTE_BANNER = "sweet:cityVote:banner:";//活动banner
// 微信用户相关 // 微信用户相关
public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO = "sweet:wechatUser:zhengzai:unionId:"; public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO = "sweet:wechatUser:zhengzai:unionId:";
public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO_MODERNSKY = "sweet:wechatUser:modernsky:unionId:"; public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO_MODERNSKY = "sweet:wechatUser:modernsky:unionId:";
......
package com.liquidnet.service.sweet.dto.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class TempBannerVo implements Serializable, Cloneable {
private static final long serialVersionUID = -6777064807434774542L;
@ApiModelProperty(value = "banner图片")
private String src;
@ApiModelProperty(value = "banner链接")
private String url;
}
package com.liquidnet.service.sweet.param;
import com.liquidnet.service.sweet.dto.vo.TempBannerVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@ApiModel(value = "SweetCityVoteParam", description = "用户投票记录入参")
@Data
public class TempBannerParam implements Serializable {
@ApiModelProperty(position = 13, required = true, value = "临时banner数据")
@NotBlank(message = "tempBannerVo不能为空")
private List<TempBannerVo> tempBannerVo;
@ApiModelProperty(position = 14, required = true, value = "活动类型 1新裤子 2莫宰羊", example = "1")
@NotNull(message = "type不能为空")
private Integer type;
}
...@@ -43,6 +43,9 @@ public class SweetCItyVoteStatVo implements Serializable, Cloneable { ...@@ -43,6 +43,9 @@ public class SweetCItyVoteStatVo implements Serializable, Cloneable {
@ApiModelProperty("名次变动状态 1未变化 2上升 3下降") @ApiModelProperty("名次变动状态 1未变化 2上升 3下降")
private Integer rankingUpOrDown; private Integer rankingUpOrDown;
// @ApiModelProperty("状态[0-未开始|1-进行中|2-已结束]")
// private Integer status;
/*@ApiModelProperty("创建时间") /*@ApiModelProperty("创建时间")
private LocalDateTime createdAt; private LocalDateTime createdAt;
...@@ -50,6 +53,7 @@ public class SweetCItyVoteStatVo implements Serializable, Cloneable { ...@@ -50,6 +53,7 @@ public class SweetCItyVoteStatVo implements Serializable, Cloneable {
private LocalDateTime updatedAt;*/ private LocalDateTime updatedAt;*/
private static final SweetCItyVoteStatVo obj = new SweetCItyVoteStatVo(); private static final SweetCItyVoteStatVo obj = new SweetCItyVoteStatVo();
public static SweetCItyVoteStatVo getNew() { public static SweetCItyVoteStatVo getNew() {
try { try {
return (SweetCItyVoteStatVo) obj.clone(); return (SweetCItyVoteStatVo) obj.clone();
......
...@@ -2,13 +2,17 @@ package com.liquidnet.service.sweet.controller; ...@@ -2,13 +2,17 @@ package com.liquidnet.service.sweet.controller;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.dto.vo.TempBannerVo;
import com.liquidnet.service.sweet.param.SweetCityVoteParam; import com.liquidnet.service.sweet.param.SweetCityVoteParam;
import com.liquidnet.service.sweet.param.TempBannerParam;
import com.liquidnet.service.sweet.service.ISweetCityVoteService; import com.liquidnet.service.sweet.service.ISweetCityVoteService;
import com.liquidnet.service.sweet.utils.RedisDataUtils;
import com.liquidnet.service.sweet.vo.SweetCItyVoteStatVo; import com.liquidnet.service.sweet.vo.SweetCItyVoteStatVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -58,4 +62,24 @@ public class SweetCityVoteController { ...@@ -58,4 +62,24 @@ public class SweetCityVoteController {
return sweetCityVoteService.setStatList(type); return sweetCityVoteService.setStatList(type);
} }
@Autowired
RedisDataUtils redisDataUtils;
@PostMapping("setTime")
@ApiOperation("临时-设置时间")
@ApiImplicitParams({
@ApiImplicitParam(type = "query", dataType = "String", name = "endTime", value = "结束时间[2021-12-01 10:00:00]", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "startTime", value = "开始时间[2021-12-01 10:00:00]", required = true),
@ApiImplicitParam(type = "query", dataType = "Integer", name = "type", value = "活动类型 1新裤子 2莫宰羊", required = false)
})
public void setStartEndTime(@RequestParam Integer type, @RequestParam String startTime, @RequestParam String endTime) {
redisDataUtils.setStartEndTime(type, startTime, endTime);
}
@PostMapping("setBanner")
@ApiOperation("临时-设置banner")
public void setTempBanner(@RequestBody TempBannerParam param) {
redisDataUtils.setTempBanner(param.getType(), param.getTempBannerVo());
}
} }
...@@ -8,6 +8,7 @@ import com.liquidnet.service.base.ResponseDto; ...@@ -8,6 +8,7 @@ import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.sweet.dto.SweetCityVoteStatDto; import com.liquidnet.service.sweet.dto.SweetCityVoteStatDto;
import com.liquidnet.service.sweet.dto.vo.TempBannerVo;
import com.liquidnet.service.sweet.entity.SweetCityVote; import com.liquidnet.service.sweet.entity.SweetCityVote;
import com.liquidnet.service.sweet.mapper.SweetCityVoteMapper; import com.liquidnet.service.sweet.mapper.SweetCityVoteMapper;
import com.liquidnet.service.sweet.mapper.SweetCityVoteStatMapper; import com.liquidnet.service.sweet.mapper.SweetCityVoteStatMapper;
...@@ -29,6 +30,8 @@ import java.util.HashMap; ...@@ -29,6 +30,8 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import static com.liquidnet.commons.lang.util.DateUtil.DTF_YMD_HMS;
/** /**
* <p> * <p>
* 答题表 服务实现类 * 答题表 服务实现类
...@@ -70,6 +73,26 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S ...@@ -70,6 +73,26 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
stringObjectHashMap.put("userVote", userVote); stringObjectHashMap.put("userVote", userVote);
stringObjectHashMap.put("statUpdateTime", redisDataUtils.getSweetCityVoteStatUpdateTime(type)); stringObjectHashMap.put("statUpdateTime", redisDataUtils.getSweetCityVoteStatUpdateTime(type));
//获取活动状态
HashMap<String, String> map = redisDataUtils.getStartEndTime(type);
if (map.get("startTime") == null || map.get("endTime") == null) {
stringObjectHashMap.put("activeStatus", 2);
} else {
LocalDateTime startTime = LocalDateTime.parse(map.get("startTime"), DTF_YMD_HMS);
LocalDateTime endTime = LocalDateTime.parse(map.get("endTime"), DTF_YMD_HMS);
LocalDateTime now = LocalDateTime.now();
if (startTime.isBefore(now)) {
stringObjectHashMap.put("activeStatus", 0);
} else if (endTime.isAfter(now)) {
stringObjectHashMap.put("activeStatus", 2);
} else {
stringObjectHashMap.put("activeStatus", 1);
}
}
//获取banner
List<TempBannerVo> bannerVoList = redisDataUtils.getTempBanner(type);
stringObjectHashMap.put("bannerList", bannerVoList);
return ResponseDto.success(stringObjectHashMap); return ResponseDto.success(stringObjectHashMap);
} }
......
...@@ -13,6 +13,7 @@ import com.liquidnet.service.sweet.dto.SweetManualArtistListDto; ...@@ -13,6 +13,7 @@ import com.liquidnet.service.sweet.dto.SweetManualArtistListDto;
import com.liquidnet.service.sweet.dto.SweetManualArtistStageListDto; import com.liquidnet.service.sweet.dto.SweetManualArtistStageListDto;
import com.liquidnet.service.sweet.dto.vo.IntegralActivityDrawVo; import com.liquidnet.service.sweet.dto.vo.IntegralActivityDrawVo;
import com.liquidnet.service.sweet.dto.vo.IntegralActivityVo; import com.liquidnet.service.sweet.dto.vo.IntegralActivityVo;
import com.liquidnet.service.sweet.dto.vo.TempBannerVo;
import com.liquidnet.service.sweet.entity.*; import com.liquidnet.service.sweet.entity.*;
import com.liquidnet.service.sweet.mapper.*; import com.liquidnet.service.sweet.mapper.*;
import com.liquidnet.service.sweet.param.SweetCityVoteParam; import com.liquidnet.service.sweet.param.SweetCityVoteParam;
...@@ -768,4 +769,62 @@ public class RedisDataUtils { ...@@ -768,4 +769,62 @@ public class RedisDataUtils {
.concat(userId); .concat(userId);
redisUtil.uLock(redisKey); redisUtil.uLock(redisKey);
} }
/***
* 设置活动开始结束时间
* @param type
* @param startTime
* @param endTime
*/
public void setStartEndTime(Integer type, String startTime, String endTime) {
String startRedisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_START.concat(":type:" + type);
String endRedisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_END.concat(":type:" + type);
redisUtil.set(startRedisKey, startTime);
redisUtil.set(endRedisKey, endTime);
}
/**
* 获取活动开始结束时间 如果报错返回null
*
* @param type
* @return
*/
public HashMap<String, String> getStartEndTime(Integer type) {
try {
HashMap<String, String> map = CollectionUtil.mapStringString();
String startRedisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_START.concat(":type:" + type);
String endRedisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_END.concat(":type:" + type);
map.put("startTime", (String) redisUtil.get(startRedisKey));
map.put("endTime", (String) redisUtil.get(endRedisKey));
return map;
} catch (Exception e) {
return null;
}
}
/**
* 设置临时banner
* @param type
* @param vo
*/
public void setTempBanner(Integer type, List<TempBannerVo> vo) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_BANNER.concat(":type:" + type);
redisUtil.set(redisKey, vo);
}
/**
* 获取临时banner
* @param type
* @return
*/
public List<TempBannerVo> getTempBanner(Integer type) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_BANNER.concat(":type:" + type);
Object obj = redisUtil.get(redisKey);
if(obj==null){
return null;
}else{
return (List<TempBannerVo>)obj;
}
}
} }
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