商城业务所有模块及tools模块完成mp改造
This commit is contained in:
@ -1,65 +1,81 @@
|
||||
package co.yixiang.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 支付宝配置类
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "alipay_config")
|
||||
@Data
|
||||
@Table(name="alipay_config")
|
||||
public class AlipayConfig implements Serializable {
|
||||
|
||||
/** 主键 */
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
/** 应用ID,APPID,收款账号既是APPID对应支付宝账号 */
|
||||
@NotBlank
|
||||
|
||||
/** 应用ID */
|
||||
@Column(name = "app_id")
|
||||
private String appId;
|
||||
|
||||
/** 商户私钥,您的PKCS8格式RSA2私钥 */
|
||||
@NotBlank
|
||||
@Column(name = "private_key", columnDefinition = "text")
|
||||
private String privateKey;
|
||||
|
||||
/** 支付宝公钥 */
|
||||
@NotBlank
|
||||
@Column(name = "public_key", columnDefinition = "text")
|
||||
private String publicKey;
|
||||
/** 编码 */
|
||||
@Column(name = "charset")
|
||||
private String charset;
|
||||
|
||||
/** 签名方式,固定格式 */
|
||||
@Column(name = "sign_type")
|
||||
private String signType="RSA2";
|
||||
|
||||
/** 支付宝开放安全地址,一般不会变 */
|
||||
/** 类型 固定格式json */
|
||||
@Column(name = "format")
|
||||
private String format;
|
||||
|
||||
|
||||
/** 网关地址 */
|
||||
@Column(name = "gateway_url")
|
||||
private String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
|
||||
private String gatewayUrl;
|
||||
|
||||
/** 编码,固定格式 */
|
||||
private String charset= "utf-8";
|
||||
|
||||
/** 异步通知地址 */
|
||||
@NotBlank
|
||||
/** 异步回调 */
|
||||
@Column(name = "notify_url")
|
||||
private String notifyUrl;
|
||||
|
||||
/** 订单完成后返回的页面 */
|
||||
@NotBlank
|
||||
|
||||
/** 私钥 */
|
||||
@Column(name = "private_key")
|
||||
private String privateKey;
|
||||
|
||||
|
||||
/** 公钥 */
|
||||
@Column(name = "public_key")
|
||||
private String publicKey;
|
||||
|
||||
|
||||
/** 回调地址 */
|
||||
@Column(name = "return_url")
|
||||
private String returnUrl;
|
||||
|
||||
/** 类型,固定格式 */
|
||||
private String format="JSON";
|
||||
|
||||
/** 签名方式 */
|
||||
@Column(name = "sign_type")
|
||||
private String signType;
|
||||
|
||||
|
||||
/** 商户号 */
|
||||
@NotBlank
|
||||
@Column(name = "sys_service_provider_id")
|
||||
private String sysServiceProviderId;
|
||||
|
||||
}
|
||||
|
||||
public void copy(AlipayConfig source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -1,41 +1,56 @@
|
||||
package co.yixiang.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 邮件配置类,数据存覆盖式存入数据存
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name = "email_config")
|
||||
@Table(name="email_config")
|
||||
public class EmailConfig implements Serializable {
|
||||
|
||||
/** ID */
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
/** 邮件服务器SMTP地址 */
|
||||
@NotBlank
|
||||
private String host;
|
||||
|
||||
/** 邮件服务器 SMTP 端口 */
|
||||
@NotBlank
|
||||
private String port;
|
||||
|
||||
/** 发件者用户名,默认为发件人邮箱前缀 */
|
||||
@NotBlank
|
||||
private String user;
|
||||
|
||||
@NotBlank
|
||||
private String pass;
|
||||
|
||||
/** 收件人 */
|
||||
@NotBlank
|
||||
@Column(name = "from_user")
|
||||
private String fromUser;
|
||||
}
|
||||
|
||||
|
||||
/** 邮件服务器SMTP地址 */
|
||||
@Column(name = "host")
|
||||
private String host;
|
||||
|
||||
|
||||
/** 密码 */
|
||||
@Column(name = "pass")
|
||||
private String pass;
|
||||
|
||||
|
||||
/** 端口 */
|
||||
@Column(name = "port")
|
||||
private String port;
|
||||
|
||||
|
||||
/** 发件者用户名 */
|
||||
@Column(name = "user")
|
||||
private String user;
|
||||
|
||||
|
||||
public void copy(EmailConfig source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -1,62 +1,69 @@
|
||||
package co.yixiang.domain;
|
||||
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="local_storage")
|
||||
@NoArgsConstructor
|
||||
public class LocalStorage implements Serializable {
|
||||
public class LocalStorage implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
/** 真实文件名 */
|
||||
|
||||
/** 文件真实的名称 */
|
||||
@Column(name = "real_name")
|
||||
private String realName;
|
||||
|
||||
/**文件名 */
|
||||
|
||||
/** 文件名 */
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
/**后缀 */
|
||||
|
||||
/** 后缀 */
|
||||
@Column(name = "suffix")
|
||||
private String suffix;
|
||||
|
||||
|
||||
/** 路径 */
|
||||
@Column(name = "path")
|
||||
private String path;
|
||||
|
||||
|
||||
/** 类型 */
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
|
||||
/** 大小 */
|
||||
@Column(name = "size")
|
||||
private String size;
|
||||
|
||||
|
||||
/** 操作人 */
|
||||
@Column(name = "operate")
|
||||
private String operate;
|
||||
|
||||
@Column(name = "create_time")
|
||||
@CreationTimestamp
|
||||
private Timestamp createTime;
|
||||
|
||||
/** 创建日期 */
|
||||
@Column(name = "create_time")
|
||||
@TableField(fill= FieldFill.INSERT)
|
||||
private Timestamp createTime;
|
||||
public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) {
|
||||
this.realName = realName;
|
||||
this.name = name;
|
||||
@ -70,4 +77,4 @@ public class LocalStorage implements Serializable {
|
||||
public void copy(LocalStorage source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +1,77 @@
|
||||
package co.yixiang.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* sm.ms图床
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
*/
|
||||
@Data
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "picture")
|
||||
@Data
|
||||
@Table(name="picture")
|
||||
public class Picture implements Serializable {
|
||||
|
||||
/** ID */
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
private String filename;
|
||||
|
||||
private String url;
|
||||
|
||||
private String size;
|
||||
|
||||
private String height;
|
||||
|
||||
private String width;
|
||||
|
||||
@Column(name = "delete_url")
|
||||
private String delete;
|
||||
|
||||
private String username;
|
||||
|
||||
@CreationTimestamp
|
||||
/** 上传日期 */
|
||||
@Column(name = "create_time")
|
||||
@TableField(fill= FieldFill.INSERT)
|
||||
private Timestamp createTime;
|
||||
|
||||
/** 用于检测文件是否重复 */
|
||||
private String md5Code;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Picture{" +
|
||||
"filename='" + filename + '\'' +
|
||||
'}';
|
||||
/** 删除的URL */
|
||||
@Column(name = "delete_url")
|
||||
private String deleteUrl;
|
||||
|
||||
|
||||
/** 图片名称 */
|
||||
@Column(name = "filename")
|
||||
private String filename;
|
||||
|
||||
|
||||
/** 图片高度 */
|
||||
@Column(name = "height")
|
||||
private String height;
|
||||
|
||||
|
||||
/** 图片大小 */
|
||||
@Column(name = "size")
|
||||
private String size;
|
||||
|
||||
|
||||
/** 图片地址 */
|
||||
@Column(name = "url")
|
||||
private String url;
|
||||
|
||||
|
||||
/** 用户名称 */
|
||||
@Column(name = "username")
|
||||
private String username;
|
||||
|
||||
|
||||
/** 图片宽度 */
|
||||
@Column(name = "width")
|
||||
private String width;
|
||||
|
||||
|
||||
/** 文件的MD5值 */
|
||||
@Column(name = "md5code")
|
||||
private String md5code;
|
||||
|
||||
public void copy(Picture source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
@ -1,52 +1,62 @@
|
||||
package co.yixiang.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 七牛云对象存储配置类
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "qiniu_config")
|
||||
@Data
|
||||
@Table(name="qiniu_config")
|
||||
public class QiniuConfig implements Serializable {
|
||||
|
||||
/** ID */
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
/** 一个账号最多拥有两对密钥(Access/Secret Key) */
|
||||
@NotBlank
|
||||
@Column(name = "access_key", columnDefinition = "text")
|
||||
|
||||
/** accessKey */
|
||||
@Column(name = "access_key")
|
||||
private String accessKey;
|
||||
|
||||
/** 一个账号最多拥有两对密钥(Access/Secret Key) */
|
||||
@NotBlank
|
||||
@Column(name = "secret_key", columnDefinition = "text")
|
||||
private String secretKey;
|
||||
|
||||
/** 存储空间名称作为唯一的 Bucket 识别符 */
|
||||
@NotBlank
|
||||
/** Bucket 识别符 */
|
||||
@Column(name = "bucket")
|
||||
private String bucket;
|
||||
|
||||
/**
|
||||
* Zone表示与机房的对应关系
|
||||
* 华东 Zone.zone0()
|
||||
* 华北 Zone.zone1()
|
||||
* 华南 Zone.zone2()
|
||||
* 北美 Zone.zoneNa0()
|
||||
* 东南亚 Zone.zoneAs0()
|
||||
*/
|
||||
@NotBlank
|
||||
private String zone;
|
||||
|
||||
/** 外链域名,可自定义,需在七牛云绑定 */
|
||||
/** 外链域名 */
|
||||
@Column(name = "host",nullable = false)
|
||||
@NotBlank
|
||||
private String host;
|
||||
|
||||
/** 空间类型:公开/私有 */
|
||||
private String type = "公开";
|
||||
}
|
||||
|
||||
/** secretKey */
|
||||
@Column(name = "secret_key")
|
||||
private String secretKey;
|
||||
|
||||
|
||||
/** 空间类型 */
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
|
||||
/** 机房 */
|
||||
@Column(name = "zone")
|
||||
private String zone;
|
||||
|
||||
|
||||
public void copy(QiniuConfig source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -1,45 +1,67 @@
|
||||
package co.yixiang.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import javax.validation.constraints.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 上传成功后,存储结果
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "qiniu_content")
|
||||
@Data
|
||||
@Table(name="qiniu_content")
|
||||
public class QiniuContent implements Serializable {
|
||||
|
||||
/** ID */
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
/** 文件名 */
|
||||
@Column(name = "name")
|
||||
private String key;
|
||||
|
||||
/** 空间名 */
|
||||
/** Bucket 识别符 */
|
||||
@Column(name = "bucket")
|
||||
private String bucket;
|
||||
|
||||
/** 大小 */
|
||||
|
||||
/** 文件名称 */
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
|
||||
/** 文件大小 */
|
||||
@Column(name = "size")
|
||||
private String size;
|
||||
|
||||
/** 文件地址 */
|
||||
|
||||
/** 文件类型:私有或公开 */
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
|
||||
/** 上传或同步的时间 */
|
||||
@Column(name = "update_time")
|
||||
@TableField(fill= FieldFill.INSERT_UPDATE)
|
||||
private Timestamp updateTime;
|
||||
|
||||
|
||||
/** 文件url */
|
||||
@Column(name = "url")
|
||||
private String url;
|
||||
|
||||
|
||||
@Column(name = "suffix")
|
||||
private String suffix;
|
||||
|
||||
/** 空间类型:公开/私有 */
|
||||
private String type = "公开";
|
||||
|
||||
@UpdateTimestamp
|
||||
@Column(name = "update_time")
|
||||
private Timestamp updateTime;
|
||||
}
|
||||
public void copy(QiniuContent source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package co.yixiang.repository;
|
||||
|
||||
import co.yixiang.domain.AlipayConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface AlipayRepository extends JpaRepository<AlipayConfig,Long> {
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package co.yixiang.repository;
|
||||
|
||||
import co.yixiang.domain.EmailConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
public interface EmailRepository extends JpaRepository<EmailConfig,Long> {
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package co.yixiang.repository;
|
||||
|
||||
import co.yixiang.domain.LocalStorage;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
public interface LocalStorageRepository extends JpaRepository<LocalStorage, Long>, JpaSpecificationExecutor<LocalStorage> {
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package co.yixiang.repository;
|
||||
|
||||
import co.yixiang.domain.Picture;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
*/
|
||||
public interface PictureRepository extends JpaRepository<Picture,Long>, JpaSpecificationExecutor<Picture> {
|
||||
|
||||
/**
|
||||
* 根据 Mds 值查询文件
|
||||
* @param code 值
|
||||
* @return /
|
||||
*/
|
||||
Picture findByMd5Code(String code);
|
||||
|
||||
/**
|
||||
* 根据连接地址查询
|
||||
* @param url /
|
||||
* @return /
|
||||
*/
|
||||
boolean existsByUrl(String url);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package co.yixiang.repository;
|
||||
|
||||
import co.yixiang.domain.QiniuConfig;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface QiNiuConfigRepository extends JpaRepository<QiniuConfig,Long> {
|
||||
|
||||
/**
|
||||
* 编辑类型
|
||||
* @param type
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "update QiniuConfig set type = ?1")
|
||||
void update(String type);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package co.yixiang.repository;
|
||||
|
||||
import co.yixiang.domain.QiniuContent;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface QiniuContentRepository extends JpaRepository<QiniuContent,Long>, JpaSpecificationExecutor<QiniuContent> {
|
||||
|
||||
/**
|
||||
* 根据key查询
|
||||
* @param key 文件名
|
||||
* @return QiniuContent
|
||||
*/
|
||||
QiniuContent findByKey(String key);
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package co.yixiang.rest;
|
||||
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.service.AlipayConfigService;
|
||||
import co.yixiang.utils.AliPayStatusEnum;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -9,7 +10,6 @@ import co.yixiang.annotation.AnonymousAccess;
|
||||
import co.yixiang.domain.vo.TradeVo;
|
||||
import co.yixiang.domain.AlipayConfig;
|
||||
import co.yixiang.utils.AlipayUtils;
|
||||
import co.yixiang.service.AlipayService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -32,9 +32,9 @@ public class AliPayController {
|
||||
|
||||
private final AlipayUtils alipayUtils;
|
||||
|
||||
private final AlipayService alipayService;
|
||||
private final AlipayConfigService alipayService;
|
||||
|
||||
public AliPayController(AlipayUtils alipayUtils, AlipayService alipayService) {
|
||||
public AliPayController(AlipayUtils alipayUtils, AlipayConfigService alipayService) {
|
||||
this.alipayUtils = alipayUtils;
|
||||
this.alipayService = alipayService;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package co.yixiang.rest;
|
||||
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.service.EmailConfigService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import co.yixiang.domain.vo.EmailVo;
|
||||
import co.yixiang.domain.EmailConfig;
|
||||
import co.yixiang.service.EmailService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -21,9 +21,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
@Api(tags = "工具:邮件管理")
|
||||
public class EmailController {
|
||||
|
||||
private final EmailService emailService;
|
||||
private final EmailConfigService emailService;
|
||||
|
||||
public EmailController(EmailService emailService) {
|
||||
public EmailController(EmailConfigService emailService) {
|
||||
this.emailService = emailService;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
package co.yixiang.rest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.domain.LocalStorage;
|
||||
import co.yixiang.service.LocalStorageService;
|
||||
import co.yixiang.service.dto.LocalStorageQueryCriteria;
|
||||
import co.yixiang.service.dto.LocalStorageDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -11,61 +14,64 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Api(tags = "工具:本地存储管理")
|
||||
@AllArgsConstructor
|
||||
@Api(tags = "文件管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class LocalStorageController {
|
||||
|
||||
private final LocalStorageService localStorageService;
|
||||
private final IGenerator generator;
|
||||
|
||||
public LocalStorageController(LocalStorageService localStorageService) {
|
||||
this.localStorageService = localStorageService;
|
||||
}
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<Object> getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
@PreAuthorize("@el.check('admin','localStorage:list')")
|
||||
public void download(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException {
|
||||
localStorageService.download(localStorageService.queryAll(criteria), response);
|
||||
localStorageService.download(generator.convert(localStorageService.queryAll(criteria), LocalStorageDto.class), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@Log("查询文件")
|
||||
@ApiOperation("查询文件")
|
||||
@PreAuthorize("@el.check('admin','localStorage:list')")
|
||||
public ResponseEntity<Object> getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping
|
||||
@PreAuthorize("@el.check('storage:add')")
|
||||
public ResponseEntity<Object> create(@RequestParam String name, @RequestParam("file") MultipartFile file){
|
||||
return new ResponseEntity<>(localStorageService.create(name, file),HttpStatus.CREATED);
|
||||
@Log("新增文件")
|
||||
@ApiOperation("新增文件")
|
||||
@PreAuthorize("@el.check('admin','localStorage:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody LocalStorage resources){
|
||||
return new ResponseEntity<>(localStorageService.save(resources),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改文件")
|
||||
@PutMapping
|
||||
@PreAuthorize("@el.check('storage:edit')")
|
||||
@Log("修改文件")
|
||||
@ApiOperation("修改文件")
|
||||
@PreAuthorize("@el.check('admin','localStorage:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorage resources){
|
||||
localStorageService.update(resources);
|
||||
localStorageService.updateById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("多选删除")
|
||||
@Log("删除文件")
|
||||
@ApiOperation("删除文件")
|
||||
@PreAuthorize("@el.check('admin','localStorage:del')")
|
||||
@DeleteMapping
|
||||
@ApiOperation("多选删除")
|
||||
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||
localStorageService.deleteAll(ids);
|
||||
Arrays.asList(ids).forEach(id->{
|
||||
localStorageService.removeById(id);
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package co.yixiang.rest;
|
||||
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.service.dto.PictureDto;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import co.yixiang.domain.Picture;
|
||||
@ -17,17 +19,18 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author 郑杰
|
||||
* @author hupeng
|
||||
* @date 2018/09/20 14:13:32
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/pictures")
|
||||
@Api(tags = "工具:免费图床管理")
|
||||
public class PictureController {
|
||||
|
||||
private final IGenerator generator;
|
||||
private final PictureService pictureService;
|
||||
|
||||
public PictureController(PictureService pictureService) {
|
||||
public PictureController(IGenerator generator, PictureService pictureService) {
|
||||
this.generator = generator;
|
||||
this.pictureService = pictureService;
|
||||
}
|
||||
|
||||
@ -44,7 +47,7 @@ public class PictureController {
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('pictures:list')")
|
||||
public void download(HttpServletResponse response, PictureQueryCriteria criteria) throws IOException {
|
||||
pictureService.download(pictureService.queryAll(criteria), response);
|
||||
pictureService.download(generator.convert(pictureService.queryAll(criteria), PictureDto.class), response);
|
||||
}
|
||||
|
||||
@Log("上传图片")
|
||||
|
@ -7,7 +7,7 @@ import co.yixiang.domain.LocalStorage;
|
||||
import co.yixiang.domain.QiniuContent;
|
||||
import co.yixiang.service.LocalStorageService;
|
||||
import co.yixiang.service.QiNiuService;
|
||||
import co.yixiang.service.dto.LocalStorageDTO;
|
||||
import co.yixiang.service.dto.LocalStorageDto;
|
||||
import co.yixiang.service.dto.LocalStorageQueryCriteria;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -55,7 +55,7 @@ public class UploadController {
|
||||
StringBuilder url = new StringBuilder();
|
||||
if (StrUtil.isNotEmpty(localUrl)) { //存在走本地
|
||||
for (MultipartFile file : files) {
|
||||
LocalStorageDTO localStorageDTO = localStorageService.create(name, file);
|
||||
LocalStorageDto localStorageDTO = localStorageService.create(name, file);
|
||||
if ("".equals(url.toString())) {
|
||||
url = url.append(localUrl + "/file/" + localStorageDTO.getType() + "/" + localStorageDTO.getRealName());
|
||||
} else {
|
||||
@ -80,4 +80,4 @@ public class UploadController {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package co.yixiang.rest;
|
||||
|
||||
import co.yixiang.service.EmailConfigService;
|
||||
import co.yixiang.utils.YshopConstant;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import co.yixiang.domain.VerificationCode;
|
||||
import co.yixiang.domain.vo.EmailVo;
|
||||
import co.yixiang.service.EmailService;
|
||||
import co.yixiang.service.VerificationCodeService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -22,9 +22,9 @@ public class VerificationCodeController {
|
||||
|
||||
private final VerificationCodeService verificationCodeService;
|
||||
|
||||
private final EmailService emailService;
|
||||
private final EmailConfigService emailService;
|
||||
|
||||
public VerificationCodeController(VerificationCodeService verificationCodeService, EmailService emailService) {
|
||||
public VerificationCodeController(VerificationCodeService verificationCodeService, EmailConfigService emailService) {
|
||||
this.verificationCodeService = verificationCodeService;
|
||||
this.emailService = emailService;
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package co.yixiang.service;
|
||||
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.domain.AlipayConfig;
|
||||
import co.yixiang.domain.vo.TradeVo;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface AlipayService {
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
public interface AlipayConfigService extends BaseService<AlipayConfig>{
|
||||
|
||||
/**
|
||||
* 处理来自PC的交易请求
|
||||
@ -38,5 +38,5 @@ public interface AlipayService {
|
||||
* @param alipayConfig 支付宝配置
|
||||
* @return AlipayConfig
|
||||
*/
|
||||
AlipayConfig update(AlipayConfig alipayConfig);
|
||||
void update(AlipayConfig alipayConfig);
|
||||
}
|
@ -1,22 +1,21 @@
|
||||
package co.yixiang.service;
|
||||
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.domain.EmailConfig;
|
||||
import co.yixiang.domain.vo.EmailVo;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
public interface EmailService {
|
||||
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
public interface EmailConfigService extends BaseService<EmailConfig>{
|
||||
/**
|
||||
* 更新邮件配置
|
||||
* @param emailConfig 邮件配置
|
||||
* @param old 旧的配置
|
||||
* @return EmailConfig
|
||||
*/
|
||||
EmailConfig update(EmailConfig emailConfig, EmailConfig old);
|
||||
void update(EmailConfig emailConfig, EmailConfig old);
|
||||
|
||||
/**
|
||||
* 查询配置
|
@ -1,19 +1,21 @@
|
||||
package co.yixiang.service;
|
||||
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.domain.LocalStorage;
|
||||
import co.yixiang.service.dto.LocalStorageDTO;
|
||||
import co.yixiang.service.dto.LocalStorageDto;
|
||||
import co.yixiang.service.dto.LocalStorageQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
public interface LocalStorageService {
|
||||
public interface LocalStorageService extends BaseService<LocalStorage>{
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
@ -21,21 +23,21 @@ public interface LocalStorageService {
|
||||
* @param pageable 分页参数
|
||||
* @return /
|
||||
*/
|
||||
Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
|
||||
Map<String, Object> queryAll(LocalStorageQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<LocalStorageDTO> queryAll(LocalStorageQueryCriteria criteria);
|
||||
List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id /
|
||||
* @return /
|
||||
*/
|
||||
LocalStorageDTO findById(Long id);
|
||||
LocalStorageDto findById(Long id);
|
||||
|
||||
/**
|
||||
* 上传
|
||||
@ -43,13 +45,8 @@ public interface LocalStorageService {
|
||||
* @param file 文件
|
||||
* @return /
|
||||
*/
|
||||
LocalStorageDTO create(String name, MultipartFile file);
|
||||
LocalStorageDto create(String name, MultipartFile file);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources 文件信息
|
||||
*/
|
||||
void update(LocalStorage resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
@ -63,5 +60,5 @@ public interface LocalStorageService {
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<LocalStorageDTO> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
void download(List<LocalStorageDto> localStorageDtos, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
@ -1,35 +1,46 @@
|
||||
package co.yixiang.service;
|
||||
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.domain.Picture;
|
||||
import co.yixiang.service.dto.PictureDto;
|
||||
import co.yixiang.service.dto.PictureQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
*/
|
||||
public interface PictureService {
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
public interface PictureService extends BaseService<Picture>{
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(PictureQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return /
|
||||
*/
|
||||
Object queryAll(PictureQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<PictureDto>
|
||||
*/
|
||||
List<Picture> queryAll(PictureQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<PictureDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file /
|
||||
@ -51,13 +62,6 @@ public interface PictureService {
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出
|
||||
* @param queryAll 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<Picture> queryAll, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
|
@ -0,0 +1,44 @@
|
||||
package co.yixiang.service;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.domain.QiniuConfig;
|
||||
import co.yixiang.service.dto.QiniuConfigDto;
|
||||
import co.yixiang.service.dto.QiniuConfigQueryCriteria;
|
||||
import co.yixiang.service.dto.QiniuQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
public interface QiniuConfigService extends BaseService<QiniuConfig>{
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(QiniuQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<QiniuConfigDto>
|
||||
*/
|
||||
List<QiniuConfig> queryAll(QiniuQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<QiniuConfigDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
|
||||
void update(String type);
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package co.yixiang.service;
|
||||
import co.yixiang.common.service.BaseService;
|
||||
import co.yixiang.domain.QiniuContent;
|
||||
import co.yixiang.service.dto.QiniuContentDto;
|
||||
import co.yixiang.service.dto.QiniuContentQueryCriteria;
|
||||
import co.yixiang.service.dto.QiniuQueryCriteria;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
public interface QiniuContentService extends BaseService<QiniuContent>{
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(QiniuQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<QiniuContentDto>
|
||||
*/
|
||||
List<QiniuContent> queryAll(QiniuQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<QiniuContentDto> all, HttpServletResponse response) throws IOException;
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class LocalStorageDTO implements Serializable {
|
||||
|
||||
public class LocalStorageDto implements Serializable {
|
||||
private Long id;
|
||||
|
||||
private String realName;
|
||||
@ -26,4 +25,4 @@ public class LocalStorageDTO implements Serializable {
|
||||
private String operate;
|
||||
|
||||
private Timestamp createTime;
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class LocalStorageQueryCriteria{
|
||||
@ -18,4 +18,4 @@ public class LocalStorageQueryCriteria{
|
||||
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Timestamp> createTime;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class PictureDto implements Serializable {
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** 上传日期 */
|
||||
private Timestamp createTime;
|
||||
|
||||
/** 删除的URL */
|
||||
private String deleteUrl;
|
||||
|
||||
/** 图片名称 */
|
||||
private String filename;
|
||||
|
||||
/** 图片高度 */
|
||||
private String height;
|
||||
|
||||
/** 图片大小 */
|
||||
private String size;
|
||||
|
||||
/** 图片地址 */
|
||||
private String url;
|
||||
|
||||
/** 用户名称 */
|
||||
private String username;
|
||||
|
||||
/** 图片宽度 */
|
||||
private String width;
|
||||
|
||||
/** 文件的MD5值 */
|
||||
private String md5code;
|
||||
}
|
@ -1,26 +1,13 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* sm.ms图床
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2019-6-4 09:52:09
|
||||
*/
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class PictureQueryCriteria{
|
||||
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String filename;
|
||||
|
||||
@Query(type = Query.Type.INNER_LIKE)
|
||||
private String username;
|
||||
|
||||
@Query(type = Query.Type.BETWEEN)
|
||||
private List<Timestamp> createTime;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class QiniuConfigDto implements Serializable {
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** accessKey */
|
||||
private String accessKey;
|
||||
|
||||
/** Bucket 识别符 */
|
||||
private String bucket;
|
||||
|
||||
/** 外链域名 */
|
||||
private String host;
|
||||
|
||||
/** secretKey */
|
||||
private String secretKey;
|
||||
|
||||
/** 空间类型 */
|
||||
private String type;
|
||||
|
||||
/** 机房 */
|
||||
private String zone;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class QiniuConfigQueryCriteria{
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class QiniuContentDto implements Serializable {
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
/** Bucket 识别符 */
|
||||
private String bucket;
|
||||
|
||||
/** 文件名称 */
|
||||
private String name;
|
||||
|
||||
/** 文件大小 */
|
||||
private String size;
|
||||
|
||||
/** 文件类型:私有或公开 */
|
||||
private String type;
|
||||
|
||||
/** 上传或同步的时间 */
|
||||
private Timestamp updateTime;
|
||||
|
||||
/** 文件url */
|
||||
private String url;
|
||||
|
||||
private String suffix;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package co.yixiang.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Data
|
||||
public class QiniuContentQueryCriteria{
|
||||
}
|
@ -1,39 +1,37 @@
|
||||
package co.yixiang.service.impl;
|
||||
|
||||
import co.yixiang.domain.AlipayConfig;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.domain.vo.TradeVo;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.repository.AlipayRepository;
|
||||
import co.yixiang.service.AlipayService;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.service.AlipayConfigService;
|
||||
import co.yixiang.service.mapper.AlipayConfigMapper;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "alipay")
|
||||
@SuppressWarnings("all")
|
||||
@AllArgsConstructor
|
||||
//@CacheConfig(cacheNames = "alipayConfig")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class AlipayServiceImpl implements AlipayService {
|
||||
|
||||
private final AlipayRepository alipayRepository;
|
||||
|
||||
public AlipayServiceImpl(AlipayRepository alipayRepository) {
|
||||
this.alipayRepository = alipayRepository;
|
||||
}
|
||||
|
||||
public class AlipayConfigServiceImpl extends BaseServiceImpl<AlipayConfigMapper, AlipayConfig> implements AlipayConfigService {
|
||||
@Override
|
||||
public String toPayAsPc(AlipayConfig alipay, TradeVo trade) throws Exception {
|
||||
|
||||
@ -94,16 +92,16 @@ public class AlipayServiceImpl implements AlipayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'1'")
|
||||
// @Cacheable(key = "'1'")
|
||||
public AlipayConfig find() {
|
||||
Optional<AlipayConfig> alipayConfig = alipayRepository.findById(1L);
|
||||
return alipayConfig.orElseGet(AlipayConfig::new);
|
||||
AlipayConfig alipayConfig = this.list().get(0);
|
||||
return alipayConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'1'")
|
||||
// @CachePut(key = "'1'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AlipayConfig update(AlipayConfig alipayConfig) {
|
||||
return alipayRepository.save(alipayConfig);
|
||||
public void update(AlipayConfig alipayConfig) {
|
||||
this.save(alipayConfig);
|
||||
}
|
||||
}
|
@ -3,38 +3,42 @@ package co.yixiang.service.impl;
|
||||
import cn.hutool.extra.mail.Mail;
|
||||
import cn.hutool.extra.mail.MailAccount;
|
||||
import co.yixiang.domain.EmailConfig;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.domain.vo.EmailVo;
|
||||
import co.yixiang.repository.EmailRepository;
|
||||
import co.yixiang.service.EmailService;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.utils.EncryptUtils;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import co.yixiang.utils.*;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.service.EmailConfigService;
|
||||
import co.yixiang.service.mapper.EmailConfigMapper;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.Optional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "email")
|
||||
@AllArgsConstructor
|
||||
//@CacheConfig(cacheNames = "emailConfig")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class EmailServiceImpl implements EmailService {
|
||||
public class EmailConfigServiceImpl extends BaseServiceImpl<EmailConfigMapper, EmailConfig> implements EmailConfigService {
|
||||
|
||||
private final EmailRepository emailRepository;
|
||||
|
||||
public EmailServiceImpl(EmailRepository emailRepository) {
|
||||
this.emailRepository = emailRepository;
|
||||
}
|
||||
private final IGenerator generator;
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'1'")
|
||||
// @CachePut(key = "'1'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public EmailConfig update(EmailConfig emailConfig, EmailConfig old) {
|
||||
public void update(EmailConfig emailConfig, EmailConfig old) {
|
||||
try {
|
||||
if(!emailConfig.getPass().equals(old.getPass())){
|
||||
// 对称加密
|
||||
@ -43,14 +47,14 @@ public class EmailServiceImpl implements EmailService {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return emailRepository.save(emailConfig);
|
||||
this.save(emailConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'1'")
|
||||
// @Cacheable(key = "'1'")
|
||||
public EmailConfig find() {
|
||||
Optional<EmailConfig> emailConfig = emailRepository.findById(1L);
|
||||
return emailConfig.orElseGet(EmailConfig::new);
|
||||
EmailConfig emailConfig = this.list().get(0);
|
||||
return emailConfig;
|
||||
}
|
||||
|
||||
@Override
|
@ -2,81 +2,81 @@ package co.yixiang.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.domain.LocalStorage;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.repository.LocalStorageRepository;
|
||||
import co.yixiang.utils.*;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import co.yixiang.common.utils.QueryHelpPlus;
|
||||
import co.yixiang.service.LocalStorageService;
|
||||
import co.yixiang.service.dto.LocalStorageDTO;
|
||||
import co.yixiang.service.dto.LocalStorageDto;
|
||||
import co.yixiang.service.dto.LocalStorageQueryCriteria;
|
||||
import co.yixiang.service.mapper.LocalStorageMapper;
|
||||
import co.yixiang.utils.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "localStorage")
|
||||
//@CacheConfig(cacheNames = "localStorage")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
|
||||
private final LocalStorageRepository localStorageRepository;
|
||||
|
||||
private final LocalStorageMapper localStorageMapper;
|
||||
public class LocalStorageServiceImpl extends BaseServiceImpl<LocalStorageMapper, LocalStorage> implements LocalStorageService {
|
||||
|
||||
private final IGenerator generator;
|
||||
@Value("${file.path}")
|
||||
private String path;
|
||||
|
||||
@Value("${file.maxSize}")
|
||||
private long maxSize;
|
||||
|
||||
public LocalStorageServiceImpl(LocalStorageRepository localStorageRepository, LocalStorageMapper localStorageMapper) {
|
||||
this.localStorageRepository = localStorageRepository;
|
||||
this.localStorageMapper = localStorageMapper;
|
||||
public LocalStorageServiceImpl(IGenerator generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object queryAll(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||
Page<LocalStorage> page = localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(localStorageMapper::toDto));
|
||||
//@Cacheable
|
||||
public Map<String, Object> queryAll(LocalStorageQueryCriteria criteria, Pageable pageable) {
|
||||
getPage(pageable);
|
||||
PageInfo<LocalStorage> page = new PageInfo<>(baseMapper.selectList(QueryHelpPlus.getPredicate(LocalStorage.class, criteria)));
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content", generator.convert(page.getList(), LocalStorageDto.class));
|
||||
map.put("totalElements", page.getTotal());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public List<LocalStorageDto> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return generator.convert(baseMapper.selectList(QueryHelpPlus.getPredicate(LocalStorage.class, criteria)),LocalStorageDto.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public List<LocalStorageDTO> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.toDto(localStorageRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
public LocalStorageDto findById(Long id) {
|
||||
LocalStorage localStorage = this.getById(id);
|
||||
return generator.convert(localStorage,LocalStorageDto.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public LocalStorageDTO findById(Long id){
|
||||
LocalStorage localStorage = localStorageRepository.findById(id).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull(localStorage.getId(),"LocalStorage","id",id);
|
||||
return localStorageMapper.toDto(localStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LocalStorageDTO create(String name, MultipartFile multipartFile) {
|
||||
public LocalStorageDto create(String name, MultipartFile multipartFile) {
|
||||
FileUtil.checkSize(maxSize, multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
@ -92,48 +92,41 @@ public class LocalStorageServiceImpl implements LocalStorageService {
|
||||
suffix,
|
||||
file.getPath(),
|
||||
type,
|
||||
FileUtil.getSize(file.length()),
|
||||
FileUtil.getSize(multipartFile.getSize()),
|
||||
SecurityUtils.getUsername()
|
||||
);
|
||||
return localStorageMapper.toDto(localStorageRepository.save(localStorage));
|
||||
|
||||
return generator.convert(localStorage,LocalStorageDto.class);
|
||||
}catch (Exception e){
|
||||
FileUtil.del(file);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(LocalStorage resources) {
|
||||
LocalStorage localStorage = localStorageRepository.findById(resources.getId()).orElseGet(LocalStorage::new);
|
||||
ValidationUtil.isNull( localStorage.getId(),"LocalStorage","id",resources.getId());
|
||||
localStorage.copy(resources);
|
||||
localStorageRepository.save(localStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
LocalStorage storage = localStorageRepository.findById(id).orElseGet(LocalStorage::new);
|
||||
LocalStorage storage = this.getById(id);
|
||||
FileUtil.del(storage.getPath());
|
||||
localStorageRepository.delete(storage);
|
||||
this.removeById(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void download(List<LocalStorageDTO> queryAll, HttpServletResponse response) throws IOException {
|
||||
public void download(List<LocalStorageDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LocalStorageDTO localStorageDTO : queryAll) {
|
||||
for (LocalStorageDto localStorage : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", localStorageDTO.getRealName());
|
||||
map.put("备注名", localStorageDTO.getName());
|
||||
map.put("文件类型", localStorageDTO.getType());
|
||||
map.put("文件大小", localStorageDTO.getSize());
|
||||
map.put("操作人", localStorageDTO.getOperate());
|
||||
map.put("创建日期", localStorageDTO.getCreateTime());
|
||||
map.put("文件真实的名称", localStorage.getRealName());
|
||||
map.put("文件名", localStorage.getName());
|
||||
map.put("后缀", localStorage.getSuffix());
|
||||
// map.put("路径", localStorage.getPath());
|
||||
map.put("类型", localStorage.getType());
|
||||
map.put("大小", localStorage.getSize());
|
||||
map.put("操作人", localStorage.getOperate());
|
||||
map.put("创建日期", localStorage.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
|
@ -5,39 +5,52 @@ import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import co.yixiang.domain.Picture;
|
||||
import co.yixiang.service.dto.PictureQueryCriteria;
|
||||
import co.yixiang.utils.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import co.yixiang.repository.PictureRepository;
|
||||
import co.yixiang.service.PictureService;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.utils.TranslatorUtil;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import co.yixiang.utils.YshopConstant;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import co.yixiang.common.utils.QueryHelpPlus;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import co.yixiang.service.PictureService;
|
||||
import co.yixiang.service.dto.PictureDto;
|
||||
import co.yixiang.service.dto.PictureQueryCriteria;
|
||||
import co.yixiang.service.mapper.PictureMapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-27
|
||||
*/
|
||||
@Slf4j
|
||||
@Service(value = "pictureService")
|
||||
@CacheConfig(cacheNames = "picture")
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
//@AllArgsConstructor
|
||||
//@CacheConfig(cacheNames = "picture")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class PictureServiceImpl implements PictureService {
|
||||
public class PictureServiceImpl extends BaseServiceImpl<PictureMapper, Picture> implements PictureService {
|
||||
|
||||
private final IGenerator generator;
|
||||
|
||||
@Value("${smms.token}")
|
||||
private String token;
|
||||
|
||||
private final PictureRepository pictureRepository;
|
||||
|
||||
private static final String SUCCESS = "success";
|
||||
|
||||
@ -45,18 +58,46 @@ public class PictureServiceImpl implements PictureService {
|
||||
|
||||
private static final String MSG = "message";
|
||||
|
||||
public PictureServiceImpl(PictureRepository pictureRepository) {
|
||||
this.pictureRepository = pictureRepository;
|
||||
public PictureServiceImpl(IGenerator generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object queryAll(PictureQueryCriteria criteria, Pageable pageable){
|
||||
return PageUtil.toPage(pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||
//@Cacheable
|
||||
public Map<String, Object> queryAll(PictureQueryCriteria criteria, Pageable pageable) {
|
||||
getPage(pageable);
|
||||
PageInfo<Picture> page = new PageInfo<>(queryAll(criteria));
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content", generator.convert(page.getList(), PictureDto.class));
|
||||
map.put("totalElements", page.getTotal());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Picture> queryAll(PictureQueryCriteria criteria) {
|
||||
return pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
//@Cacheable
|
||||
public List<Picture> queryAll(PictureQueryCriteria criteria){
|
||||
return baseMapper.selectList(QueryHelpPlus.getPredicate(Picture.class, criteria));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void download(List<PictureDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (PictureDto picture : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("上传日期", picture.getCreateTime());
|
||||
map.put("删除的URL", picture.getDeleteUrl());
|
||||
map.put("图片名称", picture.getFilename());
|
||||
map.put("图片高度", picture.getHeight());
|
||||
map.put("图片大小", picture.getSize());
|
||||
map.put("图片地址", picture.getUrl());
|
||||
map.put("用户名称", picture.getUsername());
|
||||
map.put("图片宽度", picture.getWidth());
|
||||
map.put("文件的MD5值", picture.getMd5code());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,9 +105,9 @@ public class PictureServiceImpl implements PictureService {
|
||||
public Picture upload(MultipartFile multipartFile, String username) {
|
||||
File file = FileUtil.toFile(multipartFile);
|
||||
// 验证是否重复上传
|
||||
Picture picture = pictureRepository.findByMd5Code(FileUtil.getMd5(file));
|
||||
Picture picture = this.getOne(new QueryWrapper<Picture>().eq("md5code",FileUtil.getMd5(file)));
|
||||
if(picture != null){
|
||||
return picture;
|
||||
return picture;
|
||||
}
|
||||
HashMap<String, Object> paramMap = new HashMap<>(1);
|
||||
paramMap.put("smfile", file);
|
||||
@ -83,9 +124,9 @@ public class PictureServiceImpl implements PictureService {
|
||||
picture = JSON.parseObject(jsonObject.get("data").toString(), Picture.class);
|
||||
picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize())));
|
||||
picture.setUsername(username);
|
||||
picture.setMd5Code(FileUtil.getMd5(file));
|
||||
picture.setMd5code(FileUtil.getMd5(file));
|
||||
picture.setFilename(FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename())+"."+FileUtil.getExtensionName(multipartFile.getOriginalFilename()));
|
||||
pictureRepository.save(picture);
|
||||
this.save(picture);
|
||||
//删除临时文件
|
||||
FileUtil.del(file);
|
||||
return picture;
|
||||
@ -94,7 +135,7 @@ public class PictureServiceImpl implements PictureService {
|
||||
|
||||
@Override
|
||||
public Picture findById(Long id) {
|
||||
Picture picture = pictureRepository.findById(id).orElseGet(Picture::new);
|
||||
Picture picture = this.getById(id);
|
||||
ValidationUtil.isNull(picture.getId(),"Picture","id",id);
|
||||
return picture;
|
||||
}
|
||||
@ -104,10 +145,10 @@ public class PictureServiceImpl implements PictureService {
|
||||
for (Long id : ids) {
|
||||
Picture picture = findById(id);
|
||||
try {
|
||||
HttpUtil.get(picture.getDelete());
|
||||
pictureRepository.delete(picture);
|
||||
HttpUtil.get(picture.getDeleteUrl());
|
||||
this.removeById(id);
|
||||
} catch(Exception e){
|
||||
pictureRepository.delete(picture);
|
||||
this.removeById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,30 +164,12 @@ public class PictureServiceImpl implements PictureService {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(result);
|
||||
List<Picture> pictures = JSON.parseArray(jsonObject.get("data").toString(), Picture.class);
|
||||
for (Picture picture : pictures) {
|
||||
if(!pictureRepository.existsByUrl(picture.getUrl())){
|
||||
if(this.getOne(new QueryWrapper<Picture>().eq("url",picture.getUrl()))==null){
|
||||
picture.setSize(FileUtil.getSize(Integer.parseInt(picture.getSize())));
|
||||
picture.setUsername("System Sync");
|
||||
picture.setMd5Code("");
|
||||
pictureRepository.save(picture);
|
||||
picture.setMd5code("");
|
||||
this.save(picture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<Picture> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (Picture picture : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", picture.getFilename());
|
||||
map.put("图片地址", picture.getUrl());
|
||||
map.put("文件大小", picture.getSize());
|
||||
map.put("操作人", picture.getUsername());
|
||||
map.put("高度", picture.getHeight());
|
||||
map.put("宽度", picture.getWidth());
|
||||
map.put("删除地址", picture.getDelete());
|
||||
map.put("创建日期", picture.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,16 @@ package co.yixiang.service.impl;
|
||||
|
||||
import co.yixiang.domain.QiniuConfig;
|
||||
import co.yixiang.domain.QiniuContent;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.service.QiNiuService;
|
||||
import co.yixiang.service.QiniuConfigService;
|
||||
import co.yixiang.service.QiniuContentService;
|
||||
import co.yixiang.service.dto.QiniuConfigDto;
|
||||
import co.yixiang.utils.QiNiuUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
|
||||
import com.qiniu.common.QiniuException;
|
||||
import com.qiniu.http.Response;
|
||||
import com.qiniu.storage.BucketManager;
|
||||
@ -13,14 +20,13 @@ import com.qiniu.storage.UploadManager;
|
||||
import com.qiniu.storage.model.DefaultPutRet;
|
||||
import com.qiniu.storage.model.FileInfo;
|
||||
import com.qiniu.util.Auth;
|
||||
import co.yixiang.repository.QiniuContentRepository;
|
||||
import co.yixiang.service.dto.QiniuQueryCriteria;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.repository.QiNiuConfigRepository;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import co.yixiang.utils.PageUtil;
|
||||
import co.yixiang.utils.QueryHelp;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import org.mapstruct.ap.internal.model.assignment.UpdateWrapper;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@ -44,34 +50,37 @@ import java.util.*;
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class QiNiuServiceImpl implements QiNiuService {
|
||||
|
||||
private final QiNiuConfigRepository qiNiuConfigRepository;
|
||||
private final QiniuConfigService qiniuConfigService;
|
||||
|
||||
private final QiniuContentRepository qiniuContentRepository;
|
||||
private final QiniuContentService qiniuContentService;
|
||||
|
||||
public QiNiuServiceImpl(QiNiuConfigRepository qiNiuConfigRepository, QiniuContentRepository qiniuContentRepository) {
|
||||
this.qiNiuConfigRepository = qiNiuConfigRepository;
|
||||
this.qiniuContentRepository = qiniuContentRepository;
|
||||
}
|
||||
private final IGenerator generator;
|
||||
|
||||
@Value("${qiniu.max-size}")
|
||||
private Long maxSize;
|
||||
|
||||
public QiNiuServiceImpl(QiniuConfigService qiniuConfigService, QiniuContentService qiniuContentService, IGenerator generator) {
|
||||
this.qiniuConfigService = qiniuConfigService;
|
||||
this.qiniuContentService = qiniuContentService;
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable
|
||||
public Object queryAll(QiniuQueryCriteria criteria, Pageable pageable){
|
||||
return PageUtil.toPage(qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable));
|
||||
return qiniuContentService.queryAll(criteria,pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QiniuContent> queryAll(QiniuQueryCriteria criteria) {
|
||||
return qiniuContentRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
|
||||
return qiniuContentService.queryAll(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'1'")
|
||||
public QiniuConfig find() {
|
||||
Optional<QiniuConfig> qiniuConfig = qiNiuConfigRepository.findById(1L);
|
||||
return qiniuConfig.orElseGet(QiniuConfig::new);
|
||||
QiniuConfig qiniuConfig = qiniuConfigService.getById(1L);
|
||||
return qiniuConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -83,7 +92,8 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
throw new BadRequestException("外链域名必须以http://或者https://开头");
|
||||
}
|
||||
qiniuConfig.setId(1L);
|
||||
return qiNiuConfigRepository.save(qiniuConfig);
|
||||
qiniuConfigService.save(qiniuConfig);
|
||||
return qiniuConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,7 +111,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
String upToken = auth.uploadToken(qiniuConfig.getBucket());
|
||||
try {
|
||||
String key = file.getOriginalFilename();
|
||||
if(qiniuContentRepository.findByKey(key) != null) {
|
||||
if(qiniuContentService.getOne(new QueryWrapper<QiniuContent>().eq("name",key)) != null) {
|
||||
key = QiNiuUtil.getKey(key);
|
||||
}
|
||||
Response response = uploadManager.put(file.getBytes(), key, upToken);
|
||||
@ -113,10 +123,11 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
qiniuContent.setSuffix(FileUtil.getExtensionName(putRet.key));
|
||||
qiniuContent.setBucket(qiniuConfig.getBucket());
|
||||
qiniuContent.setType(qiniuConfig.getType());
|
||||
qiniuContent.setKey(FileUtil.getFileNameNoEx(putRet.key));
|
||||
qiniuContent.setName(FileUtil.getFileNameNoEx(putRet.key));
|
||||
qiniuContent.setUrl(qiniuConfig.getHost()+"/"+putRet.key);
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(file.getSize()+"")));
|
||||
return qiniuContentRepository.save(qiniuContent);
|
||||
qiniuContentService.save(qiniuContent);
|
||||
return qiniuContent;
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
@ -125,8 +136,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
@Override
|
||||
@Cacheable
|
||||
public QiniuContent findByContentId(Long id) {
|
||||
QiniuContent qiniuContent = qiniuContentRepository.findById(id).orElseGet(QiniuContent::new);
|
||||
ValidationUtil.isNull(qiniuContent.getId(),"QiniuContent", "id",id);
|
||||
QiniuContent qiniuContent = qiniuContentService.getById(id);
|
||||
return qiniuContent;
|
||||
}
|
||||
|
||||
@ -155,10 +165,10 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||
try {
|
||||
bucketManager.delete(content.getBucket(), content.getKey() + "." + content.getSuffix());
|
||||
qiniuContentRepository.delete(content);
|
||||
bucketManager.delete(content.getBucket(), content.getName() + "." + content.getSuffix());
|
||||
qiniuContentService.removeById(content.getId());
|
||||
} catch (QiniuException ex) {
|
||||
qiniuContentRepository.delete(content);
|
||||
qiniuConfigService.removeById(content.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,15 +196,16 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
QiniuContent qiniuContent;
|
||||
FileInfo[] items = fileListIterator.next();
|
||||
for (FileInfo item : items) {
|
||||
if(qiniuContentRepository.findByKey(FileUtil.getFileNameNoEx(item.key)) == null){
|
||||
if(qiniuContentService.getOne(new QueryWrapper<QiniuContent>().eq("name",FileUtil.getFileNameNoEx(item.key)))
|
||||
== null){
|
||||
qiniuContent = new QiniuContent();
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(item.fsize+"")));
|
||||
qiniuContent.setSuffix(FileUtil.getExtensionName(item.key));
|
||||
qiniuContent.setKey(FileUtil.getFileNameNoEx(item.key));
|
||||
qiniuContent.setName(FileUtil.getFileNameNoEx(item.key));
|
||||
qiniuContent.setType(config.getType());
|
||||
qiniuContent.setBucket(config.getBucket());
|
||||
qiniuContent.setUrl(config.getHost()+"/"+item.key);
|
||||
qiniuContentRepository.save(qiniuContent);
|
||||
qiniuContentService.save(qiniuContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -212,7 +223,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
@CacheEvict(allEntries = true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(String type) {
|
||||
qiNiuConfigRepository.update(type);
|
||||
qiniuConfigService.update(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -220,7 +231,7 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QiniuContent content : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", content.getKey());
|
||||
map.put("文件名", content.getName());
|
||||
map.put("文件类型", content.getSuffix());
|
||||
map.put("空间名称", content.getBucket());
|
||||
map.put("文件大小", content.getSize());
|
||||
|
@ -0,0 +1,87 @@
|
||||
package co.yixiang.service.impl;
|
||||
|
||||
import co.yixiang.domain.QiniuConfig;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.service.dto.QiniuQueryCriteria;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import co.yixiang.common.utils.QueryHelpPlus;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import co.yixiang.service.QiniuConfigService;
|
||||
import co.yixiang.service.dto.QiniuConfigDto;
|
||||
import co.yixiang.service.dto.QiniuConfigQueryCriteria;
|
||||
import co.yixiang.service.mapper.QiniuConfigMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import co.yixiang.utils.PageUtil;
|
||||
import co.yixiang.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
//@CacheConfig(cacheNames = "qiniuConfig")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class QiniuConfigServiceImpl extends BaseServiceImpl<QiniuConfigMapper, QiniuConfig> implements QiniuConfigService {
|
||||
|
||||
private final IGenerator generator;
|
||||
|
||||
private final QiniuConfigMapper qiniuConfigMapper;
|
||||
@Override
|
||||
//@Cacheable
|
||||
public Map<String, Object> queryAll(QiniuQueryCriteria criteria, Pageable pageable) {
|
||||
getPage(pageable);
|
||||
PageInfo<QiniuConfig> page = new PageInfo<>(queryAll(criteria));
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content", generator.convert(page.getList(), QiniuConfigDto.class));
|
||||
map.put("totalElements", page.getTotal());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public List<QiniuConfig> queryAll(QiniuQueryCriteria criteria){
|
||||
return baseMapper.selectList(QueryHelpPlus.getPredicate(QiniuConfig.class, criteria));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void download(List<QiniuConfigDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QiniuConfigDto qiniuConfig : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("accessKey", qiniuConfig.getAccessKey());
|
||||
map.put("Bucket 识别符", qiniuConfig.getBucket());
|
||||
map.put("外链域名", qiniuConfig.getHost());
|
||||
map.put("secretKey", qiniuConfig.getSecretKey());
|
||||
map.put("空间类型", qiniuConfig.getType());
|
||||
map.put("机房", qiniuConfig.getZone());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String type) {
|
||||
qiniuConfigMapper.updateType(type);
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package co.yixiang.service.impl;
|
||||
|
||||
import co.yixiang.domain.QiniuContent;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.service.dto.QiniuQueryCriteria;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import co.yixiang.common.utils.QueryHelpPlus;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import co.yixiang.utils.FileUtil;
|
||||
import co.yixiang.service.QiniuContentService;
|
||||
import co.yixiang.service.dto.QiniuContentDto;
|
||||
import co.yixiang.service.dto.QiniuContentQueryCriteria;
|
||||
import co.yixiang.service.mapper.QiniuContentMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import co.yixiang.utils.PageUtil;
|
||||
import co.yixiang.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
//@CacheConfig(cacheNames = "qiniuContent")
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class QiniuContentServiceImpl extends BaseServiceImpl<QiniuContentMapper, QiniuContent> implements QiniuContentService {
|
||||
|
||||
private final IGenerator generator;
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public Map<String, Object> queryAll(QiniuQueryCriteria criteria, Pageable pageable) {
|
||||
getPage(pageable);
|
||||
PageInfo<QiniuContent> page = new PageInfo<>(queryAll(criteria));
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content", generator.convert(page.getList(), QiniuContentDto.class));
|
||||
map.put("totalElements", page.getTotal());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public List<QiniuContent> queryAll(QiniuQueryCriteria criteria){
|
||||
return baseMapper.selectList(QueryHelpPlus.getPredicate(QiniuContent.class, criteria));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void download(List<QiniuContentDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QiniuContentDto qiniuContent : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("Bucket 识别符", qiniuContent.getBucket());
|
||||
map.put("文件名称", qiniuContent.getName());
|
||||
map.put("文件大小", qiniuContent.getSize());
|
||||
map.put("文件类型:私有或公开", qiniuContent.getType());
|
||||
map.put("上传或同步的时间", qiniuContent.getUpdateTime());
|
||||
map.put("文件url", qiniuContent.getUrl());
|
||||
map.put(" suffix", qiniuContent.getSuffix());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.service.mapper;
|
||||
|
||||
import co.yixiang.common.mapper.CoreMapper;
|
||||
import co.yixiang.domain.AlipayConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface AlipayConfigMapper extends CoreMapper<AlipayConfig> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.service.mapper;
|
||||
|
||||
import co.yixiang.common.mapper.CoreMapper;
|
||||
import co.yixiang.domain.EmailConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface EmailConfigMapper extends CoreMapper<EmailConfig> {
|
||||
|
||||
}
|
@ -1,16 +1,16 @@
|
||||
package co.yixiang.service.mapper;
|
||||
|
||||
import co.yixiang.common.mapper.CoreMapper;
|
||||
import co.yixiang.domain.LocalStorage;
|
||||
import co.yixiang.service.dto.LocalStorageDTO;
|
||||
import co.yixiang.base.BaseMapper;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface LocalStorageMapper extends BaseMapper<LocalStorageDTO, LocalStorage> {
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface LocalStorageMapper extends CoreMapper<LocalStorage> {
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.service.mapper;
|
||||
|
||||
import co.yixiang.common.mapper.CoreMapper;
|
||||
import co.yixiang.domain.Picture;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface PictureMapper extends CoreMapper<Picture> {
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package co.yixiang.service.mapper;
|
||||
|
||||
import co.yixiang.base.BaseEntity;
|
||||
import co.yixiang.common.mapper.CoreMapper;
|
||||
import co.yixiang.domain.QiniuConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface QiniuConfigMapper extends CoreMapper<QiniuConfig> {
|
||||
|
||||
|
||||
@Update("update qiniu_config set type = #{type} ")
|
||||
void updateType(@Param("type") String type);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.service.mapper;
|
||||
|
||||
import co.yixiang.common.mapper.CoreMapper;
|
||||
import co.yixiang.domain.QiniuContent;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* @date 2020-05-13
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface QiniuContentMapper extends CoreMapper<QiniuContent> {
|
||||
|
||||
}
|
Reference in New Issue
Block a user