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

Commit 2ffb208a authored by jiangxiulong's avatar jiangxiulong

增加updatetime hashmap list 3 投票城市

parent 84a08b4c
......@@ -27,6 +27,7 @@ public class SweetConstant {
public final static String REDIS_KEY_SWEET_CITY_VOTE_STAT_LIST="sweet:cityVote:StatList";
public final static String REDIS_KEY_SWEET_CITY_VOTE_CITY_CODE="sweet:cityVote:cityCode:";
public final static String REDIS_KEY_SWEET_CITY_VOTE_USER="sweet:cityVote:user:";
public final static String REDIS_KEY_SWEET_CITY_VOTE_STAT_UPDATE_TIME="sweet:cityVote:updateTime";
// public enum ManualPosition {
// artist("艺人","artist"),
......
......@@ -23,6 +23,7 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
......@@ -45,17 +46,24 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
private SweetCityVoteStatMapper sweetCityVoteStatMapper;
@Override
public ResponseDto<List<SweetCItyVoteStatVo>> getList(String phone, String unionId) {
public ResponseDto getList(String phone, String unionId) {
List<SweetCItyVoteStatVo> sweetCityVoteStatList = redisDataUtils.getSweetCityVoteStatList();
String userVote = redisDataUtils.getUserVote(phone, unionId);
for (SweetCItyVoteStatVo info : sweetCityVoteStatList) {
if (userVote.isEmpty() || !userVote.equals(info.getCityCode())) {
if (userVote.isEmpty()) {
info.setIsVote(1);
} else if (!userVote.equals(info.getCityCode())) {
info.setIsVote(3);
} else {
info.setIsVote(2);
}
}
return ResponseDto.success(sweetCityVoteStatList);
HashMap<String, Object> stringObjectHashMap = CollectionUtil.mapStringObject();
stringObjectHashMap.put("list", sweetCityVoteStatList);
stringObjectHashMap.put("userVote", userVote);
stringObjectHashMap.put("statUpdateTime", redisDataUtils.getSweetCityVoteStatUpdateTime());
return ResponseDto.success(stringObjectHashMap);
}
@Override
......@@ -110,6 +118,7 @@ public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, S
list.forEach(r -> newList.add(SweetCItyVoteStatVo.getNew().copy(r)));
redisDataUtils.setSweetCityVoteStatList(newList);
}
redisDataUtils.setSweetCityVoteStatUpdateTime();
return ResponseDto.success();
}
}
......@@ -530,4 +530,17 @@ public class RedisDataUtils {
return (String) obj;
}
}
public void setSweetCityVoteStatUpdateTime() {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_STAT_UPDATE_TIME;
redisUtil.set(redisKey, DateUtil.getNowTime());
}
public String getSweetCityVoteStatUpdateTime() {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_STAT_UPDATE_TIME;
Object obj = redisUtil.get(redisKey);
if (null == obj) {
return "";
} else {
return (String) obj;
}
}
}
......@@ -70,6 +70,6 @@ sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performan
# --------------------------小程序登录记录用户解密后信息--------------------------
sweet_applet_user.insert=INSERT INTO sweet_applet_user (user_id,openId,unionId,getPhoneNumber,getPurePhoneNumber,getCountryCode,type) VALUES (?,?,?,?,?,?,?)
# --------------------------用户投票记录--------------------------
sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,openId,unionId,city_code,city_name,day_time) VALUES (?,?,?,?,?,?)
sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,openId,unionId,city_code,city_name,day_time) VALUES (?,?,?,?,?,?,?)
sweet_city_vote_stat.insert=INSERT INTO sweet_city_vote_stat (stat_id,city_code,city_name,vote_num) VALUES (?,?,?,?)
sweet_city_vote_stat.update=UPDATE sweet_city_vote_stat SET vote_num = IFNULL(vote_num, 0) + 1, updated_at = ? WHERE city_code = ?
\ 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