51 changed files with 2085 additions and 34 deletions
@ -0,0 +1,73 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.utils; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import java.awt.image.BufferedImage; |
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.File; |
||||
|
import java.io.FileInputStream; |
||||
|
import java.io.IOException; |
||||
|
|
||||
|
/** |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date |
||||
|
*/ |
||||
|
public class FileUtils { |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* File文件转为byte[] |
||||
|
* |
||||
|
* @param file |
||||
|
* @return byte[] |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2019/9/19 15:56 |
||||
|
*/ |
||||
|
public static byte[] fileToByteArray(File file) { |
||||
|
try { |
||||
|
//获取输入流
|
||||
|
FileInputStream fis = new FileInputStream(file); |
||||
|
//新的 byte 数组输出流,缓冲区容量1024byte
|
||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); |
||||
|
//缓存
|
||||
|
byte[] b = new byte[1024]; |
||||
|
int n; |
||||
|
while ((n = fis.read(b)) != NumConstant.ONE_NEG) { |
||||
|
bos.write(b, NumConstant.ZERO, n); |
||||
|
} |
||||
|
fis.close(); |
||||
|
//改变为byte[]
|
||||
|
byte[] data = bos.toByteArray(); |
||||
|
bos.close(); |
||||
|
return data; |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* BufferedImage文件转为byte[] |
||||
|
* |
||||
|
* @param bImage 图片 |
||||
|
* @param formatName 格式 e.g. png |
||||
|
* @return byte[] |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2020/8/7 13:30 |
||||
|
*/ |
||||
|
public static byte[] imageToBytes(BufferedImage bImage, String formatName) { |
||||
|
if (null == bImage || StringUtils.isBlank(formatName)) { |
||||
|
return null; |
||||
|
} |
||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
|
try { |
||||
|
ImageIO.write(bImage, formatName, out); |
||||
|
} catch (IOException e) { |
||||
|
//log.error(e.getMessage());
|
||||
|
} |
||||
|
return out.toByteArray(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,224 @@ |
|||||
|
package com.elink.esua.epdc.commons.tools.utils; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
||||
|
import com.google.zxing.BarcodeFormat; |
||||
|
import com.google.zxing.EncodeHintType; |
||||
|
import com.google.zxing.MultiFormatWriter; |
||||
|
import com.google.zxing.common.BitMatrix; |
||||
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.codec.CharEncoding; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import java.awt.*; |
||||
|
import java.awt.geom.RoundRectangle2D; |
||||
|
import java.awt.image.BufferedImage; |
||||
|
import java.io.File; |
||||
|
import java.io.InputStream; |
||||
|
import java.io.OutputStream; |
||||
|
import java.net.URL; |
||||
|
import java.util.Hashtable; |
||||
|
|
||||
|
/** |
||||
|
* 二维码工具类 |
||||
|
* |
||||
|
* @author yujintao |
||||
|
* @date 2018/11/12 14:49 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
public class QrCodeUtils { |
||||
|
|
||||
|
/** |
||||
|
* 二维码尺寸 |
||||
|
*/ |
||||
|
private static final int QRCODE_SIZE = 800; |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码图片,并转为byte[] |
||||
|
* |
||||
|
* @param content 二维码内的信息 |
||||
|
* @param imgPath logo地址 |
||||
|
* @param needCompress 是否压缩logo |
||||
|
* @return java.awt.image.BufferedImage |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2020/8/7 10:58 |
||||
|
*/ |
||||
|
public static byte[] encodeByByte(String content, String imgPath, boolean needCompress) { |
||||
|
return FileUtils.imageToBytes(encodeByImage(content, imgPath, needCompress), StrConstant.SUFFIX_IMG_PNG); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码图片 |
||||
|
* |
||||
|
* @param content 二维码内的信息 |
||||
|
* @param imgPath logo地址 |
||||
|
* @param needCompress 是否压缩logo |
||||
|
* @return java.awt.image.BufferedImage |
||||
|
* @author work@yujt.net.cn |
||||
|
* @date 2020/8/7 10:58 |
||||
|
*/ |
||||
|
public static BufferedImage encodeByImage(String content, String imgPath, boolean needCompress) { |
||||
|
BufferedImage image = null; |
||||
|
try { |
||||
|
image = QrCodeUtils.createImage(content, imgPath, needCompress); |
||||
|
} catch (Exception e) { |
||||
|
log.error("创建二维码失败,\n content={} \n imagePath={}", content, imgPath); |
||||
|
} |
||||
|
return image; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 生成二维码(内嵌LOGO),选择是否压缩logo,直接存入指定文件目录 |
||||
|
* |
||||
|
* @param content 内容 |
||||
|
* @param imgPath LOGO地址 |
||||
|
* @param destPath 存放目录 |
||||
|
* @param needCompress 是否压缩LOGO |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void encode(String content, String imgPath, String destPath, boolean needCompress) throws Exception { |
||||
|
BufferedImage image = QrCodeUtils.createImage(content, imgPath, needCompress); |
||||
|
mkdirs(destPath); |
||||
|
ImageIO.write(image, StrConstant.SUFFIX_IMG_PNG, new File(destPath)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码(内嵌LOGO),不压缩logo,直接存入指定目录 |
||||
|
* |
||||
|
* @param content 内容 |
||||
|
* @param imgPath LOGO地址 |
||||
|
* @param destPath 存储地址 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void encode(String content, String imgPath, String destPath) throws Exception { |
||||
|
QrCodeUtils.encode(content, imgPath, destPath, false); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码,不插入logo |
||||
|
* |
||||
|
* @param content 内容 |
||||
|
* @param destPath 存储地址 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void encode(String content, String destPath) throws Exception { |
||||
|
QrCodeUtils.encode(content, null, destPath, false); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码(内嵌LOGO) |
||||
|
* |
||||
|
* @param content 内容 |
||||
|
* @param imgPath LOGO地址 |
||||
|
* @param output 输出流 |
||||
|
* @param needCompress 是否压缩LOGO |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void encode(String content, String imgPath, OutputStream output, boolean needCompress) |
||||
|
throws Exception { |
||||
|
BufferedImage image = QrCodeUtils.createImage(content, imgPath, needCompress); |
||||
|
ImageIO.write(image, StrConstant.SUFFIX_IMG_PNG, output); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码 |
||||
|
* |
||||
|
* @param content 内容 |
||||
|
* @param output 输出流 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void encode(String content, OutputStream output) throws Exception { |
||||
|
QrCodeUtils.encode(content, null, output, false); |
||||
|
} |
||||
|
|
||||
|
private static BufferedImage createImage(String content, String imgPath, boolean needCompress) throws Exception { |
||||
|
Hashtable<EncodeHintType, Object> hints = new Hashtable(); |
||||
|
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H); |
||||
|
hints.put(EncodeHintType.CHARACTER_SET, CharEncoding.UTF_8); |
||||
|
hints.put(EncodeHintType.MARGIN, 1); |
||||
|
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, QRCODE_SIZE, QRCODE_SIZE, |
||||
|
hints); |
||||
|
int width = bitMatrix.getWidth(); |
||||
|
int height = bitMatrix.getHeight(); |
||||
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
||||
|
for (int x = 0; x < width; x++) { |
||||
|
for (int y = 0; y < height; y++) { |
||||
|
image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF); |
||||
|
} |
||||
|
} |
||||
|
if (StringUtils.isBlank(imgPath)) { |
||||
|
return image; |
||||
|
} |
||||
|
// 插入logo图片
|
||||
|
QrCodeUtils.insertImage(image, imgPath, needCompress); |
||||
|
return image; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 插入LOGO |
||||
|
* |
||||
|
* @param source 二维码图片 |
||||
|
* @param imgPath LOGO图片地址 |
||||
|
* @param needCompress 是否压缩 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
private static void insertImage(BufferedImage source, String imgPath, boolean needCompress) throws Exception { |
||||
|
|
||||
|
URL url = new URL(imgPath); |
||||
|
InputStream is = url.openConnection().getInputStream(); |
||||
|
|
||||
|
Image src = ImageIO.read(is); |
||||
|
int width = src.getWidth(null); |
||||
|
int height = src.getHeight(null); |
||||
|
// 压缩LOGO
|
||||
|
if (needCompress) { |
||||
|
// 限制最大LOGO宽度
|
||||
|
int maxWidth = QRCODE_SIZE / 4; |
||||
|
// 限制最大LOGO高度
|
||||
|
int maxHeight = QRCODE_SIZE / 4; |
||||
|
|
||||
|
if (width > maxWidth) { |
||||
|
width = maxWidth; |
||||
|
} |
||||
|
if (height > maxHeight) { |
||||
|
height = maxHeight; |
||||
|
} |
||||
|
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH); |
||||
|
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
||||
|
Graphics g = tag.getGraphics(); |
||||
|
// 绘制缩小后的图
|
||||
|
g.drawImage(image, 0, 0, null); |
||||
|
g.dispose(); |
||||
|
src = image; |
||||
|
} |
||||
|
// 插入LOGO
|
||||
|
Graphics2D graph = source.createGraphics(); |
||||
|
int x = (QRCODE_SIZE - width) / 2; |
||||
|
int y = (QRCODE_SIZE - height) / 2; |
||||
|
graph.drawImage(src, x, y, width, height, null); |
||||
|
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6); |
||||
|
graph.setStroke(new BasicStroke(3f)); |
||||
|
graph.draw(shape); |
||||
|
graph.dispose(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常) |
||||
|
* |
||||
|
* @param destPath 存放目录 |
||||
|
* @author lanyuan Email: mmm333zzz520@163.com |
||||
|
* @date 2013-12-11 上午10:16:36 |
||||
|
*/ |
||||
|
private static void mkdirs(String destPath) { |
||||
|
File file = new File(destPath); |
||||
|
// 当文件夹不存在时,mkdirs会自动创建多层目录,区别于mkdir.(mkdir如果父目录不存在则会抛出异常)
|
||||
|
if (!file.exists() && !file.isDirectory()) { |
||||
|
file.mkdirs(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.elink.esua.epdc.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.Min; |
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 积分核销表单 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:47 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EpdcWorkPointsVerificationFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 499510543162448451L; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
@NotBlank(message = "用户ID不能为空") |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 积分操作类型 0-减积分,1-加积分 |
||||
|
*/ |
||||
|
@NotBlank(message = "积分操作类型不能为空") |
||||
|
private String operationType; |
||||
|
|
||||
|
/** |
||||
|
* 操作积分值 |
||||
|
*/ |
||||
|
@Min(value = 1, message = "操作积分值必须大于0") |
||||
|
private Integer points; |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
package com.elink.esua.epdc.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.Min; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 工作端获取核销记录formDTO |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 16:59 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EpdcWorkVerificationLogsFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -2519917462142795840L; |
||||
|
|
||||
|
/** |
||||
|
* 页码 |
||||
|
*/ |
||||
|
@Min(value = 1, message = "页码必须大于0") |
||||
|
private Integer pageIndex; |
||||
|
|
||||
|
/** |
||||
|
* 页容量 |
||||
|
*/ |
||||
|
@Min(value = 1, message = "页容量必须大于0") |
||||
|
private Integer pageSize; |
||||
|
|
||||
|
/** |
||||
|
* 开始时间 |
||||
|
*/ |
||||
|
private String startTime; |
||||
|
|
||||
|
/** |
||||
|
* 结束时间 |
||||
|
*/ |
||||
|
private String endTime; |
||||
|
|
||||
|
/** |
||||
|
* 部门ID |
||||
|
*/ |
||||
|
private Long deptId; |
||||
|
|
||||
|
/** |
||||
|
* 当前用户所属部门ID |
||||
|
*/ |
||||
|
private Long currentUserDeptId; |
||||
|
|
||||
|
/** |
||||
|
* 操作方式 user-用户操作,admin-管理员操作,sys-系统操作, work_jfhx-工作端-扫描兑换码-积分核销 |
||||
|
*/ |
||||
|
private String operationMode; |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.elink.esua.epdc.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.Min; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 查询积分记录 表单 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 14:08 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class PointsExchangeLogsFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 7021642608531330184L; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 积分动作编码 |
||||
|
*/ |
||||
|
private String behaviorCode; |
||||
|
|
||||
|
/** |
||||
|
* 页码 |
||||
|
*/ |
||||
|
@Min(value = 1, message = "页码必须大于0") |
||||
|
private Integer pageIndex; |
||||
|
|
||||
|
/** |
||||
|
* 页容量 |
||||
|
*/ |
||||
|
@Min(value = 1, message = "页容量必须大于0") |
||||
|
private Integer pageSize; |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.elink.esua.epdc.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 核销记录 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 17:36 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EpdcVerificationLogsResultDTO<T> implements Serializable { |
||||
|
private static final long serialVersionUID = -6338967854031776740L; |
||||
|
|
||||
|
/** |
||||
|
* 核销总积分 |
||||
|
*/ |
||||
|
private Integer pointsTotal; |
||||
|
|
||||
|
/** |
||||
|
* 核销记录 |
||||
|
*/ |
||||
|
private List<T> verificationLogs; |
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.common.token.dto.TokenDto; |
||||
|
import com.elink.esua.epdc.commons.tools.annotation.LoginUser; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.form.PointsExchangeLogsFormDTO; |
||||
|
import com.elink.esua.epdc.pointcommons.tools.dto.PointsLogsResultDTO; |
||||
|
import com.elink.esua.epdc.service.UserPointsVerificationService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销模块 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:47 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("userpointsverification") |
||||
|
public class ApiUserPointsVerificationController { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserPointsVerificationService userPointsVerificationService; |
||||
|
|
||||
|
/** |
||||
|
* 获取积分核销兑换码 |
||||
|
* |
||||
|
* @param userDetail 用户信息 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:54 |
||||
|
*/ |
||||
|
@GetMapping("getqrcode") |
||||
|
public Result<UserPointsVerificationResultDTO> getQRCode(@LoginUser TokenDto userDetail) { |
||||
|
if (null == userDetail || StringUtils.isEmpty(userDetail.getUserId())) { |
||||
|
return new Result<UserPointsVerificationResultDTO>().error("获取用户信息失败,请稍后重试"); |
||||
|
} |
||||
|
|
||||
|
return userPointsVerificationService.getQRCode(userDetail.getUserId()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取用户积分记录 |
||||
|
* |
||||
|
* @param userDetail 用户信息 |
||||
|
* @param formDto 表单 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.pointcommons.tools.dto.PointsLogsResultDTO>> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 14:16 |
||||
|
*/ |
||||
|
@GetMapping("getpointslogs") |
||||
|
public Result<List<PointsLogsResultDTO>> getPointsLogs(@LoginUser TokenDto userDetail, @RequestBody PointsExchangeLogsFormDTO formDto) { |
||||
|
ValidatorUtils.validateEntity(formDto); |
||||
|
formDto.setUserId(userDetail.getUserId()); |
||||
|
|
||||
|
return userPointsVerificationService.listOfPointsLogs(formDto); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.dto.SysDeptDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsVerificationCheckFormDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.form.EpdcWorkPointsVerificationFormDTO; |
||||
|
import com.elink.esua.epdc.dto.form.EpdcWorkVerificationLogsFormDTO; |
||||
|
import com.elink.esua.epdc.dto.result.EpdcVerificationLogsResultDTO; |
||||
|
import com.elink.esua.epdc.service.UserPointsVerificationService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 工作端用户积分核销模块 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:47 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("work/pointsverification") |
||||
|
public class ApiWorkPointsVerificationController { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserPointsVerificationService userPointsVerificationService; |
||||
|
|
||||
|
/** |
||||
|
* 扫描兑换码获取用户信息接口 |
||||
|
* |
||||
|
* @param formDto 码ID |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:03 |
||||
|
*/ |
||||
|
@PostMapping("getuserinfobycode") |
||||
|
public Result<EpdcUserPointsVerificationResultDTO> getUserInfoByCode(@RequestBody EpdcUserPointsVerificationCheckFormDTO formDto) { |
||||
|
ValidatorUtils.validateEntity(formDto); |
||||
|
return userPointsVerificationService.getUserInfoByCode(formDto); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 积分核销 |
||||
|
* |
||||
|
* @param formDto 表单 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:52 |
||||
|
*/ |
||||
|
@PostMapping("pointsverification") |
||||
|
public Result pointsVerification(@RequestBody EpdcWorkPointsVerificationFormDTO formDto) { |
||||
|
ValidatorUtils.validateEntity(formDto); |
||||
|
|
||||
|
return userPointsVerificationService.pointsVerification(formDto); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 工作端-核销记录 |
||||
|
* |
||||
|
* @param formDto 表单 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.pointcommons.tools.dto.PointsLogsResultDTO>> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 17:00 |
||||
|
*/ |
||||
|
@GetMapping("verificationlogs") |
||||
|
public Result<EpdcVerificationLogsResultDTO> verificationLogs(@RequestBody EpdcWorkVerificationLogsFormDTO formDto) { |
||||
|
ValidatorUtils.validateEntity(formDto); |
||||
|
|
||||
|
return userPointsVerificationService.listOfVerificationLogs(formDto); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据机构类型获取机构数据 |
||||
|
* |
||||
|
* @param typeKey 机构类型 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<com.elink.esua.epdc.dto.SysDeptDTO>> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/20 9:58 |
||||
|
*/ |
||||
|
@GetMapping("getdeptinfo/{typeKey}") |
||||
|
public Result<List<SysDeptDTO>> getDeptInfoByTypeKey(@PathVariable String typeKey) { |
||||
|
return userPointsVerificationService.listOfDeptInfoByTypeKey(typeKey); |
||||
|
} |
||||
|
} |
@ -0,0 +1,83 @@ |
|||||
|
package com.elink.esua.epdc.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.SysDeptDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsVerificationCheckFormDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.form.EpdcWorkPointsVerificationFormDTO; |
||||
|
import com.elink.esua.epdc.dto.form.EpdcWorkVerificationLogsFormDTO; |
||||
|
import com.elink.esua.epdc.dto.form.PointsExchangeLogsFormDTO; |
||||
|
import com.elink.esua.epdc.dto.result.EpdcVerificationLogsResultDTO; |
||||
|
import com.elink.esua.epdc.pointcommons.tools.dto.PointsLogsResultDTO; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:48 |
||||
|
*/ |
||||
|
public interface UserPointsVerificationService { |
||||
|
|
||||
|
/** |
||||
|
* 获取积分核销兑换码 |
||||
|
* |
||||
|
* @param userId 用户ID |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:57 |
||||
|
*/ |
||||
|
Result<UserPointsVerificationResultDTO> getQRCode(String userId); |
||||
|
|
||||
|
/** |
||||
|
* 获取用户积分记录 |
||||
|
* |
||||
|
* @param formDto 表单 |
||||
|
* @return java.util.List<com.elink.esua.epdc.pointcommons.tools.dto.PointsLogsResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 14:17 |
||||
|
*/ |
||||
|
Result<List<PointsLogsResultDTO>> listOfPointsLogs(PointsExchangeLogsFormDTO formDto); |
||||
|
|
||||
|
/** |
||||
|
* 扫描兑换码获取用户信息接口 |
||||
|
* |
||||
|
* @param formDto 码ID |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:04 |
||||
|
*/ |
||||
|
Result<EpdcUserPointsVerificationResultDTO> getUserInfoByCode(EpdcUserPointsVerificationCheckFormDTO formDto); |
||||
|
|
||||
|
/** |
||||
|
* 积分核销 |
||||
|
* |
||||
|
* @param formDto 表单 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:53 |
||||
|
*/ |
||||
|
Result pointsVerification(EpdcWorkPointsVerificationFormDTO formDto); |
||||
|
|
||||
|
/** |
||||
|
* 工作端-核销记录 |
||||
|
* |
||||
|
* @param formDto 表单 |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 17:41 |
||||
|
*/ |
||||
|
Result<EpdcVerificationLogsResultDTO> listOfVerificationLogs(EpdcWorkVerificationLogsFormDTO formDto); |
||||
|
|
||||
|
/** |
||||
|
* 根据机构类型获取机构数据 |
||||
|
* |
||||
|
* @param typeKey 机构类型 |
||||
|
* @return java.util.List<com.elink.esua.epdc.dto.SysDeptDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/20 9:59 |
||||
|
*/ |
||||
|
Result<List<SysDeptDTO>> listOfDeptInfoByTypeKey(String typeKey); |
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
||||
|
import com.elink.esua.epdc.commons.tools.security.user.SecurityUser; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.SysDeptDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsVerificationCheckFormDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.form.EpdcWorkPointsVerificationFormDTO; |
||||
|
import com.elink.esua.epdc.dto.form.EpdcWorkVerificationLogsFormDTO; |
||||
|
import com.elink.esua.epdc.dto.form.PointsExchangeLogsFormDTO; |
||||
|
import com.elink.esua.epdc.dto.result.EpdcVerificationLogsResultDTO; |
||||
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
||||
|
import com.elink.esua.epdc.feign.PointsFeignClient; |
||||
|
import com.elink.esua.epdc.feign.UserFeignClient; |
||||
|
import com.elink.esua.epdc.pointcommons.tools.dto.PointsLogsResultDTO; |
||||
|
import com.elink.esua.epdc.service.UserPointsVerificationService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:49 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class UserPointsVerificationServiceImpl implements UserPointsVerificationService { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserFeignClient userFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private PointsFeignClient pointsFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private AdminFeignClient adminFeignClient; |
||||
|
|
||||
|
@Override |
||||
|
public Result<UserPointsVerificationResultDTO> getQRCode(String userId) { |
||||
|
return userFeignClient.getQRCode(userId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<List<PointsLogsResultDTO>> listOfPointsLogs(PointsExchangeLogsFormDTO formDto) { |
||||
|
return pointsFeignClient.getPointsLogs(formDto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<EpdcUserPointsVerificationResultDTO> getUserInfoByCode(EpdcUserPointsVerificationCheckFormDTO formDto) { |
||||
|
return userFeignClient.getUserInfoByCode(formDto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result pointsVerification(EpdcWorkPointsVerificationFormDTO formDto) { |
||||
|
return pointsFeignClient.pointsVerification(formDto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<EpdcVerificationLogsResultDTO> listOfVerificationLogs(EpdcWorkVerificationLogsFormDTO formDto) { |
||||
|
return pointsFeignClient.verificationLogs(formDto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<List<SysDeptDTO>> listOfDeptInfoByTypeKey(String typeKey) { |
||||
|
return adminFeignClient.getDeptInfoByTypeKey(typeKey); |
||||
|
} |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dto; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-01-18 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserPointsVerificationQrCodeDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 二维码地址 |
||||
|
*/ |
||||
|
private String codeUrl; |
||||
|
|
||||
|
/** |
||||
|
* 删除标记:0-否,1-是 |
||||
|
*/ |
||||
|
private String delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.elink.esua.epdc.dto.epdc.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 兑换码校验表单 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/20 11:08 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EpdcUserPointsVerificationCheckFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -5573771550554955607L; |
||||
|
|
||||
|
/** |
||||
|
* 兑换码ID |
||||
|
*/ |
||||
|
@NotBlank(message = "兑换码ID不能为空") |
||||
|
private String qrCodeId; |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.elink.esua.epdc.dto.epdc.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 用户信息 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 14:58 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class EpdcUserPointsVerificationResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 8116531573516487358L; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 用户真实姓名 |
||||
|
*/ |
||||
|
private String realName; |
||||
|
|
||||
|
/** |
||||
|
* 用户头像 |
||||
|
*/ |
||||
|
private String faceImg; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分 |
||||
|
*/ |
||||
|
private Integer points; |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.elink.esua.epdc.dto.epdc.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:51 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class UserPointsVerificationResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 567506783648999124L; |
||||
|
|
||||
|
/** |
||||
|
* 二维码地址 |
||||
|
*/ |
||||
|
private String codeUrl; |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.annotation.LoginUser; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.Constant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.dto.epdc.form.EpdcUserPointsVerificationCheckFormDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.service.UserPointsVerificationQrCodeService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销兑换码 接口 |
||||
|
* |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 11:03 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping(Constant.EPDC_APP + "verificationqrcode") |
||||
|
public class EpdcAppUserPointsVerificationQrCodeController { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserPointsVerificationQrCodeService userPointsVerificationQrCodeService; |
||||
|
|
||||
|
/** |
||||
|
* 获取积分核销兑换码 |
||||
|
* |
||||
|
* @param userId 用户ID |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 10:54 |
||||
|
*/ |
||||
|
@GetMapping("getqrcode/{userId}") |
||||
|
public Result<UserPointsVerificationResultDTO> getQRCode(@PathVariable String userId) { |
||||
|
UserPointsVerificationResultDTO data = userPointsVerificationQrCodeService.generatePointsVerificationQRCode(userId); |
||||
|
return new Result<UserPointsVerificationResultDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 扫描兑换码获取用户信息接口 |
||||
|
* |
||||
|
* @param formDto 码ID |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO> |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:09 |
||||
|
*/ |
||||
|
@PostMapping("getuserinfobycode") |
||||
|
public Result<EpdcUserPointsVerificationResultDTO> getUserInfoByCode(@RequestBody EpdcUserPointsVerificationCheckFormDTO formDto) { |
||||
|
ValidatorUtils.validateEntity(formDto); |
||||
|
EpdcUserPointsVerificationResultDTO data = userPointsVerificationQrCodeService.getUserInfoByCode(formDto.getQrCodeId()); |
||||
|
|
||||
|
return new Result<EpdcUserPointsVerificationResultDTO>().ok(data); |
||||
|
} |
||||
|
} |
@ -0,0 +1,84 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.controller; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.elink.esua.epdc.dto.UserPointsVerificationQrCodeDTO; |
||||
|
import com.elink.esua.epdc.service.UserPointsVerificationQrCodeService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-01-18 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("userpointsverificationqrcode") |
||||
|
public class UserPointsVerificationQrCodeController { |
||||
|
|
||||
|
@Autowired |
||||
|
private UserPointsVerificationQrCodeService userPointsVerificationQrCodeService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<UserPointsVerificationQrCodeDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<UserPointsVerificationQrCodeDTO> page = userPointsVerificationQrCodeService.page(params); |
||||
|
return new Result<PageData<UserPointsVerificationQrCodeDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<UserPointsVerificationQrCodeDTO> get(@PathVariable("id") String id){ |
||||
|
UserPointsVerificationQrCodeDTO data = userPointsVerificationQrCodeService.get(id); |
||||
|
return new Result<UserPointsVerificationQrCodeDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody UserPointsVerificationQrCodeDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
userPointsVerificationQrCodeService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody UserPointsVerificationQrCodeDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
userPointsVerificationQrCodeService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
userPointsVerificationQrCodeService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.dao; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import com.elink.esua.epdc.entity.UserPointsVerificationQrCodeEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-01-18 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface UserPointsVerificationQrCodeDao extends BaseDao<UserPointsVerificationQrCodeEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 根据用户ID删除兑换码 |
||||
|
* |
||||
|
* @param userId 用户ID |
||||
|
* @return void |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 13:52 |
||||
|
*/ |
||||
|
void deleteByUserId(String userId); |
||||
|
|
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-01-18 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_user_points_verification_qr_code") |
||||
|
public class UserPointsVerificationQrCodeEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 用户ID |
||||
|
*/ |
||||
|
private String userId; |
||||
|
|
||||
|
/** |
||||
|
* 二维码地址 |
||||
|
*/ |
||||
|
private String codeUrl; |
||||
|
|
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
package com.elink.esua.epdc.feign; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.UploadFormDTO; |
||||
|
import com.elink.esua.epdc.dto.UploadToOssDTO; |
||||
|
import com.elink.esua.epdc.feign.fallback.OssFeignClientFallback; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.http.MediaType; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
|
||||
|
/** |
||||
|
* 文件对象模块 |
||||
|
* @Author LC |
||||
|
* @Date 2019/9/8 18:24 |
||||
|
*/ |
||||
|
@FeignClient(name = ServiceConstant.EPDC_OSS_SERVER, fallback = OssFeignClientFallback.class) |
||||
|
public interface OssFeignClient { |
||||
|
|
||||
|
/** |
||||
|
* 图片上传 |
||||
|
* @Params: [base64] |
||||
|
* @Return: com.elink.esua.epdc.commons.tools.utils.Result<java.lang.String> |
||||
|
* @Author: liuchuang |
||||
|
* @Date: 2019/9/11 17:17 |
||||
|
*/ |
||||
|
@PostMapping(value = "oss/file/uploadBase64") |
||||
|
Result<String> upload(UploadFormDTO formDTO); |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* 图片上传 |
||||
|
* |
||||
|
* @params [file] |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result<com.elink.esua.epdc.dto.UploadDTO> |
||||
|
* @author liuchuang |
||||
|
* @since 2019/11/25 16:13 |
||||
|
*/ |
||||
|
@PostMapping(value = "oss/file/uploadFile", consumes = MediaType.APPLICATION_JSON_VALUE) |
||||
|
Result<String> uploadFile(UploadToOssDTO uploadToOssDto); |
||||
|
} |
@ -0,0 +1,28 @@ |
|||||
|
package com.elink.esua.epdc.feign.fallback; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.UploadFormDTO; |
||||
|
import com.elink.esua.epdc.dto.UploadToOssDTO; |
||||
|
import com.elink.esua.epdc.feign.OssFeignClient; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* 文件对象模块 |
||||
|
* @Author LC |
||||
|
* @Date 2019/9/8 18:25 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class OssFeignClientFallback implements OssFeignClient { |
||||
|
|
||||
|
@Override |
||||
|
public Result<String> upload(UploadFormDTO formDTO) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_OSS_SERVER, "upload", formDTO); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result<String> uploadFile(UploadToOssDTO uploadToOssDto) { |
||||
|
return ModuleUtils.feignConError(ServiceConstant.EPDC_OSS_SERVER, "uploadFile", uploadToOssDto); |
||||
|
} |
||||
|
} |
@ -0,0 +1,117 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service; |
||||
|
|
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.dto.UserPointsVerificationQrCodeDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.entity.UserPointsVerificationQrCodeEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-01-18 |
||||
|
*/ |
||||
|
public interface UserPointsVerificationQrCodeService extends BaseService<UserPointsVerificationQrCodeEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<UserPointsVerificationQrCodeDTO> |
||||
|
* @author generator |
||||
|
* @date 2021-01-18 |
||||
|
*/ |
||||
|
PageData<UserPointsVerificationQrCodeDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<UserPointsVerificationQrCodeDTO> |
||||
|
* @author generator |
||||
|
* @date 2021-01-18 |
||||
|
*/ |
||||
|
List<UserPointsVerificationQrCodeDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return UserPointsVerificationQrCodeDTO |
||||
|
* @author generator |
||||
|
* @date 2021-01-18 |
||||
|
*/ |
||||
|
UserPointsVerificationQrCodeDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2021-01-18 |
||||
|
*/ |
||||
|
void save(UserPointsVerificationQrCodeDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2021-01-18 |
||||
|
*/ |
||||
|
void update(UserPointsVerificationQrCodeDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2021-01-18 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* 生成积分核销二维码 |
||||
|
* |
||||
|
* @param userId 用户ID |
||||
|
* @return com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 11:11 |
||||
|
*/ |
||||
|
UserPointsVerificationResultDTO generatePointsVerificationQRCode(String userId); |
||||
|
|
||||
|
/** |
||||
|
* 扫描兑换码获取用户信息接口 |
||||
|
* |
||||
|
* @param qrCodeId 码ID |
||||
|
* @return com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:11 |
||||
|
*/ |
||||
|
EpdcUserPointsVerificationResultDTO getUserInfoByCode(String qrCodeId); |
||||
|
} |
@ -0,0 +1,197 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.elink.esua.epdc.service.impl; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.StrConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.QrCodeUtils; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dao.UserPointsVerificationQrCodeDao; |
||||
|
import com.elink.esua.epdc.dto.UploadToOssDTO; |
||||
|
import com.elink.esua.epdc.dto.UserDTO; |
||||
|
import com.elink.esua.epdc.dto.UserPointsVerificationQrCodeDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.EpdcUserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.dto.epdc.result.UserPointsVerificationResultDTO; |
||||
|
import com.elink.esua.epdc.entity.UserPointsVerificationQrCodeEntity; |
||||
|
import com.elink.esua.epdc.feign.OssFeignClient; |
||||
|
import com.elink.esua.epdc.service.UserPointsVerificationQrCodeService; |
||||
|
import com.elink.esua.epdc.service.UserService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 用户积分核销二维码表 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2021-01-18 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class UserPointsVerificationQrCodeServiceImpl extends BaseServiceImpl<UserPointsVerificationQrCodeDao, UserPointsVerificationQrCodeEntity> implements UserPointsVerificationQrCodeService { |
||||
|
|
||||
|
@Autowired |
||||
|
private OssFeignClient ossFeignClient; |
||||
|
|
||||
|
@Autowired |
||||
|
private UserService userService; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<UserPointsVerificationQrCodeDTO> page(Map<String, Object> params) { |
||||
|
IPage<UserPointsVerificationQrCodeEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
getWrapper(params) |
||||
|
); |
||||
|
return getPageData(page, UserPointsVerificationQrCodeDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<UserPointsVerificationQrCodeDTO> list(Map<String, Object> params) { |
||||
|
List<UserPointsVerificationQrCodeEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, UserPointsVerificationQrCodeDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<UserPointsVerificationQrCodeEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<UserPointsVerificationQrCodeEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public UserPointsVerificationQrCodeDTO get(String id) { |
||||
|
UserPointsVerificationQrCodeEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, UserPointsVerificationQrCodeDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(UserPointsVerificationQrCodeDTO dto) { |
||||
|
UserPointsVerificationQrCodeEntity entity = ConvertUtils.sourceToTarget(dto, UserPointsVerificationQrCodeEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(UserPointsVerificationQrCodeDTO dto) { |
||||
|
UserPointsVerificationQrCodeEntity entity = ConvertUtils.sourceToTarget(dto, UserPointsVerificationQrCodeEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public UserPointsVerificationResultDTO generatePointsVerificationQRCode(String userId) { |
||||
|
// 删除用户对应的兑换码
|
||||
|
baseDao.deleteByUserId(userId); |
||||
|
|
||||
|
// 保存用户信息
|
||||
|
UserPointsVerificationQrCodeEntity entity = new UserPointsVerificationQrCodeEntity(); |
||||
|
entity.setUserId(userId); |
||||
|
insert(entity); |
||||
|
|
||||
|
// 生成二维码
|
||||
|
String codeUrl = generateQRCode(entity.getId()); |
||||
|
entity.setCodeUrl(codeUrl); |
||||
|
|
||||
|
// 更新二维码地址
|
||||
|
updateById(entity); |
||||
|
UserPointsVerificationResultDTO resultDto = new UserPointsVerificationResultDTO(); |
||||
|
resultDto.setCodeUrl(codeUrl); |
||||
|
|
||||
|
return resultDto; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public EpdcUserPointsVerificationResultDTO getUserInfoByCode(String qrCodeId) { |
||||
|
// 校验兑换码
|
||||
|
String userId = checkQRCode(qrCodeId); |
||||
|
// 获取用户信息
|
||||
|
UserDTO userDto = userService.get(userId); |
||||
|
EpdcUserPointsVerificationResultDTO resultDto = ConvertUtils.sourceToTarget(userDto, EpdcUserPointsVerificationResultDTO.class); |
||||
|
resultDto.setUserId(userDto.getId()); |
||||
|
|
||||
|
return resultDto; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码并上传 OSS |
||||
|
* |
||||
|
* @param param 二维码参数 |
||||
|
* @return java.lang.String |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 13:30 |
||||
|
*/ |
||||
|
private String generateQRCode(String param) { |
||||
|
UploadToOssDTO dto = new UploadToOssDTO(); |
||||
|
dto.setFileByte(QrCodeUtils.encodeByByte(param, "", false)); |
||||
|
dto.setFileName(param.concat(StrConstant.DOT).concat(StrConstant.SUFFIX_IMG_PNG)); |
||||
|
|
||||
|
Result<String> ossResult = ossFeignClient.uploadFile(dto); |
||||
|
if (null == ossResult || !ossResult.success() || null == ossResult.getData()) { |
||||
|
throw new RenException("兑换码上传失败,请稍后重试"); |
||||
|
} |
||||
|
return ossResult.getData(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 兑换码校验 |
||||
|
* |
||||
|
* @param qrCodeId 码ID |
||||
|
* @return java.lang.String |
||||
|
* @author Liuchuang |
||||
|
* @since 2021/1/19 15:26 |
||||
|
*/ |
||||
|
private String checkQRCode(String qrCodeId) { |
||||
|
UserPointsVerificationQrCodeEntity entity = baseDao.selectById(qrCodeId); |
||||
|
if (null == entity) { |
||||
|
throw new RenException("获取兑换码信息失败,请重新扫码"); |
||||
|
} |
||||
|
|
||||
|
// 兑换码有效时间3分钟
|
||||
|
long seconds = (System.currentTimeMillis() - entity.getCreatedTime().getTime()) / 1000; |
||||
|
if (seconds > NumConstant.ONE_HUNDRED_EIGHTY) { |
||||
|
throw new RenException("兑换码已失效,请重新扫码"); |
||||
|
} |
||||
|
|
||||
|
return entity.getUserId(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,10 @@ |
|||||
|
<?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.elink.esua.epdc.dao.UserPointsVerificationQrCodeDao"> |
||||
|
|
||||
|
<delete id="deleteByUserId"> |
||||
|
UPDATE epdc_user_points_verification_qr_code SET DEL_FLAG = '1', UPDATED_TIME = NOW() WHERE USER_ID = #{userId} |
||||
|
</delete> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue