parent
f5b6f5829c
commit
a4d36a470c
|
|
@ -0,0 +1,55 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.entity.SysImageLibrary;
|
||||
import com.czg.account.service.SysImageLibraryService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 自用图库接口
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/image")
|
||||
public class SysImageLibraryController {
|
||||
|
||||
@Resource
|
||||
private SysImageLibraryService sysImageLibraryService;
|
||||
|
||||
/**
|
||||
* 获取系统图库分页列表
|
||||
* @param name 文件名称 模糊匹配
|
||||
* @return 系统图库分页列表
|
||||
*/
|
||||
@GetMapping("/get")
|
||||
public CzgResult<Page<SysImageLibrary>> get(@RequestParam(required = false) String name) {
|
||||
return CzgResult.success(sysImageLibraryService.getImagePage(name));
|
||||
}
|
||||
/**
|
||||
* 保存系统图库
|
||||
* @param sysImageLibrary 系统图库
|
||||
* @return 无
|
||||
*/
|
||||
@PostMapping("/saveOrUpdate")
|
||||
public CzgResult<Void> saveOrUpdate(@RequestBody SysImageLibrary sysImageLibrary) {
|
||||
sysImageLibraryService.saveOrUpdate(sysImageLibrary);
|
||||
return CzgResult.success();
|
||||
}
|
||||
/**
|
||||
* 上传系统图库图片
|
||||
* @param fileName 图片文件名 必填
|
||||
* @param suffix 图片扩展名 必填
|
||||
* @param file 图片文件 必填
|
||||
* @return 图片地址
|
||||
*/
|
||||
@PostMapping("/upload")
|
||||
public CzgResult<String> upload(@RequestParam String fileName, @RequestParam String suffix, @RequestParam MultipartFile file) throws Exception {
|
||||
return CzgResult.success(sysImageLibraryService.upload(file.getBytes(), fileName, suffix));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 系统图库 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-09-25
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sys_image_library")
|
||||
public class SysImageLibrary implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 图片名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 预留
|
||||
*/
|
||||
private String type;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.SysImageLibrary;
|
||||
|
||||
/**
|
||||
* 系统图库 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-09-25
|
||||
*/
|
||||
public interface SysImageLibraryService extends IService<SysImageLibrary> {
|
||||
|
||||
/**
|
||||
* 获取系统图库分页列表
|
||||
* @param name 图库名称
|
||||
* @return 系统图库分页列表
|
||||
*/
|
||||
Page<SysImageLibrary> getImagePage(String name);
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
* @param bytes 图片字节数组
|
||||
* @param fileName 图片文件名
|
||||
* @param suffix 图片扩展名
|
||||
* @return 图片地址
|
||||
*/
|
||||
String upload(byte[] bytes, String fileName, String suffix) throws Exception;
|
||||
}
|
||||
|
|
@ -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> {
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -11,7 +11,7 @@ import com.zaxxer.hikari.HikariDataSource;
|
|||
*/
|
||||
public class Main {
|
||||
// private final static String BASE_URL = "rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com";
|
||||
private final static String BASE_URL = "192.168.1.31";
|
||||
private final static String BASE_URL = "192.168.1.42";
|
||||
private final static String PORT = "3306";
|
||||
private final static String USERNAME = "root";
|
||||
private final static String PASSWORD = "Chaozg123.";
|
||||
|
|
@ -26,12 +26,12 @@ public class Main {
|
|||
// String packageName = "system";
|
||||
// String packageName = "account";
|
||||
// String packageName = "product";
|
||||
String packageName = "market";
|
||||
String packageName = "account";
|
||||
|
||||
String tableName = "mk_shop_consume_discount_record";
|
||||
String tableName = "sys_image_library";
|
||||
String author = "zs";
|
||||
//是否生成DTO实体 默认生成
|
||||
boolean isGenerateDto = true;
|
||||
boolean isGenerateDto = false;
|
||||
|
||||
//配置数据源
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
|||
continue;
|
||||
}
|
||||
} else {
|
||||
long count = recordService.count(new QueryWrapper().eq(MkShopCouponRecord::getCouponSyncId, coupon.getId()));
|
||||
long count = recordService.count(new QueryWrapper().eq(MkShopCouponRecord::getCouponId, coupon.getId()));
|
||||
if (count >= coupon.getGetLimit()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue