券 领取数量校验

图库
This commit is contained in:
2025-09-26 13:58:53 +08:00
parent f5b6f5829c
commit a4d36a470c
9 changed files with 235 additions and 10 deletions

View File

@@ -0,0 +1,14 @@
package com.czg.service.account.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.account.entity.SysImageLibrary;
/**
* 系统图库 映射层。
*
* @author zs
* @since 2025-09-25
*/
public interface SysImageLibraryMapper extends BaseMapper<SysImageLibrary> {
}

View File

@@ -0,0 +1,44 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.util.StrUtil;
import com.czg.market.dto.MkCouponGiftDTO;
import com.czg.market.entity.MkCouponGift;
import com.czg.service.account.util.AliOssUtil;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.SysImageLibrary;
import com.czg.account.service.SysImageLibraryService;
import com.czg.service.account.mapper.SysImageLibraryMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 系统图库 服务层实现。
*
* @author zs
* @since 2025-09-25
*/
@Service
public class SysImageLibraryServiceImpl extends ServiceImpl<SysImageLibraryMapper, SysImageLibrary> implements SysImageLibraryService {
@Resource
private AliOssUtil aliOssUtil;
@Override
public Page<SysImageLibrary> getImagePage(String name) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.like(SysImageLibrary::getName, StrUtil.isBlank(name) ? null : name)
.orderBy(SysImageLibrary::getId).desc();
return pageAs(PageUtil.buildPage(), queryWrapper, SysImageLibrary.class);
}
@Override
public String upload(byte[] bytes, String fileName, String suffix) throws Exception {
return aliOssUtil.uploadSelfSuffix(bytes, fileName, suffix);
}
}

View File

@@ -1,8 +1,8 @@
/**
* Copyright (c) 2018 人人开源 All rights reserved.
*
* <p>
* https://www.renren.io
*
* <p>
* 版权所有,侵权必究!
*/
@@ -23,7 +23,7 @@ import java.util.UUID;
* @author Mark sunlightcs@gmail.com
*/
@Component
public class AliOssUtil{
public class AliOssUtil {
private final String endPoint = "oss-cn-beijing.aliyuncs.com";
private final String accessKey = "LTAI5tPdEfYSZcqHbjCrtPRD";
@@ -31,9 +31,11 @@ public class AliOssUtil{
private final String bucketName = "cashier-oss";
private final String url = "cashier-oss.oss-cn-beijing.aliyuncs.com";
private final String prefix = "upload";
private final String selfPrefix = "self";
/**
* 文件路径
*
* @param prefix 前缀
* @param suffix 后缀
* @return 返回上传路径
@@ -44,19 +46,32 @@ public class AliOssUtil{
//文件路径
String path = DateUtil.date().getDay() + "/" + uuid;
if(StrUtil.isNotBlank(prefix)){
if (StrUtil.isNotBlank(prefix)) {
path = prefix + "/" + path;
}
return path + "." + suffix;
}
/**
* 文件路径
*
* @param prefix 前缀
* @param fileName 文件名
* @param suffix 后缀
* @return 返回上传路径
*/
public String getPathByFileName(String prefix, String fileName, String suffix) {
return prefix + "/" + fileName + "." + suffix;
}
public String upload(InputStream inputStream, String path) throws Exception {
OSSClient client = new OSSClient(endPoint, accessKey, secretKey);
try {
client.putObject(bucketName, path, inputStream);
client.shutdown();
} catch (Exception e){
} catch (Exception e) {
throw new Exception("上传异常");
}
@@ -67,4 +82,8 @@ public class AliOssUtil{
return upload(new ByteArrayInputStream(data), getPath(prefix, suffix));
}
public String uploadSelfSuffix(byte[] data, String fileName, String suffix) throws Exception {
return upload(new ByteArrayInputStream(data), getPathByFileName(selfPrefix, fileName, suffix));
}
}

View File

@@ -0,0 +1,7 @@
<?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.czg.service.account.mapper.SysImageLibraryMapper">
</mapper>