add 会议随机码 新增,编辑更换逻辑为全量处理
This commit is contained in:
+5
-1
@@ -17,4 +17,8 @@ create table pay_random_code_link
|
||||
random_code_id varchar(36) not null comment 'random_code_id',
|
||||
random_code varchar(6) null comment '随机码',
|
||||
use_flag tinyint(1) default 0 comment '是否使用'
|
||||
) comment '随机码关联表';
|
||||
) comment '随机码关联表';
|
||||
|
||||
INSERT INTO sys_dict ( id, dict_name, dict_code, description, del_flag, create_by, create_time ) VALUES ( '1539122073714880513', '使用状态', 'use_flag', '', 0, 'LKGLZ', '2022-06-21 13:44:32' );
|
||||
INSERT INTO sys_dict_item ( id, dict_id, item_text, item_value, description, sort_order, status, create_by, create_time ) VALUES ( '1539122136461668354', '1539122073714880513', '未使用', '0', '', 1, 1, 'LKGLZ', '2022-06-21 13:44:47' );
|
||||
INSERT INTO sys_dict_item ( id, dict_id, item_text, item_value, description, sort_order, status, create_by, create_time ) VALUES ( '1539122172666900482', '1539122073714880513', '已使用', '1', '', 2, 1, 'LKGLZ', '2022-06-21 13:44:56' );
|
||||
+8
-16
@@ -10,7 +10,9 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.jero.meeting.vo.GenerateDTO;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
@@ -109,21 +111,11 @@ public class PayRandomCodeController extends JeroController<PayRandomCode, PayR
|
||||
@AutoLog(value = "随机码表-生成")
|
||||
@ApiOperation(value="随机码表-生成", notes="随机码表-生成")
|
||||
@PostMapping(value = "/generate")
|
||||
public Result<?> generate(@Validated @RequestBody PayRandomCode randomCode) {
|
||||
payRandomCodeService.generate(randomCode);
|
||||
return Result.OK("生成成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加
|
||||
*/
|
||||
@RequiresPermissions("internationalSeminarGenerateCode:edit")
|
||||
@AutoLog(value = "随机码表-追加")
|
||||
@ApiOperation(value="随机码表-追加", notes="随机码表-追加")
|
||||
@PostMapping(value = "/additional")
|
||||
public Result<?> additional(@Validated @RequestBody PayRandomCode randomCode) {
|
||||
payRandomCodeService.additional(randomCode);
|
||||
return Result.OK("追加成功!");
|
||||
public Result<List<PayRandomCodeLink>> generate(@Validated @RequestBody GenerateDTO generateDTO) {
|
||||
PayRandomCode randomCode = new PayRandomCode();
|
||||
BeanUtils.copyProperties(generateDTO,randomCode);
|
||||
List<PayRandomCodeLink> generate = payRandomCodeService.generate(randomCode);
|
||||
return Result.OK(generate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +125,7 @@ public class PayRandomCodeController extends JeroController<PayRandomCode, PayR
|
||||
@ApiOperation(value="随机码表-导出excel")
|
||||
@GetMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, PayRandomCode randomCode) {
|
||||
return super.exportXls(request, randomCode, PayRandomCode.class, "");
|
||||
return super.exportXls(request, randomCode, PayRandomCode.class, "随机码表");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PayRandomCode {
|
||||
*/
|
||||
@TableField(value = "meeting_id")
|
||||
@ApiModelProperty(value="会议id")
|
||||
private Integer meeting_id;
|
||||
private Integer meetingId;
|
||||
|
||||
/**
|
||||
* 嘉宾类型
|
||||
|
||||
+4
-4
@@ -45,11 +45,11 @@ public class PayRandomCodeLink {
|
||||
private String randomCode;
|
||||
|
||||
/**
|
||||
* 是否使用
|
||||
* 使用状态
|
||||
*/
|
||||
@TableField(value = "use_flag")
|
||||
@Excel(name = "使用个数", width = 15, dicCode = "yn")
|
||||
@Dict(dicCode = "yn")
|
||||
@ApiModelProperty(value="是否使用")
|
||||
@Excel(name = "状态", width = 15, dicCode = "use_flag")
|
||||
@Dict(dicCode = "use_flag")
|
||||
@ApiModelProperty(value="使用状态")
|
||||
private Integer useFlag;
|
||||
}
|
||||
+68
-12
@@ -1,12 +1,19 @@
|
||||
package com.jero.meeting.service;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.meeting.entity.PayRandomCodeLink;
|
||||
import com.jero.meeting.mapper.PayRandomCodeLinkMapper;
|
||||
import net.sf.saxon.om.Item;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.meeting.mapper.PayRandomCodeMapper;
|
||||
import com.jero.meeting.entity.PayRandomCode;
|
||||
@@ -25,26 +32,75 @@ public class PayRandomCodeService extends ServiceImpl<PayRandomCodeMapper, PayRa
|
||||
public void add(PayRandomCode randomCode) {
|
||||
randomCodeMapper.insert(randomCode);
|
||||
String randomCodeId = randomCode.getRandomCodeId();
|
||||
List<PayRandomCodeLink> randomCodeLinkList = new ArrayList<>();
|
||||
for (Integer i = 0; i < randomCode.getRandomCodeCount(); i++) {
|
||||
PayRandomCodeLink randomCodeLink = new PayRandomCodeLink();
|
||||
List<PayRandomCodeLink> randomCodeLinkList = randomCode.getRandomCodeLinkList();
|
||||
for (PayRandomCodeLink randomCodeLink : randomCodeLinkList) {
|
||||
randomCodeLink.setRandomCodeId(randomCodeId);
|
||||
randomCodeLink.setRandomCode(RandomUtil.randomString(6));
|
||||
randomCodeLinkList.add(randomCodeLink);
|
||||
}
|
||||
randomCodeLinkMapper.insertList(randomCodeLinkList);
|
||||
|
||||
}
|
||||
|
||||
public void editById(PayRandomCode randomCode) {
|
||||
|
||||
randomCodeMapper.updateById(randomCode);
|
||||
String randomCodeId = randomCode.getRandomCodeId();
|
||||
//先删除未使用的
|
||||
LambdaQueryWrapper<PayRandomCodeLink> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PayRandomCodeLink::getRandomCodeId,randomCodeId);
|
||||
wrapper.eq(PayRandomCodeLink::getUseFlag, CommonConstant.DEL_FLAG_0);
|
||||
randomCodeLinkMapper.delete(wrapper);
|
||||
//查询已使用code
|
||||
wrapper.clear();
|
||||
List<PayRandomCodeLink> useRandomCodeLinkList = randomCodeLinkMapper.selectList(wrapper);
|
||||
List<String> useCodeList = useRandomCodeLinkList.stream()
|
||||
.map(PayRandomCodeLink::getRandomCode)
|
||||
.collect(Collectors.toList());
|
||||
//处理新增的数据
|
||||
List<PayRandomCodeLink> allRandomCodeLinkList = randomCode.getRandomCodeLinkList();
|
||||
allRandomCodeLinkList.forEach(item ->{
|
||||
String randomCode1 = item.getRandomCode();
|
||||
//如果在已使用中,就赋值为1
|
||||
if (useCodeList.contains(randomCode1)) {
|
||||
item.setUseFlag(CommonConstant.DEL_FLAG_1);
|
||||
}else {
|
||||
item.setUseFlag(CommonConstant.DEL_FLAG_0);
|
||||
}
|
||||
});
|
||||
//筛选出未使用code
|
||||
List<PayRandomCodeLink> unUseList = allRandomCodeLinkList.stream()
|
||||
.filter(one -> Objects.equals(one.getUseFlag(), CommonConstant.DEL_FLAG_0))
|
||||
.collect(Collectors.toList());
|
||||
for (PayRandomCodeLink randomCodeLink : unUseList) {
|
||||
randomCodeLink.setRandomCodeId(randomCodeId);
|
||||
}
|
||||
randomCodeLinkMapper.insertList(unUseList);
|
||||
}
|
||||
|
||||
public void generate(PayRandomCode randomCode) {
|
||||
|
||||
/**
|
||||
* 生成
|
||||
*/
|
||||
public List<PayRandomCodeLink> generate(PayRandomCode randomCode) {
|
||||
String randomCodeId = randomCode.getRandomCodeId();
|
||||
List<PayRandomCodeLink> randomCodeLinkList = new ArrayList<>();
|
||||
//根据id判断是新增还是编辑
|
||||
if (StringUtils.isBlank(randomCodeId)){
|
||||
for (int i = 0; i < randomCode.getRandomCodeCount(); i++) {
|
||||
PayRandomCodeLink randomCodeLink = new PayRandomCodeLink();
|
||||
randomCodeLink.setRandomCode(RandomUtil.randomString(6));
|
||||
randomCodeLinkList.add(randomCodeLink);
|
||||
}
|
||||
return randomCodeLinkList;
|
||||
}else {
|
||||
LambdaQueryWrapper<PayRandomCodeLink> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PayRandomCodeLink::getRandomCodeId,randomCodeId);
|
||||
wrapper.eq(PayRandomCodeLink::getUseFlag, CommonConstant.DEL_FLAG_1);
|
||||
List<PayRandomCodeLink> useList = randomCodeLinkMapper.selectList(wrapper);
|
||||
randomCodeLinkList.addAll(useList);
|
||||
for (int i = 0; i < randomCode.getRandomCodeCount() - useList.size(); i++) {
|
||||
PayRandomCodeLink randomCodeLink = new PayRandomCodeLink();
|
||||
randomCodeLink.setRandomCode(RandomUtil.randomString(6));
|
||||
randomCodeLinkList.add(randomCodeLink);
|
||||
}
|
||||
return randomCodeLinkList;
|
||||
}
|
||||
}
|
||||
|
||||
public void additional(PayRandomCode randomCode) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jero.meeting.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2022-06-21 11:45
|
||||
*/
|
||||
@Data
|
||||
public class GenerateDTO {
|
||||
@ApiModelProperty(value="id")
|
||||
private String randomCodeId;
|
||||
/**
|
||||
* 随机码个数
|
||||
*/
|
||||
@ApiModelProperty(value="随机码个数")
|
||||
private Integer randomCodeCount;
|
||||
}
|
||||
Reference in New Issue
Block a user