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

Commit fc24cf3c authored by jiangxiulong's avatar jiangxiulong

用户投票列表 creat

parent 3ff35925
...@@ -81,6 +81,7 @@ public class MQConst { ...@@ -81,6 +81,7 @@ public class MQConst {
SWEET_USER_INSERT_DRAW("sweet:stream:rk.sweetUserInsert", "group.sweetUserInsert", "关注服务号的用户信息"), SWEET_USER_INSERT_DRAW("sweet:stream:rk.sweetUserInsert", "group.sweetUserInsert", "关注服务号的用户信息"),
SWEET_REMIND_INSERT_DRAW("sweet:stream:rk.remindInsert", "group.remindInsert", "提醒记录"), SWEET_REMIND_INSERT_DRAW("sweet:stream:rk.remindInsert", "group.remindInsert", "提醒记录"),
SWEET_APPLET_USER_INSERT_DRAW("sweet:stream:rk.sweetAppletUserInsert", "group.sweetAppletUserInsert", "小程序登录记录用户解密后信息"), SWEET_APPLET_USER_INSERT_DRAW("sweet:stream:rk.sweetAppletUserInsert", "group.sweetAppletUserInsert", "小程序登录记录用户解密后信息"),
SWEET_CITY_VOTE_INSERT_DRAW("sweet:stream:rk.cityVoteInsert", "group.cityVoteInsert", "用户投票记录"),
; ;
private final String key; private final String key;
......
...@@ -499,6 +499,24 @@ CREATE TABLE `sweet_city_vote` ...@@ -499,6 +499,24 @@ CREATE TABLE `sweet_city_vote`
COLLATE utf8mb4_unicode_ci COLLATE utf8mb4_unicode_ci
ROW_FORMAT = DYNAMIC COMMENT '城市投票表'; ROW_FORMAT = DYNAMIC COMMENT '城市投票表';
drop TABLE if exists `sweet_city_vote_stat`;
CREATE TABLE `sweet_city_vote_stat`
(
`mid` bigint unsigned NOT NULL AUTO_INCREMENT,
`stat_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'stat_id',
`city_code` varchar(255) NOT NULL DEFAULT '' COMMENT '城市代码',
`city_name` varchar(255) NOT NULL DEFAULT '' COMMENT '城市名称',
`vote_num` int NOT NULL DEFAULT 0 COMMENT '真实投票数量',
`manual_vote_num` int NOT NULL DEFAULT 0 COMMENT '手动增加投票数量',
`created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`mid`),
KEY `sweet_city_vote_stat_stat_id` (`stat_id`)
) ENGINE = InnoDB
DEFAULT CHARSET utf8mb4
COLLATE utf8mb4_unicode_ci
ROW_FORMAT = DYNAMIC COMMENT '城市投票统计表';
-- 提醒记录 -- 提醒记录
drop TABLE if exists `sweet_remind`; drop TABLE if exists `sweet_remind`;
CREATE TABLE `sweet_remind` CREATE TABLE `sweet_remind`
......
...@@ -24,6 +24,8 @@ public class SweetConstant { ...@@ -24,6 +24,8 @@ public class SweetConstant {
public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO_STR="sweet:wechatUser:unionIdStr:"; public final static String REDIS_KEY_SWEET_WECHAT_USER_INFO_STR="sweet:wechatUser:unionIdStr:";
public final static String REDIS_KEY_SWEET_WECHAT_USER_UNIONID="sweet:wechatUser:openId:"; public final static String REDIS_KEY_SWEET_WECHAT_USER_UNIONID="sweet:wechatUser:openId:";
public final static String REDIS_KEY_SWEET_ANSWER_PHONE="sweet:answer:phone:"; public final static String REDIS_KEY_SWEET_ANSWER_PHONE="sweet:answer:phone:";
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 enum ManualPosition { // public enum ManualPosition {
// artist("艺人","artist"), // artist("艺人","artist"),
......
package com.liquidnet.service.sweet.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.param.SweetCityVoteParam;
import com.liquidnet.service.sweet.service.ISweetCityVoteService;
import com.liquidnet.service.sweet.vo.SweetCItyVoteStatVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* <p>
* 城市投票表 前端控制器
* </p>
*
* @author jiangxiulong
* @since 2021-09-15
*/
@RestController
@RequestMapping("/sweetCityVote")
public class SweetCityVoteController {
@Autowired
private ISweetCityVoteService sweetCityVoteService;
@GetMapping("statList")
@ApiOperation("城市投票排名")
public ResponseDto<List<SweetCItyVoteStatVo>> getList() {
return sweetCityVoteService.getList();
}
@PostMapping("createVote")
@ApiOperation("用户投票记录")
public ResponseDto<Boolean> createVote(@Valid @RequestBody SweetCityVoteParam param) {
return sweetCityVoteService.createVote(param);
}
}
package com.liquidnet.service.sweet.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 城市投票表
* </p>
*
* @author jiangxiulong
* @since 2021-09-15
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class SweetCityVote implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
/**
* vote_id
*/
private String voteId;
/**
* 手机号
*/
private String phone;
/**
* unionId
*/
@TableField("unionId")
private String unionId;
/**
* 城市代码
*/
private String cityCode;
/**
* 城市名称
*/
private String cityName;
/**
* 创建时间
*/
private LocalDateTime createdAt;
/**
* 更新时间
*/
private LocalDateTime updatedAt;
private static final SweetCityVote obj = new SweetCityVote();
public static SweetCityVote getNew() {
try {
return (SweetCityVote) obj.clone();
} catch (CloneNotSupportedException e) {
return new SweetCityVote();
}
}
}
package com.liquidnet.service.sweet.mapper;
import com.liquidnet.service.sweet.entity.SweetCityVote;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 城市投票表 Mapper 接口
* </p>
*
* @author jiangxiulong
* @since 2021-09-15
*/
public interface SweetCityVoteMapper extends BaseMapper<SweetCityVote> {
}
package com.liquidnet.service.sweet.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@ApiModel(value = "SweetCityVoteParam", description = "用户投票记录入参")
@Data
public class SweetCityVoteParam implements java.io.Serializable {
private static final long serialVersionUID = -2626425843975309892L;
@ApiModelProperty(position = 10, required = true, value = "手机号", example = "15811009011")
@NotBlank(message = "phone不能为空")
private String phone;
@ApiModelProperty(position = 11, required = true, value = "unionId", example = "unionId")
@NotBlank(message = "unionId不能为空")
private String unionId;
@ApiModelProperty(position = 12, required = true, value = "城市代码", example = "10001")
@NotBlank(message = "cityCode不能为空")
private String cityCode;
@ApiModelProperty(position = 13, required = true, value = "城市名称", example = "北京")
@NotBlank(message = "cityName不能为空")
private String cityName;
}
package com.liquidnet.service.sweet.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.entity.SweetCityVote;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.sweet.param.SweetCityVoteParam;
import com.liquidnet.service.sweet.vo.SweetCItyVoteStatVo;
import java.util.List;
/**
* <p>
* 城市投票表 服务类
* </p>
*
* @author jiangxiulong
* @since 2021-09-15
*/
public interface ISweetCityVoteService extends IService<SweetCityVote> {
ResponseDto<List<SweetCItyVoteStatVo>> getList();
ResponseDto<Boolean> createVote(SweetCityVoteParam param);
}
package com.liquidnet.service.sweet.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.sweet.entity.SweetCityVote;
import com.liquidnet.service.sweet.mapper.SweetCityVoteMapper;
import com.liquidnet.service.sweet.param.SweetCityVoteParam;
import com.liquidnet.service.sweet.service.ISweetCityVoteService;
import com.liquidnet.service.sweet.utils.QueueUtils;
import com.liquidnet.service.sweet.utils.RedisDataUtils;
import com.liquidnet.service.sweet.vo.SweetCItyVoteStatVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* <p>
* 答题表 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2021-08-12
*/
@Service
public class SweetCityVoteServiceImpl extends ServiceImpl<SweetCityVoteMapper, SweetCityVote> implements ISweetCityVoteService {
@Autowired
private RedisDataUtils redisDataUtils;
@Autowired
QueueUtils queueUtils;
@Override
public ResponseDto<List<SweetCItyVoteStatVo>> getList() {
List<SweetCItyVoteStatVo> sweetCityVoteStatList = redisDataUtils.getSweetCityVoteStatList();
return ResponseDto.success(sweetCityVoteStatList);
}
@Override
public ResponseDto<Boolean> createVote(SweetCityVoteParam param) {
SweetCityVote aNew = SweetCityVote.getNew();
aNew.setVoteId(IDGenerator.nextSnowId());
aNew.setPhone(param.getPhone());
aNew.setUnionId(param.getUnionId());
aNew.setCityCode(param.getCityCode());
aNew.setCityName(param.getCityName());
LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlsDataA = CollectionUtil.linkedListObjectArr();
sqls.add(SqlMapping.get("sweet_city_vote.insert"));
sqlsDataA.add(new Object[]{
aNew.getVoteId(), aNew.getPhone(), aNew.getUnionId(), aNew.getCityCode(), aNew.getCityName()
});
queueUtils.sendMsgByRedis(MQConst.SweetQueue.SWEET_CITY_VOTE_INSERT_DRAW.getKey(),
SqlMapping.gets(sqls, sqlsDataA));
Integer cityVoteNum = redisDataUtils.getSweetCityVote(aNew.getCityCode());
if (cityVoteNum > 0) { // 已有 incr
} else {// insert
}
redisDataUtils.incrSweetCityVote(aNew.getCityCode());
return ResponseDto.success();
}
}
...@@ -13,10 +13,7 @@ import com.liquidnet.service.sweet.dto.SweetManualArtistListDto; ...@@ -13,10 +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.entity.*; import com.liquidnet.service.sweet.entity.*;
import com.liquidnet.service.sweet.mapper.*; import com.liquidnet.service.sweet.mapper.*;
import com.liquidnet.service.sweet.vo.SweetAnswerVo; import com.liquidnet.service.sweet.vo.*;
import com.liquidnet.service.sweet.vo.SweetArtistsRelationVo;
import com.liquidnet.service.sweet.vo.SweetPrizeVo;
import com.liquidnet.service.sweet.vo.SweetRemindVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -24,9 +21,6 @@ import org.springframework.stereotype.Component; ...@@ -24,9 +21,6 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import static com.liquidnet.service.sweet.constant.SweetConstant.REDIS_KEY_SWEET_LUCK_DRAW_PRESENT_MOBILE;
import static com.liquidnet.service.sweet.constant.SweetConstant.REDIS_KEY_SWEET_LUCK_DRAW_SURPLUS;
@Component @Component
@Slf4j @Slf4j
public class RedisDataUtils { public class RedisDataUtils {
...@@ -477,10 +471,28 @@ public class RedisDataUtils { ...@@ -477,10 +471,28 @@ public class RedisDataUtils {
String redisKey = SweetConstant.REDIS_KEY_SWEET_ANSWER_PHONE.concat(sweetAnswerVo.getPhone()); String redisKey = SweetConstant.REDIS_KEY_SWEET_ANSWER_PHONE.concat(sweetAnswerVo.getPhone());
redisUtil.set(redisKey, sweetAnswerVo); redisUtil.set(redisKey, sweetAnswerVo);
} }
public SweetAnswerVo getSweetAnswer(String phone) { public SweetAnswerVo getSweetAnswer(String phone) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_ANSWER_PHONE.concat(phone); String redisKey = SweetConstant.REDIS_KEY_SWEET_ANSWER_PHONE.concat(phone);
SweetAnswerVo sweetAnswerVo = (SweetAnswerVo) redisUtil.get(redisKey); SweetAnswerVo sweetAnswerVo = (SweetAnswerVo) redisUtil.get(redisKey);
return sweetAnswerVo; return sweetAnswerVo;
} }
// 投票
public void setSweetCityVoteStatList(List<SweetCItyVoteStatVo> sweetCItyVoteStatVo) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_STAT_LIST;
redisUtil.set(redisKey, sweetCItyVoteStatVo);
}
public List<SweetCItyVoteStatVo> getSweetCityVoteStatList() {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_STAT_LIST;
List<SweetCItyVoteStatVo> sweetCityVoteStatList = (List<SweetCItyVoteStatVo>) redisUtil.get(redisKey);
return sweetCityVoteStatList;
}
public void incrSweetCityVote(String cityCode) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_CITY_CODE.concat(cityCode);
redisUtil.incr(redisKey, 1);
}
public Integer getSweetCityVote(String cityCode) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_CITY_VOTE_CITY_CODE.concat(cityCode);
return (Integer) redisUtil.get(redisKey);
}
} }
package com.liquidnet.service.sweet.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@Data
public class SweetCItyVoteStatVo implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
/*@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
@ApiModelProperty("vote_id")
private String statId;*/
@ApiModelProperty("城市代码")
private String cityCode;
@ApiModelProperty("城市名称")
private String cityName;
@ApiModelProperty("真实投票数量")
private String voteNum;
@ApiModelProperty("手动增加投票数量")
private String manualVoteNum;
/*@ApiModelProperty("创建时间")
private LocalDateTime createdAt;
@ApiModelProperty("更新时间")
private LocalDateTime updatedAt;*/
private static final SweetCItyVoteStatVo obj = new SweetCItyVoteStatVo();
public static SweetCItyVoteStatVo getNew() {
try {
return (SweetCItyVoteStatVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new SweetCItyVoteStatVo();
}
}
}
...@@ -68,4 +68,6 @@ sweet_user.update=UPDATE sweet_wechat_user SET is_cancel = ?, updated_at = ? WH ...@@ -68,4 +68,6 @@ sweet_user.update=UPDATE sweet_wechat_user SET is_cancel = ?, updated_at = ? WH
# --------------------------提醒记录-------------------------- # --------------------------提醒记录--------------------------
sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performancesId) VALUES (?,?,?,?) sweet_remind.insert=INSERT INTO sweet_remind (remind_id,openId,unionId,performancesId) VALUES (?,?,?,?)
# --------------------------小程序登录记录用户解密后信息-------------------------- # --------------------------小程序登录记录用户解密后信息--------------------------
sweet_applet_user.insert=INSERT INTO sweet_applet_user (user_id,openId,unionId,getPhoneNumber,getPurePhoneNumber,getCountryCode,type) VALUES (?,?,?,?,?,?,?) sweet_applet_user.insert=INSERT INTO sweet_applet_user (user_id,openId,unionId,getPhoneNumber,getPurePhoneNumber,getCountryCode,type) VALUES (?,?,?,?,?,?,?)
\ No newline at end of file # --------------------------用户投票记录--------------------------
sweet_city_vote.insert=INSERT INTO sweet_city_vote (vote_id,phone,unionId,city_code,city_name) VALUES (?,?,?,?,?)
\ 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