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

Commit b0058ec5 authored by 胡佳晨's avatar 胡佳晨

Merge branch 'dev_qrCode_wechat' into pre

parents cd66e130 5e2f4f61
drop table if exists sweet_qr_code;
create table sweet_qr_code
(
mid bigint unsigned auto_increment primary key,
qr_code_id varchar (64) default '' comment 'ID',
type int default 0 comment '活动type类型',
url varchar(128) default '' comment '二维码地址',
show_num int default 0 comment '展示次数',
read_num int default 0 comment '访问次数',
created_at timestamp default CURRENT_TIMESTAMP not null,
KEY `sweet_qr_code_type` (`type`)
) engine = InnoDB comment 'type二维码表';
drop table if exists sweet_active_type;
create table sweet_active_type
(
mid bigint unsigned auto_increment primary key,
active_name varchar(64) default '' comment '活动名称',
type int default 0 comment 'type类型',
alarm_num int default 0 comment '预警数量',
max_count int default 8000 comment '最大访问次数',
created_at timestamp default CURRENT_TIMESTAMP not null,
KEY `sweet_active_type_active_name_index` (`active_name`)
) engine = InnoDB comment '活动type表';
package com.liquidnet.service.kylin.dto.param;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
public class CreateActiveQrCodeParam implements Serializable {
private String qrCodeId;
private Integer mid;
private Integer type;
@NotNull(message = "二维码地址")
private String url;
@NotNull(message = "生成个数")
private Integer count;
private Integer readNum;
}
package com.liquidnet.service.kylin.dto.param;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@Data
public class CreateActiveTypeParam implements Serializable {
private Integer mid;
@NotNull(message = "活动名称")
private String activeName;
@NotNull(message = "类型")
private Integer type;
@NotNull(message = "预警个数")
private Integer alarmNum;
@NotNull(message = "最大访问次数")
private Integer maxCount;
}
......@@ -2,6 +2,7 @@ package com.liquidnet.service.sweet.constant;
public class SweetConstant {
public final static String SWEET = "sweet:";
public final static String REDIS_KEY_SWEET_MANUAL_PUSH_LIST = "sweet:manual:pushList";
public final static String REDIS_KEY_SWEET_MANUAL_TIME_LIST = "sweet:manual:timeList:manual:";
public final static String REDIS_KEY_SWEET_MANUAL_NOTIFY_LIST = "sweet:manual:notify:manual:";
......@@ -79,4 +80,12 @@ public class SweetConstant {
//猫登活动整体
public final static String REDIS_KEY_SWEET_WECHAT_MAODENG_POSTER_TRANSFER = "sweet:maoDeng:naneAndImg:openId:transfer";
//二维码相关
public final static String QRCODE = SWEET.concat("qrcode:");
public final static String REDIS_KEY_QRCODE_MAX_NUM = QRCODE.concat("maxNum:"); //最大 :type
public final static String REDIS_KEY_QRCODE_SHOW_NUM = QRCODE.concat("showNum:"); //展示次数 :type:mid
public final static String REDIS_KEY_QRCODE_READ_NUM = QRCODE.concat("readNum:"); //读取次数 :type:mid
public final static String REDIS_KEY_QRCODE_LIST = QRCODE.concat("list:"); //二维码实体类 :type
}
package com.liquidnet.service.sweet.service;
/**
* <p>
* 活动type表 服务类
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
public interface ISweetActiveTypeService {
String getRandomQrCode(int type);
}
package com.liquidnet.service.sweet.service;
/**
* <p>
* type二维码表 服务类
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
public interface ISweetQrCodeService {
}
package com.liquidnet.client.admin.web.controller.zhengzai.sweet;
import com.github.pagehelper.PageInfo;
import com.liquidnet.client.admin.common.annotation.Log;
import com.liquidnet.client.admin.common.core.controller.BaseController;
import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.common.core.page.TableDataInfo;
import com.liquidnet.client.admin.common.enums.BusinessType;
import com.liquidnet.client.admin.zhengzai.sweet.service.ISweetAdminActiveTypeService;
import com.liquidnet.client.admin.zhengzai.sweet.service.ISweetAdminQrCodeService;
import com.liquidnet.client.admin.zhengzai.sweet.service.ISweetIntegralActivityService;
import com.liquidnet.service.kylin.dao.PerformanceTitleDao;
import com.liquidnet.service.kylin.dao.RoadShowAdminListDao;
import com.liquidnet.service.kylin.dto.param.CreateActiveQrCodeParam;
import com.liquidnet.service.kylin.dto.param.CreateActiveTypeParam;
import com.liquidnet.service.kylin.dto.param.CreateRoadShowParam;
import com.liquidnet.service.kylin.dto.vo.admin.KylinRoadShowAdminVo;
import com.liquidnet.service.kylin.service.admin.IKylinRoadShowsAdminService;
import com.liquidnet.service.sweet.dto.SweetIntegralActivityDto;
import com.liquidnet.service.sweet.dto.param.admin.SweetIntegralActivityFromParam;
import com.liquidnet.service.sweet.dto.param.admin.SweetIntegralActivityListSearchParam;
import com.liquidnet.service.sweet.dto.vo.admin.SweetIntegralActivityVo;
import com.liquidnet.service.sweet.entity.SweetActiveType;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import com.liquidnet.service.sweet.service.ISweetActiveTypeService;
import com.liquidnet.service.sweet.service.ISweetQrCodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* <p>
* 活动二维码 前端控制器
* </p>
*
* @author jiangxiulong
* @since 2021-10-20
*/
@Api(tags = "活动二维码")
@Controller
@RequestMapping("sweet/active")
public class SweetActiveController extends BaseController {
private String prefix = "zhengzai/sweet/qrCode";
@Autowired
private ISweetAdminActiveTypeService sweetAdminActiveTypeService;
@Autowired
private ISweetAdminQrCodeService sweetAdminQrCodeService;
@GetMapping("qrcode")
public String qrcode(ModelMap mmap) {
return prefix + "/qrcode";
}
@Log(title = "二维码列表管理", businessType = BusinessType.LIST)
@PostMapping("/list")
@ResponseBody
public TableDataInfo getList(@RequestParam(value = "pageNum") int page,
@RequestParam(value = "pageSize") int size) {
startPage();
List<SweetActiveType> result = sweetAdminActiveTypeService.getList(page, size);
return getDataTable(result);
}
/**
* 新增类型
*/
@GetMapping("/add")
public String add() {
return prefix + "/add";
}
@Log(title = "二维码列表管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult createType(CreateActiveTypeParam createActiveTypeParam) {
return toAjax(sweetAdminActiveTypeService.addInfo(createActiveTypeParam));
}
// @RequiresPermissions("kylin:performances:roadShow:details")
@Log(title = "二维码列表管理", businessType = BusinessType.DETAIL)
@GetMapping(value = "/details/{mid}")
public String detailsType(@PathVariable("mid") String mid, ModelMap mmap) {
SweetActiveType result = sweetAdminActiveTypeService.details(mid);
mmap.put("SweetActiveType", result);
return prefix + "/edit";
}
// @RequiresPermissions("kylin:performances:roadShow:edit")
@Log(title = "二维码列表管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult updateType(CreateActiveTypeParam createActiveTypeParam) {
return toAjax(sweetAdminActiveTypeService.changeInfo(createActiveTypeParam));
}
@Log(title = "二维码列表管理", businessType = BusinessType.DETAIL)
@GetMapping("/detailsList/{type}")
public String addPerformance(@PathVariable("type") String type, ModelMap mmap) {
mmap.put("type", type);
return prefix + "/details";
}
@GetMapping(value = "/qrCode/{type}")
@ResponseBody
public TableDataInfo listBymId(@PathVariable("type") String type) {
List<SweetQrCode> result = sweetAdminQrCodeService.getList(type);
return getDataTable(result);
}
/**
* 新增类型
*/
@GetMapping("/addQrCode/{type}")
public String addQrCode(@PathVariable("type") String type, ModelMap mmap) {
mmap.put("type", type);
return prefix + "/addQrCode";
}
@Log(title = "二维码列表管理", businessType = BusinessType.INSERT)
@PostMapping("/addQrCode")
@ResponseBody
public AjaxResult createQrCode(CreateActiveQrCodeParam createActiveTypeParam) {
return toAjax(sweetAdminQrCodeService.addQrCode(createActiveTypeParam));
}
@Log(title = "二维码列表管理", businessType = BusinessType.DETAIL)
@GetMapping(value = "/editQrCode/{mid}")
public String editDetails(@PathVariable("mid") String mid, ModelMap mmap) {
SweetQrCode result = sweetAdminQrCodeService.details(mid);
mmap.put("SweetQrCode", result);
return prefix + "/editQrCode";
}
@Log(title = "二维码列表管理", businessType = BusinessType.UPDATE)
@PostMapping("/editQrCode")
@ResponseBody
public AjaxResult updateType(CreateActiveQrCodeParam createActiveTypeParam) {
return toAjax(sweetAdminQrCodeService.changeInfo(createActiveTypeParam));
}
}
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('新增巡演')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-activeQr-add">
<div class="form-group">
<label class="col-sm-3 control-label is-required">活动名称:</label>
<div class="col-sm-8">
<input name="activeName" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">type类型:</label>
<div class="col-sm-8">
<input name="type" class="form-control" type="number" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">预警个数:</label>
<div class="col-sm-8">
<input name="alarmNum" class="form-control" type="number" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">最大访问次数:</label>
<div class="col-sm-8">
<input name="maxCount" class="form-control" type="number" value="8000" required readonly>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "sweet/active";
$("#form-roadShow-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-activeQr-add').serialize());
}
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('修改演出')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-qrcode-add">
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label is-required">mid:</label>
<div class="col-sm-8">
<input name="mid" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label is-required">type:</label>
<div class="col-sm-8">
<input name="type" th:value="${type}" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">二维码地址:</label>
<div class="col-sm-8">
<input name="url" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">生成数量:</label>
<div class="col-sm-8">
<input name="count" class="form-control" type="number" required>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "sweet/active";
$("#form-roadShow-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/addQrCode", $('#form-qrcode-add').serialize());
}
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('二维码列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()">
<i class="fa fa-plus"></i> 添加
</a>
</div>
<div class="col-sm-12 select-table table-bordered">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "sweet/active";
$(function () {
var options = {
url: prefix + "/qrCode/" + '[[${type}]]'.replaceAll("\"", ""),
createUrl: prefix + "/addQrCode/" + '[[${type}]]'.replaceAll("\"", ""),
updateUrl: prefix + "/editQrCode/{id}",
modalName: "二维码",
method: "get",
columns: [{
checkbox: true
},
{
field: 'mid',
title: '序号'
},
{
field: 'url',
title: '二维码内容'
},
{
field: 'showNum',
title: '展示次数'
},
// {
// field: 'readNum',
// title: '访问次数'
// }
// , {
// title: '操作',
// align: 'center',
// formatter: function (value, row, index) {
// var actions = [];
// actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
// return actions.join('');
// }
// }
]
};
$.table.init(options);
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('修改演出')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-activeQr-edit" th:object="${SweetActiveType}">
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label is-required">mid:</label>
<div class="col-sm-8">
<input name="mid" th:value="*{mid}" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">活动名称:</label>
<div class="col-sm-8">
<input name="activeName" th:value="*{activeName}" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">type类型:</label>
<div class="col-sm-8">
<input name="type" th:value="*{type}" class="form-control" type="number" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">预警个数:</label>
<div class="col-sm-8">
<input name="alarmNum" th:value="*{alarmNum}" class="form-control" type="number" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">最大访问次数:</label>
<div class="col-sm-8">
<input name="maxCount" th:value="*{maxCount}" class="form-control" type="number" required readonly>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "sweet/active";
$("#form-roadShow-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-activeQr-edit').serialize());
}
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('修改演出')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-qrcode-edit" th:object="${SweetQrCode}">
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label is-required">mid:</label>
<div class="col-sm-8">
<input name="mid" class="form-control" th:value="*{mid}" type="text" required readonly>
</div>
</div>
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label is-required">qrCodeId:</label>
<div class="col-sm-8">
<input name="qrCodeId" class="form-control" th:value="*{qrCodeId}" type="text" required readonly>
</div>
</div>
<div class="form-group" style="display: none">
<label class="col-sm-3 control-label is-required">type:</label>
<div class="col-sm-8">
<input name="type" th:value="*{type}" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">二维码地址:</label>
<div class="col-sm-8">
<input name="url" th:value="*{url}" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">展示次数:</label>
<div class="col-sm-8">
<input name="url" th:value="*{showNum}" class="form-control" type="text" required readonly>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">访问次数:</label>
<div class="col-sm-8">
<input name="readNum" th:value="*{readNum}" class="form-control" type="number" required>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var prefix = ctx + "sweet/active";
$("#form-roadShow-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/editQrCode", $('#form-qrcode-edit').serialize());
}
}
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('二维码管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<!-- <div class="col-sm-12 search-collapse">-->
<!-- <form id="formId">-->
<!-- <div class="select-list">-->
<!-- <ul>-->
<!-- <li>-->
<!-- <label>巡演名称:</label>-->
<!-- <input type="text" name="title"/>-->
<!-- </li>-->
<!-- <li>-->
<!-- <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i-->
<!-- class="fa fa-search"></i>&nbsp;搜索</a>-->
<!-- <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i-->
<!-- class="fa fa-refresh"></i>&nbsp;重置</a>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </form>-->
<!-- </div>-->
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()">
<i class="fa fa-plus"></i> 添加
</a>
</div>
<div class="col-sm-12 select-table table-bordered">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var updateFlag = [[${@permission.hasPermi('kylin:performances:roadShow:details')}]];
var detailsFlag = [[${@permission.hasPermi('kylin:performances:roadShow:addPerformance')}]];
var prefix = ctx + "sweet/active";
$(function () {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
updateUrl: prefix + "/details/{id}",
detailUrl: prefix + "/detailsList/{id}",
modalName: "活动类型",
columns: [{
checkbox: true
},
{
field: 'mid',
title: '序号'
},
{
field: 'activeName',
title: '活动名称'
},
{
field: 'type',
title: '类型'
},
{
field: 'alarmNum',
title: '预警个数'
},
{
field: 'maxCount',
title: '最大访问次数'
},
{
field: 'createdAt',
title: '创建时间'
},
{
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.detail(\'' + row.type + '\')"><i class="fa fa-edit"></i>二维码列表</a> ');
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>
\ No newline at end of file
package com.liquidnet.client.admin.zhengzai.sweet.service;
import com.liquidnet.service.kylin.dto.param.CreateActiveTypeParam;
import com.liquidnet.service.sweet.entity.SweetActiveType;
import java.util.List;
/**
* <p>
* 活动type表 服务类
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
public interface ISweetAdminActiveTypeService {
List<SweetActiveType> getList(int page, int size);
Boolean changeInfo(CreateActiveTypeParam createActiveTypeParam);
Boolean addInfo(CreateActiveTypeParam createActiveTypeParam);
SweetActiveType details(String mid);
}
package com.liquidnet.client.admin.zhengzai.sweet.service;
import com.liquidnet.service.kylin.dto.param.CreateActiveQrCodeParam;
import com.liquidnet.service.kylin.dto.param.CreateActiveTypeParam;
import com.liquidnet.service.sweet.entity.SweetActiveType;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import java.util.List;
/**
* <p>
* 活动type表 服务类
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
public interface ISweetAdminQrCodeService {
List<SweetQrCode> getList(String type);
Boolean addQrCode(CreateActiveQrCodeParam createActiveTypeParam);
SweetQrCode details(String mid);
Boolean changeInfo(CreateActiveQrCodeParam createActiveTypeParam);
}
package com.liquidnet.client.admin.zhengzai.sweet.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.client.admin.zhengzai.sweet.service.ISweetAdminActiveTypeService;
import com.liquidnet.client.admin.zhengzai.sweet.utils.SweetRedisAdminUtils;
import com.liquidnet.service.kylin.dto.param.CreateActiveTypeParam;
import com.liquidnet.service.sweet.entity.SweetActiveType;
import com.liquidnet.service.sweet.mapper.SweetActiveTypeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class SweetAdminActiveTypeServiceImpl implements ISweetAdminActiveTypeService {
@Autowired
SweetActiveTypeMapper sweetActiveTypeMapper;
@Autowired
SweetRedisAdminUtils sweetRedisAdminUtils;
@Override
public List<SweetActiveType> getList(int page, int size) {
return sweetActiveTypeMapper.selectList(Wrappers.lambdaQuery(SweetActiveType.class));
}
@Override
public Boolean changeInfo(CreateActiveTypeParam createActiveTypeParam) {
SweetActiveType bean = SweetActiveType.getNew();
bean.setActiveName(createActiveTypeParam.getActiveName());
bean.setAlarmNum(createActiveTypeParam.getAlarmNum());
bean.setMaxCount(createActiveTypeParam.getMaxCount());
bean.setType(createActiveTypeParam.getType());
return sweetActiveTypeMapper.update(bean, Wrappers.lambdaUpdate(SweetActiveType.class).eq(SweetActiveType::getMid, createActiveTypeParam.getMid())) > 0;
}
@Override
public Boolean addInfo(CreateActiveTypeParam createActiveTypeParam) {
SweetActiveType bean = SweetActiveType.getNew();
bean.setActiveName(createActiveTypeParam.getActiveName());
bean.setAlarmNum(createActiveTypeParam.getAlarmNum());
bean.setMaxCount(createActiveTypeParam.getMaxCount());
bean.setType(createActiveTypeParam.getType());
sweetRedisAdminUtils.setQrCodMaxNum(createActiveTypeParam.getType(), createActiveTypeParam.getMaxCount());
return sweetActiveTypeMapper.insert(bean) == 1;
}
@Override
public SweetActiveType details(String mid) {
return sweetActiveTypeMapper.selectOne(Wrappers.lambdaQuery(SweetActiveType.class).eq(SweetActiveType::getMid, mid));
}
}
package com.liquidnet.client.admin.zhengzai.sweet.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.client.admin.zhengzai.sweet.service.ISweetAdminActiveTypeService;
import com.liquidnet.client.admin.zhengzai.sweet.service.ISweetAdminQrCodeService;
import com.liquidnet.client.admin.zhengzai.sweet.utils.SweetRedisAdminUtils;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.kylin.dto.param.CreateActiveQrCodeParam;
import com.liquidnet.service.kylin.dto.param.CreateActiveTypeParam;
import com.liquidnet.service.sweet.entity.SweetActiveType;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import com.liquidnet.service.sweet.mapper.SweetActiveTypeMapper;
import com.liquidnet.service.sweet.mapper.SweetQrCodeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class SweetAdminQrCodeServiceImpl implements ISweetAdminQrCodeService {
@Autowired
SweetQrCodeMapper sweetQrCodeMapper;
@Autowired
SweetRedisAdminUtils sweetRedisAdminUtils;
@Override
public List<SweetQrCode> getList(String type) {
List<SweetQrCode> list = sweetQrCodeMapper.selectList(Wrappers.lambdaQuery(SweetQrCode.class).eq(SweetQrCode::getType, type));
for (SweetQrCode item : list) {
item.setShowNum(sweetRedisAdminUtils.getQrCodeShowNum(Integer.parseInt(type), item.getQrCodeId()));
}
return list;
}
@Override
public Boolean addQrCode(CreateActiveQrCodeParam createActiveTypeParam) {
try {
SweetQrCode bean = SweetQrCode.getNew();
int count = sweetQrCodeMapper.selectCount(Wrappers.lambdaQuery(SweetQrCode.class).eq(SweetQrCode::getType, createActiveTypeParam.getType()));
for (int i = 0; i < createActiveTypeParam.getCount(); i++) {
int swat = count + i + 1;
String qrCodeId = IDGenerator.nextMilliId();
bean.setQrCodeId(qrCodeId);
bean.setUrl(createActiveTypeParam.getUrl().concat("&swat=") + swat);
bean.setReadNum(0);
bean.setShowNum(0);
bean.setType(createActiveTypeParam.getType());
sweetQrCodeMapper.insert(bean);
//初始化 展示次数 读取次数
sweetRedisAdminUtils.initQrCodeShowNum(createActiveTypeParam.getType(), qrCodeId);
sweetRedisAdminUtils.initQrCodeReadNum(createActiveTypeParam.getType(), qrCodeId);
}
//纪录实体类List
sweetRedisAdminUtils.setQrCodeDetails(createActiveTypeParam.getType(), sweetQrCodeMapper.selectList(Wrappers.lambdaQuery(SweetQrCode.class).eq(SweetQrCode::getType, createActiveTypeParam.getType())));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
@Override
public SweetQrCode details(String mid) {
return sweetQrCodeMapper.selectOne(Wrappers.lambdaQuery(SweetQrCode.class).eq(SweetQrCode::getMid, mid));
}
@Override
public Boolean changeInfo(CreateActiveQrCodeParam createActiveTypeParam) {
SweetQrCode bean = SweetQrCode.getNew();
bean.setReadNum(createActiveTypeParam.getReadNum());
sweetRedisAdminUtils.setQrCodeReadNum(createActiveTypeParam.getType(), createActiveTypeParam.getQrCodeId(), createActiveTypeParam.getReadNum());
return sweetQrCodeMapper.update(bean, Wrappers.lambdaUpdate(SweetQrCode.class).eq(SweetQrCode::getMid, createActiveTypeParam.getMid())) > 0;
}
}
......@@ -4,6 +4,7 @@ import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.service.sweet.constant.SweetConstant;
import com.liquidnet.service.sweet.dto.vo.IntegralActivityDrawVo;
import com.liquidnet.service.sweet.dto.vo.IntegralActivityVo;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -36,6 +37,7 @@ public class SweetRedisAdminUtils {
.concat(prizeId);
redisDataSourceUtil.getRedisSweetUtil().incr(redisKey, num);
}
public void decrIntegralActivityPrizeNum(String integralActivityId, String prizeId, Integer num) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_PRIZE_NUM
.concat(integralActivityId)
......@@ -43,6 +45,7 @@ public class SweetRedisAdminUtils {
.concat(prizeId);
redisDataSourceUtil.getRedisSweetUtil().decr(redisKey, num);
}
public void delIntegralActivityPrizeNum(String integralActivityId, String prizeId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_PRIZE_NUM
.concat(integralActivityId)
......@@ -111,4 +114,40 @@ public class SweetRedisAdminUtils {
return (int) obj;
}
}
//
public void initQrCodeReadNum(int type, String qrCodeId) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_READ_NUM.concat(type + "").concat(":qrCodeId:").concat(qrCodeId);
redisDataSourceUtil.getRedisSweetUtil().set(redisKey, 0);
}
public void setQrCodeReadNum(int type, String qrCodeId, int num) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_READ_NUM.concat(type + "").concat(":qrCodeId:").concat(qrCodeId);
redisDataSourceUtil.getRedisSweetUtil().set(redisKey, num);
}
public int getQrCodeShowNum(int type, String qrCodeId) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_SHOW_NUM.concat(type + "").concat(":qrCodeId:").concat(qrCodeId);
Object obj = redisDataSourceUtil.getRedisSweetUtil().get(redisKey);
if (obj == null) {
return 0;
} else {
return (int) obj;
}
}
public void initQrCodeShowNum(int type, String qrCodeId) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_SHOW_NUM.concat(type + "").concat(":qrCodeId:").concat(qrCodeId);
redisDataSourceUtil.getRedisSweetUtil().set(redisKey, 0);
}
public void setQrCodMaxNum(int type, int num) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_MAX_NUM.concat(type + "");
redisDataSourceUtil.getRedisSweetUtil().set(redisKey, num);
}
public void setQrCodeDetails(int type, List<SweetQrCode> data) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_LIST.concat(type + "");
redisDataSourceUtil.getRedisSweetUtil().set(redisKey, data);
}
}
......@@ -13,6 +13,7 @@ public class CollectionUtil {
private static final LinkedList<Object[]> OBJECTS_LINKED_LIST = new LinkedList<>();
private static final LinkedMultiValueMap<String, String> STRING_STRING_LINKED_MULTI_VALUE_MAP = new LinkedMultiValueMap<>();
private static final ArrayList<String> STRING_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<Integer> INTEGER_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<Object> OBJECT_ARRAY_LIST = new ArrayList<>();
......@@ -44,6 +45,11 @@ public class CollectionUtil {
return (ArrayList<String>) STRING_ARRAY_LIST.clone();
}
public static ArrayList<Integer> arrayListInteger() {
return (ArrayList<Integer>) INTEGER_ARRAY_LIST.clone();
}
public static ArrayList<Object> arrayListObject() {
return (ArrayList<Object>) OBJECT_ARRAY_LIST.clone();
}
......
package com.liquidnet.service.sweet.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 活动type表
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class SweetActiveType implements Serializable,Cloneable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
/**
* 活动名称
*/
private String activeName;
/**
* type类型
*/
private Integer type;
/**
* 预警个数
*/
private Integer alarmNum;
/**
* 最大访问次数
*/
private Integer maxCount;
private LocalDateTime createdAt;
private static final SweetActiveType obj = new SweetActiveType();
public static SweetActiveType getNew() {
try {
return (SweetActiveType) obj.clone();
} catch (CloneNotSupportedException e) {
return new SweetActiveType();
}
}
}
package com.liquidnet.service.sweet.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* type二维码表
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class SweetQrCode implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
/**
* Id
*/
private String qrCodeId;
/**
* 活动type类型
*/
private Integer type;
/**
* 二维码地址
*/
private String url;
/**
* 展示次数
*/
private Integer showNum;
/**
* 访问次数
*/
private Integer readNum;
private LocalDateTime createdAt;
private static final SweetQrCode obj = new SweetQrCode();
public static SweetQrCode getNew() {
try {
return (SweetQrCode) obj.clone();
} catch (CloneNotSupportedException e) {
return new SweetQrCode();
}
}
}
package com.liquidnet.service.sweet.mapper;
import com.liquidnet.service.sweet.entity.SweetActiveType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 活动type表 Mapper 接口
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
public interface SweetActiveTypeMapper extends BaseMapper<SweetActiveType> {
}
package com.liquidnet.service.sweet.mapper;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* type二维码表 Mapper 接口
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
public interface SweetQrCodeMapper extends BaseMapper<SweetQrCode> {
}
<?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.liquidnet.service.sweet.mapper.SweetActiveTypeMapper">
</mapper>
<?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.liquidnet.service.sweet.mapper.SweetQrCodeMapper">
</mapper>
......@@ -26,7 +26,7 @@ public class SweetMybatisPlusCodeGenerator {
// 全局配置BankMybatisPlusCodeGenerator
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(moduleRootPath + "/src/main/java");
gc.setAuthor("jiangxiulong");
gc.setAuthor("hujiachen");
gc.setOpen(false);
// gc.setSwagger2(true); 实体属性 Swagger2 注解
mpg.setGlobalConfig(gc);
......@@ -93,9 +93,9 @@ public class SweetMybatisPlusCodeGenerator {
dsc.setUsername("testmall");
dsc.setPassword("zhengzai!mYT");
String resourcePath = "/Users/jiangxiulong/Downloads/tmp";
String resourcePath = "/Users/hujiachen/Downloads/tmp";
String directory = "com.liquidnet.service.sweet";
String[] dbTableArray = new String[]{"sweet_integral_activity_prize_relation"};
String[] dbTableArray = new String[]{"sweet_active_type","sweet_qr_code"};
doGenerator(resourcePath, dsc, directory, dbTableArray);
......
package com.liquidnet.service.sweet.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.service.ISweetActiveTypeService;
import com.liquidnet.service.sweet.service.ISweetAnswerService;
import com.liquidnet.service.sweet.vo.SweetAnswerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 答题表 前端控制器
* </p>
*
* @author jiangxiulong
* @since 2021-08-12
*/
@Api(tags = "活动-二维码")
@RestController
@RequestMapping("/active")
public class SweetQrCodeController {
@Autowired
private ISweetActiveTypeService sweetActiveTypeService;
@GetMapping("qrCode/type")
@ApiOperation("获取二维码url")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "int", name = "type", value = "活动type", required = true)
})
public ResponseDto<String> getRandomQrCode(int type) {
return ResponseDto.success(sweetActiveTypeService.getRandomQrCode(type));
}
}
package com.liquidnet.service.sweet.service.impl;
import com.liquidnet.commons.lang.util.RandomUtil;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import com.liquidnet.service.sweet.service.ISweetActiveTypeService;
import com.liquidnet.service.sweet.utils.RedisDataUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class SweetActiveQrCodeServiceImpl implements ISweetActiveTypeService {
@Autowired
private RedisDataUtils redisDataUtils;
@Override
public String getRandomQrCode(int type) {
List<SweetQrCode> sweetQrCodeList = redisDataUtils.getQrCodeTypeNum(type);//SweetQrCodeList
SweetQrCode bean = judgeRandom(type, sweetQrCodeList);
if (bean == null) {
return "";
} else {
redisDataUtils.incrQrCodeShowNum(type, bean.getQrCodeId());//访问数量
return bean.getUrl();
}
}
//获取 可使用的随机数
private SweetQrCode judgeRandom(int type, List<SweetQrCode> sweetQrCodeList) {
int randomSwat = RandomUtil.getRandomInt(0, sweetQrCodeList.size());//随机到第几个
int showNum = redisDataUtils.getQrCodeShowNum(type, sweetQrCodeList.get(randomSwat).getQrCodeId());//访问数量
int maxNum = redisDataUtils.getQrCodeMaxNum(type);
if (showNum >= maxNum) {//超过阈值
sweetQrCodeList.remove(randomSwat);
if (sweetQrCodeList.size() == 0) {
return null;
}
return judgeRandom(type, sweetQrCodeList);
} else {
redisDataUtils.setQrCodeDetails(type, sweetQrCodeList);
return sweetQrCodeList.get(randomSwat);
}
}
}
package com.liquidnet.service.sweet.service.impl;
import com.liquidnet.service.sweet.entity.SweetQrCode;
import com.liquidnet.service.sweet.mapper.SweetQrCodeMapper;
import com.liquidnet.service.sweet.service.ISweetQrCodeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* type二维码表 服务实现类
* </p>
*
* @author hujiachen
* @since 2021-12-23
*/
@Service
public class SweetQrCodeServiceImpl implements ISweetQrCodeService {
}
......@@ -558,6 +558,7 @@ public class RedisDataUtils {
return collect;
}
}
public void setIntegralActivityDrawAll(String integralActivityId, List<SweetIntegralActivityDraw> sweetIntegralActivityDraws) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_ALL_LIST
.concat(integralActivityId);
......@@ -576,6 +577,7 @@ public class RedisDataUtils {
return (LinkedList<IntegralActivityDrawVo>) obj;
}
}
public void setIntegralActivityDrawList(String uid, String integralActivityId, List<IntegralActivityDrawVo> integralActivityDrawVos) {
List<IntegralActivityDrawVo> myList = integralActivityDrawVos.stream().collect(Collectors.toCollection(LinkedList::new));
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_IN_USER
......@@ -584,6 +586,7 @@ public class RedisDataUtils {
.concat(uid);
redisUtil.set(redisKey, myList);
}
public void delIntegralActivityDrawList(String uid, String integralActivityId) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_IN_USER
.concat(integralActivityId)
......@@ -671,6 +674,7 @@ public class RedisDataUtils {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_BLACK;
redisUtil.set(redisKey, uidS);
}
public List<String> getIntegralActivityDrawBlack() {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_BLACK;
Object obj = redisUtil.get(redisKey);
......@@ -680,10 +684,12 @@ public class RedisDataUtils {
return (List<String>) obj;
}
}
public void setIntegralActivityDrawWhite(List<String> uidS) {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_WHITE;
redisUtil.set(redisKey, uidS);
}
public List<String> getIntegralActivityDrawWhite() {
String redisKey = SweetConstant.REDIS_KEY_SWEET_INTEGRAL_ACTIVITY_DRAW_WHITE;
Object obj = redisUtil.get(redisKey);
......@@ -782,4 +788,45 @@ public class RedisDataUtils {
.concat(integralActivityId);
redisUtil.decr(redisKey, num);
}
public List<SweetQrCode> getQrCodeTypeNum(int type) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_LIST.concat(type + "");
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return new ArrayList<>();
} else {
return (List<SweetQrCode>) obj;
}
}
public void setQrCodeDetails(int type, List<SweetQrCode> data) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_LIST.concat(type + "");
redisUtil.set(redisKey, data);
}
public int getQrCodeShowNum(int type, String qrCodeId) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_SHOW_NUM.concat(type + "").concat(":qrCodeId:").concat(qrCodeId);
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return 0;
} else {
return (int) obj;
}
}
public void incrQrCodeShowNum(int type, String qrCodeId) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_SHOW_NUM.concat(type + "").concat(":qrCodeId:").concat(qrCodeId);
redisUtil.incr(redisKey, 1);
}
public int getQrCodeMaxNum(int type) {
String redisKey = SweetConstant.REDIS_KEY_QRCODE_MAX_NUM.concat(type + "");
Object obj = redisUtil.get(redisKey);
if (obj == null) {
return 0;
} else {
return (int) 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