first commit
This commit is contained in:
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 支付宝配置类
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("tool_alipay_config")
|
||||
public class AlipayConfig implements Serializable {
|
||||
|
||||
@TableId("config_id")
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "应用ID")
|
||||
private String appId;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "商户私钥")
|
||||
private String privateKey;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "支付宝公钥")
|
||||
private String publicKey;
|
||||
|
||||
@ApiModelProperty(value = "签名方式")
|
||||
private String signType="RSA2";
|
||||
|
||||
@ApiModelProperty(value = "支付宝开放安全地址", hidden = true)
|
||||
private String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
|
||||
|
||||
@ApiModelProperty(value = "编码", hidden = true)
|
||||
private String charset= "utf-8";
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "异步通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "订单完成后返回的页面")
|
||||
private String returnUrl;
|
||||
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String format="JSON";
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "商户号")
|
||||
private String sysServiceProviderId;
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 邮件配置类,数据存覆盖式存入数据存
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
@Data
|
||||
@TableName("tool_email_config")
|
||||
public class EmailConfig implements Serializable {
|
||||
|
||||
@TableId("config_id")
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "邮件服务器SMTP地址")
|
||||
private String host;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "邮件服务器 SMTP 端口")
|
||||
private String port;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "发件者用户名")
|
||||
private String user;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String pass;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "收件人")
|
||||
private String fromUser;
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.fuyuanshen.base.BaseEntity;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@TableName("tool_local_storage")
|
||||
public class LocalStorage extends BaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "storage_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "真实文件名")
|
||||
private String realName;
|
||||
|
||||
@ApiModelProperty(value = "文件名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "后缀")
|
||||
private String suffix;
|
||||
|
||||
@ApiModelProperty(value = "路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "大小")
|
||||
private String size;
|
||||
|
||||
public LocalStorage(String realName,String name, String suffix, String path, String type, String size) {
|
||||
this.realName = realName;
|
||||
this.name = name;
|
||||
this.suffix = suffix;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void copy(LocalStorage source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 七牛云对象存储配置类
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("tool_qiniu_config")
|
||||
public class QiniuConfig implements Serializable {
|
||||
|
||||
@TableId("config_id")
|
||||
private Long id;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "accessKey")
|
||||
private String accessKey;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "secretKey")
|
||||
private String secretKey;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "存储空间名称作为唯一的 Bucket 识别符")
|
||||
private String bucket;
|
||||
|
||||
/**
|
||||
* Zone表示与机房的对应关系
|
||||
* 华东 Zone.zone0()
|
||||
* 华北 Zone.zone1()
|
||||
* 华南 Zone.zone2()
|
||||
* 北美 Zone.zoneNa0()
|
||||
* 东南亚 Zone.zoneAs0()
|
||||
*/
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "Zone表示与机房的对应关系")
|
||||
private String zone;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "外链域名,可自定义,需在七牛云绑定")
|
||||
private String host;
|
||||
|
||||
@ApiModelProperty(value = "空间类型:公开/私有")
|
||||
private String type = "公开";
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 上传成功后,存储结果
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
@TableName("tool_qiniu_content")
|
||||
public class QiniuContent implements Serializable {
|
||||
|
||||
@TableId(value = "content_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@TableField("name")
|
||||
@ApiModelProperty(value = "文件名")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "空间名")
|
||||
private String bucket;
|
||||
|
||||
@ApiModelProperty(value = "大小")
|
||||
private String size;
|
||||
|
||||
@ApiModelProperty(value = "文件地址")
|
||||
private String url;
|
||||
|
||||
@ApiModelProperty(value = "文件类型")
|
||||
private String suffix;
|
||||
|
||||
@ApiModelProperty(value = "空间类型:公开/私有")
|
||||
private String type = "公开";
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@ApiModelProperty(value = "创建或更新时间")
|
||||
private Timestamp updateTime;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 发送邮件时,接收参数的类
|
||||
* @author 郑杰
|
||||
* @date 2018/09/28 12:02:14
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EmailDto {
|
||||
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "收件人")
|
||||
private List<String> tos;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "主题")
|
||||
private String subject;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Data
|
||||
public class LocalStorageQueryCriteria{
|
||||
|
||||
@ApiModelProperty(value = "模糊查询")
|
||||
private String blurry;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Timestamp> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-6-4 09:54:37
|
||||
*/
|
||||
@Data
|
||||
public class QiniuQueryCriteria{
|
||||
|
||||
@ApiModelProperty(value = "名称查询")
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private List<Timestamp> createTime;
|
||||
|
||||
@ApiModelProperty(value = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@ApiModelProperty(value = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 交易详情,按需应该存入数据库,这里存入数据库,仅供临时测试
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Data
|
||||
public class TradeDto {
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
private String body;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String subject;
|
||||
|
||||
@ApiModelProperty(value = "商户订单号", hidden = true)
|
||||
private String outTradeNo;
|
||||
|
||||
@ApiModelProperty(value = "第三方订单号", hidden = true)
|
||||
private String tradeNo;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "价格")
|
||||
private String totalAmount;
|
||||
|
||||
@ApiModelProperty(value = "订单状态,已支付,未支付,作废", hidden = true)
|
||||
private String state;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||
private Timestamp createTime;
|
||||
|
||||
@ApiModelProperty(value = "作废时间", hidden = true)
|
||||
private Date cancelTime;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.domain.enums;
|
||||
|
||||
/**
|
||||
* 支付状态
|
||||
* @author zhengjie
|
||||
* @date 2018/08/01 16:45:43
|
||||
*/
|
||||
public enum AliPayStatusEnum {
|
||||
|
||||
/** 交易成功 */
|
||||
FINISHED("TRADE_FINISHED"),
|
||||
|
||||
/** 支付成功 */
|
||||
SUCCESS("TRADE_SUCCESS"),
|
||||
|
||||
/** 交易创建 */
|
||||
BUYER_PAY("WAIT_BUYER_PAY"),
|
||||
|
||||
/** 交易关闭 */
|
||||
CLOSED("TRADE_CLOSED");
|
||||
|
||||
private final String value;
|
||||
|
||||
AliPayStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuyuanshen.domain.AlipayConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @description
|
||||
* @date 2023-06-14
|
||||
**/
|
||||
@Mapper
|
||||
public interface AliPayConfigMapper extends BaseMapper<AlipayConfig> {
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuyuanshen.domain.EmailConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @description
|
||||
* @date 2023-06-14
|
||||
**/
|
||||
@Mapper
|
||||
public interface EmailConfigMapper extends BaseMapper<EmailConfig> {
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.domain.LocalStorage;
|
||||
import com.fuyuanshen.domain.dto.LocalStorageQueryCriteria;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @description
|
||||
* @date 2023-06-14
|
||||
**/
|
||||
@Mapper
|
||||
public interface LocalStorageMapper extends BaseMapper<LocalStorage> {
|
||||
|
||||
IPage<LocalStorage> findAll(@Param("criteria") LocalStorageQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
List<LocalStorage> findAll(@Param("criteria") LocalStorageQueryCriteria criteria);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuyuanshen.domain.EmailConfig;
|
||||
import com.fuyuanshen.domain.QiniuConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @description
|
||||
* @date 2023-06-14
|
||||
**/
|
||||
@Mapper
|
||||
public interface QiniuConfigMapper extends BaseMapper<QiniuConfig> {
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.domain.QiniuContent;
|
||||
import com.fuyuanshen.domain.dto.QiniuQueryCriteria;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @description
|
||||
* @date 2023-06-14
|
||||
**/
|
||||
@Mapper
|
||||
public interface QiniuContentMapper extends BaseMapper<QiniuContent> {
|
||||
|
||||
QiniuContent findByKey(@Param("name") String name);
|
||||
|
||||
IPage<QiniuContent> findAll(@Param("criteria") QiniuQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
List<QiniuContent> findAll(QiniuQueryCriteria criteria);
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.rest;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.fuyuanshen.annotation.rest.AnonymousAccess;
|
||||
import com.fuyuanshen.annotation.Log;
|
||||
import com.fuyuanshen.annotation.rest.AnonymousGetMapping;
|
||||
import com.fuyuanshen.domain.dto.TradeDto;
|
||||
import com.fuyuanshen.domain.AlipayConfig;
|
||||
import com.fuyuanshen.domain.enums.AliPayStatusEnum;
|
||||
import com.fuyuanshen.utils.AlipayUtils;
|
||||
import com.fuyuanshen.service.AliPayService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/aliPay")
|
||||
@Api(tags = "工具:支付宝管理")
|
||||
public class AliPayController {
|
||||
|
||||
private final AlipayUtils alipayUtils;
|
||||
private final AliPayService alipayService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<AlipayConfig> queryAliConfig() {
|
||||
return new ResponseEntity<>(alipayService.find(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("配置支付宝")
|
||||
@ApiOperation("配置支付宝")
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> updateAliPayConfig(@Validated @RequestBody AlipayConfig alipayConfig) {
|
||||
alipayService.config(alipayConfig);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("支付宝PC网页支付")
|
||||
@ApiOperation("PC网页支付")
|
||||
@PostMapping(value = "/toPayAsPC")
|
||||
public ResponseEntity<String> toPayAsPc(@Validated @RequestBody TradeDto trade) throws Exception {
|
||||
AlipayConfig aliPay = alipayService.find();
|
||||
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
||||
String payUrl = alipayService.toPayAsPc(aliPay, trade);
|
||||
return ResponseEntity.ok(payUrl);
|
||||
}
|
||||
|
||||
@Log("支付宝手机网页支付")
|
||||
@ApiOperation("手机网页支付")
|
||||
@PostMapping(value = "/toPayAsWeb")
|
||||
public ResponseEntity<String> toPayAsWeb(@Validated @RequestBody TradeDto trade) throws Exception {
|
||||
AlipayConfig alipay = alipayService.find();
|
||||
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
||||
String payUrl = alipayService.toPayAsWeb(alipay, trade);
|
||||
return ResponseEntity.ok(payUrl);
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@AnonymousGetMapping("/return")
|
||||
@ApiOperation("支付之后跳转的链接")
|
||||
public ResponseEntity<String> returnPage(HttpServletRequest request, HttpServletResponse response) {
|
||||
AlipayConfig alipay = alipayService.find();
|
||||
response.setContentType("text/html;charset=" + alipay.getCharset());
|
||||
//内容验签,防止黑客篡改参数
|
||||
if (alipayUtils.rsaCheck(request, alipay)) {
|
||||
//商户订单号
|
||||
String outTradeNo = new String(request.getParameter("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
//支付宝交易号
|
||||
String tradeNo = new String(request.getParameter("trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
System.out.println("商户订单号" + outTradeNo + " " + "第三方交易号" + tradeNo);
|
||||
|
||||
// 根据业务需要返回数据,这里统一返回OK
|
||||
return new ResponseEntity<>("payment successful", HttpStatus.OK);
|
||||
} else {
|
||||
// 根据业务需要返回数据
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@RequestMapping("/notify")
|
||||
@AnonymousAccess
|
||||
@ApiOperation("支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理")
|
||||
public ResponseEntity<Object> notify(HttpServletRequest request) {
|
||||
AlipayConfig alipay = alipayService.find();
|
||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||
//内容验签,防止黑客篡改参数
|
||||
if (alipayUtils.rsaCheck(request, alipay)) {
|
||||
//交易状态
|
||||
String tradeStatus = new String(request.getParameter("trade_status").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
// 商户订单号
|
||||
String outTradeNo = new String(request.getParameter("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
//支付宝交易号
|
||||
String tradeNo = new String(request.getParameter("trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
//付款金额
|
||||
String totalAmount = new String(request.getParameter("total_amount").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||
//验证
|
||||
if (tradeStatus.equals(AliPayStatusEnum.SUCCESS.getValue()) || tradeStatus.equals(AliPayStatusEnum.FINISHED.getValue())) {
|
||||
// 验证通过后应该根据业务需要处理订单
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.rest;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.annotation.Log;
|
||||
import com.fuyuanshen.domain.dto.EmailDto;
|
||||
import com.fuyuanshen.domain.EmailConfig;
|
||||
import com.fuyuanshen.service.EmailService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
* @author 郑杰
|
||||
* @date 2018/09/28 6:55:53
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("api/email")
|
||||
@Api(tags = "工具:邮件管理")
|
||||
public class EmailController {
|
||||
|
||||
private final EmailService emailService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<EmailConfig> queryEmailConfig(){
|
||||
return new ResponseEntity<>(emailService.find(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("配置邮件")
|
||||
@PutMapping
|
||||
@ApiOperation("配置邮件")
|
||||
public ResponseEntity<Object> updateEmailConfig(@Validated @RequestBody EmailConfig emailConfig) throws Exception {
|
||||
emailService.config(emailConfig, emailService.find());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("发送邮件")
|
||||
@PostMapping
|
||||
@ApiOperation("发送邮件")
|
||||
public ResponseEntity<Object> sendEmail(@Validated @RequestBody EmailDto emailDto){
|
||||
emailService.send(emailDto,emailService.find());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.rest;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.annotation.Log;
|
||||
import com.fuyuanshen.domain.LocalStorage;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.service.LocalStorageService;
|
||||
import com.fuyuanshen.domain.dto.LocalStorageQueryCriteria;
|
||||
import com.fuyuanshen.utils.FileUtil;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "工具:本地存储管理")
|
||||
@RequestMapping("/api/localStorage")
|
||||
public class LocalStorageController {
|
||||
|
||||
private final LocalStorageService localStorageService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询文件")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public ResponseEntity<PageResult<LocalStorage>> queryFile(LocalStorageQueryCriteria criteria){
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(localStorageService.queryAll(criteria,page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('storage:list')")
|
||||
public void exportFile(HttpServletResponse response, LocalStorageQueryCriteria criteria) throws IOException {
|
||||
localStorageService.download(localStorageService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("上传文件")
|
||||
@PreAuthorize("@el.check('storage:add')")
|
||||
public ResponseEntity<Object> createFile(@RequestParam String name, @RequestParam("file") MultipartFile file){
|
||||
localStorageService.create(name, file);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("上传图片")
|
||||
@PostMapping("/pictures")
|
||||
public ResponseEntity<LocalStorage> uploadPicture(@RequestParam MultipartFile file){
|
||||
// 判断文件是否为图片
|
||||
String suffix = FileUtil.getExtensionName(file.getOriginalFilename());
|
||||
if(!FileUtil.IMAGE.equals(FileUtil.getFileType(suffix))){
|
||||
throw new BadRequestException("只能上传图片");
|
||||
}
|
||||
LocalStorage localStorage = localStorageService.create(null, file);
|
||||
return new ResponseEntity<>(localStorage, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改文件")
|
||||
@ApiOperation("修改文件")
|
||||
@PreAuthorize("@el.check('storage:edit')")
|
||||
public ResponseEntity<Object> updateFile(@Validated @RequestBody LocalStorage resources){
|
||||
localStorageService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除文件")
|
||||
@DeleteMapping
|
||||
@ApiOperation("多选删除")
|
||||
public ResponseEntity<Object> deleteFile(@RequestBody Long[] ids) {
|
||||
localStorageService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
125
fys-tools/src/main/java/com/fuyuanshen/rest/QiniuController.java
Normal file
125
fys-tools/src/main/java/com/fuyuanshen/rest/QiniuController.java
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.rest;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.fuyuanshen.annotation.Log;
|
||||
import com.fuyuanshen.domain.QiniuConfig;
|
||||
import com.fuyuanshen.domain.QiniuContent;
|
||||
import com.fuyuanshen.service.QiNiuConfigService;
|
||||
import com.fuyuanshen.domain.dto.QiniuQueryCriteria;
|
||||
import com.fuyuanshen.service.QiniuContentService;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
* @author 郑杰
|
||||
* @date 2018/09/28 6:55:53
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/qiNiuContent")
|
||||
@Api(tags = "工具:七牛云存储管理")
|
||||
public class QiniuController {
|
||||
|
||||
private final QiniuContentService qiniuContentService;
|
||||
private final QiNiuConfigService qiNiuConfigService;
|
||||
|
||||
@GetMapping(value = "/config")
|
||||
public ResponseEntity<QiniuConfig> queryQiNiuConfig(){
|
||||
return new ResponseEntity<>(qiNiuConfigService.getConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("配置七牛云存储")
|
||||
@ApiOperation("配置七牛云存储")
|
||||
@PutMapping(value = "/config")
|
||||
public ResponseEntity<Object> updateQiNiuConfig(@Validated @RequestBody QiniuConfig qiniuConfig){
|
||||
qiNiuConfigService.saveConfig(qiniuConfig);
|
||||
qiNiuConfigService.updateType(qiniuConfig.getType());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void exportQiNiu(HttpServletResponse response, QiniuQueryCriteria criteria) throws IOException {
|
||||
qiniuContentService.downloadList(qiniuContentService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询文件")
|
||||
@GetMapping
|
||||
public ResponseEntity<PageResult<QiniuContent>> queryQiNiu(QiniuQueryCriteria criteria){
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(qiniuContentService.queryAll(criteria, page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> uploadQiNiu(@RequestParam MultipartFile file){
|
||||
QiniuContent qiniuContent = qiniuContentService.upload(file, qiNiuConfigService.getConfig());
|
||||
Map<String,Object> map = new HashMap<>(3);
|
||||
map.put("id",qiniuContent.getId());
|
||||
map.put("errno",0);
|
||||
map.put("data",new String[]{qiniuContent.getUrl()});
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("同步七牛云数据")
|
||||
@ApiOperation("同步七牛云数据")
|
||||
@PostMapping(value = "/synchronize")
|
||||
public ResponseEntity<Object> synchronizeQiNiu(){
|
||||
qiniuContentService.synchronize(qiNiuConfigService.getConfig());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("下载文件")
|
||||
@ApiOperation("下载文件")
|
||||
@GetMapping(value = "/download/{id}")
|
||||
public ResponseEntity<Object> downloadQiNiu(@PathVariable Long id){
|
||||
Map<String,Object> map = new HashMap<>(1);
|
||||
map.put("url", qiniuContentService.download(qiniuContentService.getById(id), qiNiuConfigService.getConfig()));
|
||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("删除文件")
|
||||
@ApiOperation("删除文件")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public ResponseEntity<Object> deleteQiNiu(@PathVariable Long id){
|
||||
qiniuContentService.delete(qiniuContentService.getById(id), qiNiuConfigService.getConfig());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("删除多张图片")
|
||||
@ApiOperation("删除多张图片")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAllQiNiu(@RequestBody Long[] ids) {
|
||||
qiniuContentService.deleteAll(ids, qiNiuConfigService.getConfig());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.domain.dto.TradeDto;
|
||||
import com.fuyuanshen.domain.AlipayConfig;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface AliPayService extends IService<AlipayConfig> {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
* @return AlipayConfig
|
||||
*/
|
||||
AlipayConfig find();
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
* @param alipayConfig 支付宝配置
|
||||
* @return AlipayConfig
|
||||
*/
|
||||
AlipayConfig config(AlipayConfig alipayConfig);
|
||||
|
||||
/**
|
||||
* 处理来自PC的交易请求
|
||||
* @param alipay 支付宝配置
|
||||
* @param trade 交易详情
|
||||
* @return String
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
String toPayAsPc(AlipayConfig alipay, TradeDto trade) throws Exception;
|
||||
|
||||
/**
|
||||
* 处理来自手机网页的交易请求
|
||||
* @param alipay 支付宝配置
|
||||
* @param trade 交易详情
|
||||
* @return String
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
String toPayAsWeb(AlipayConfig alipay, TradeDto trade) throws Exception;
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.domain.dto.EmailDto;
|
||||
import com.fuyuanshen.domain.EmailConfig;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
public interface EmailService extends IService<EmailConfig> {
|
||||
|
||||
/**
|
||||
* 更新邮件配置
|
||||
* @param emailConfig 邮箱配置
|
||||
* @param old /
|
||||
* @return /
|
||||
* @throws Exception /
|
||||
*/
|
||||
EmailConfig config(EmailConfig emailConfig, EmailConfig old) throws Exception;
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
* @return EmailConfig 邮件配置
|
||||
*/
|
||||
EmailConfig find();
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
* @param emailDto 邮件发送的内容
|
||||
* @param emailConfig 邮件配置
|
||||
*/
|
||||
void send(EmailDto emailDto, EmailConfig emailConfig);
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.domain.LocalStorage;
|
||||
import com.fuyuanshen.domain.dto.LocalStorageQueryCriteria;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
public interface LocalStorageService extends IService<LocalStorage> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<LocalStorage> queryAll(LocalStorageQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<LocalStorage> queryAll(LocalStorageQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param name 文件名称
|
||||
* @param file 文件
|
||||
* @return /
|
||||
*/
|
||||
LocalStorage create(String name, MultipartFile file);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources 文件信息
|
||||
*/
|
||||
void update(LocalStorage resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param localStorages 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<LocalStorage> localStorages, HttpServletResponse response) throws IOException;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.domain.QiniuConfig;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface QiNiuConfigService extends IService<QiniuConfig> {
|
||||
|
||||
/**
|
||||
* 查询配置
|
||||
* @return QiniuConfig
|
||||
*/
|
||||
QiniuConfig getConfig();
|
||||
|
||||
/**
|
||||
* 保存
|
||||
* @param type 类型
|
||||
*/
|
||||
void saveConfig(QiniuConfig type);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param type 类型
|
||||
*/
|
||||
void updateType(String type);
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.domain.QiniuConfig;
|
||||
import com.fuyuanshen.domain.QiniuContent;
|
||||
import com.fuyuanshen.domain.dto.QiniuQueryCriteria;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public interface QiniuContentService extends IService<QiniuContent> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param page 分页参数
|
||||
* @return /
|
||||
*/
|
||||
PageResult<QiniuContent> queryAll(QiniuQueryCriteria criteria, Page<Object> page);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
* @param criteria 条件
|
||||
* @return /
|
||||
*/
|
||||
List<QiniuContent> queryAll(QiniuQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file 文件
|
||||
* @param qiniuConfig 配置
|
||||
* @return QiniuContent
|
||||
*/
|
||||
QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig);
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @param content 文件信息
|
||||
* @param config 配置
|
||||
* @return String
|
||||
*/
|
||||
String download(QiniuContent content, QiniuConfig config);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param content 文件
|
||||
* @param config 配置
|
||||
*/
|
||||
void delete(QiniuContent content, QiniuConfig config);
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
* @param config 配置
|
||||
*/
|
||||
void synchronize(QiniuConfig config);
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
* @param ids 文件ID数组
|
||||
* @param config 配置
|
||||
*/
|
||||
void deleteAll(Long[] ids, QiniuConfig config);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
* @param queryAll /
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void downloadList(List<QiniuContent> queryAll, HttpServletResponse response) throws IOException;
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service.impl;
|
||||
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.request.AlipayTradePagePayRequest;
|
||||
import com.alipay.api.request.AlipayTradeWapPayRequest;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.domain.dto.TradeDto;
|
||||
import com.fuyuanshen.domain.AlipayConfig;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.mapper.AliPayConfigMapper;
|
||||
import com.fuyuanshen.service.AliPayService;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "aliPay")
|
||||
public class AliPayServiceImpl extends ServiceImpl<AliPayConfigMapper, AlipayConfig> implements AliPayService {
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public AlipayConfig find() {
|
||||
AlipayConfig alipayConfig = getById(1L);
|
||||
return alipayConfig == null ? new AlipayConfig() : alipayConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AlipayConfig config(AlipayConfig alipayConfig) {
|
||||
alipayConfig.setId(1L);
|
||||
saveOrUpdate(alipayConfig);
|
||||
return alipayConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPayAsPc(AlipayConfig alipay, TradeDto trade) throws Exception {
|
||||
|
||||
if(alipay.getId() == null){
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType());
|
||||
|
||||
// 创建API对应的request(电脑网页版)
|
||||
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
|
||||
|
||||
// 订单完成后返回的页面和异步通知地址
|
||||
request.setReturnUrl(alipay.getReturnUrl());
|
||||
request.setNotifyUrl(alipay.getNotifyUrl());
|
||||
// 填充订单参数
|
||||
request.setBizContent("{" +
|
||||
" \"out_trade_no\":\""+trade.getOutTradeNo()+"\"," +
|
||||
" \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
|
||||
" \"total_amount\":"+trade.getTotalAmount()+"," +
|
||||
" \"subject\":\""+trade.getSubject()+"\"," +
|
||||
" \"body\":\""+trade.getBody()+"\"," +
|
||||
" \"extend_params\":{" +
|
||||
" \"sys_service_provider_id\":\""+alipay.getSysServiceProviderId()+"\"" +
|
||||
" }"+
|
||||
" }");//填充业务参数
|
||||
// 调用SDK生成表单, 通过GET方式,口可以获取url
|
||||
return alipayClient.pageExecute(request, "GET").getBody();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPayAsWeb(AlipayConfig alipay, TradeDto trade) throws Exception {
|
||||
if(alipay.getId() == null){
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppId(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType());
|
||||
|
||||
double money = Double.parseDouble(trade.getTotalAmount());
|
||||
double maxMoney = 5000;
|
||||
if(money <= 0 || money >= maxMoney){
|
||||
throw new BadRequestException("测试金额过大");
|
||||
}
|
||||
// 创建API对应的request(手机网页版)
|
||||
AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
|
||||
request.setReturnUrl(alipay.getReturnUrl());
|
||||
request.setNotifyUrl(alipay.getNotifyUrl());
|
||||
request.setBizContent("{" +
|
||||
" \"out_trade_no\":\""+trade.getOutTradeNo()+"\"," +
|
||||
" \"product_code\":\"FAST_INSTANT_TRADE_PAY\"," +
|
||||
" \"total_amount\":"+trade.getTotalAmount()+"," +
|
||||
" \"subject\":\""+trade.getSubject()+"\"," +
|
||||
" \"body\":\""+trade.getBody()+"\"," +
|
||||
" \"extend_params\":{" +
|
||||
" \"sys_service_provider_id\":\""+alipay.getSysServiceProviderId()+"\"" +
|
||||
" }"+
|
||||
" }");
|
||||
return alipayClient.pageExecute(request, "GET").getBody();
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service.impl;
|
||||
|
||||
import cn.hutool.extra.mail.Mail;
|
||||
import cn.hutool.extra.mail.MailAccount;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.domain.EmailConfig;
|
||||
import com.fuyuanshen.domain.dto.EmailDto;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.mapper.EmailConfigMapper;
|
||||
import com.fuyuanshen.service.EmailService;
|
||||
import com.fuyuanshen.utils.EncryptUtils;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-26
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "email")
|
||||
public class EmailServiceImpl extends ServiceImpl<EmailConfigMapper, EmailConfig> implements EmailService {
|
||||
|
||||
@Override
|
||||
@CachePut(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public EmailConfig config(EmailConfig emailConfig, EmailConfig old) throws Exception {
|
||||
emailConfig.setId(1L);
|
||||
if(!emailConfig.getPass().equals(old.getPass())){
|
||||
// 对称加密
|
||||
emailConfig.setPass(EncryptUtils.desEncrypt(emailConfig.getPass()));
|
||||
}
|
||||
saveOrUpdate(emailConfig);
|
||||
return emailConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public EmailConfig find() {
|
||||
EmailConfig emailConfig = getById(1L);
|
||||
return emailConfig == null ? new EmailConfig() : emailConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void send(EmailDto emailDto, EmailConfig emailConfig){
|
||||
if(emailConfig.getId() == null){
|
||||
throw new BadRequestException("请先配置,再操作");
|
||||
}
|
||||
// 封装
|
||||
MailAccount account = new MailAccount();
|
||||
// 设置用户
|
||||
String user = emailConfig.getFromUser().split("@")[0];
|
||||
account.setUser(user);
|
||||
account.setHost(emailConfig.getHost());
|
||||
account.setPort(Integer.parseInt(emailConfig.getPort()));
|
||||
account.setAuth(true);
|
||||
try {
|
||||
// 对称解密
|
||||
account.setPass(EncryptUtils.desDecrypt(emailConfig.getPass()));
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
account.setFrom(emailConfig.getUser()+"<"+emailConfig.getFromUser()+">");
|
||||
// ssl方式发送
|
||||
account.setSslEnable(true);
|
||||
// 使用STARTTLS安全连接
|
||||
account.setStarttlsEnable(true);
|
||||
// 解决jdk8之后默认禁用部分tls协议,导致邮件发送失败的问题
|
||||
account.setSslProtocols("TLSv1 TLSv1.1 TLSv1.2");
|
||||
String content = emailDto.getContent();
|
||||
// 发送
|
||||
try {
|
||||
int size = emailDto.getTos().size();
|
||||
Mail.create(account)
|
||||
.setTos(emailDto.getTos().toArray(new String[size]))
|
||||
.setTitle(emailDto.getSubject())
|
||||
.setContent(content)
|
||||
.setHtml(true)
|
||||
//关闭session
|
||||
.setUseGlobalSession(false)
|
||||
.send();
|
||||
}catch (Exception e){
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.config.properties.FileProperties;
|
||||
import com.fuyuanshen.domain.LocalStorage;
|
||||
import com.fuyuanshen.domain.dto.LocalStorageQueryCriteria;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.mapper.LocalStorageMapper;
|
||||
import com.fuyuanshen.utils.*;
|
||||
import com.fuyuanshen.service.LocalStorageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
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 org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-09-05
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LocalStorageServiceImpl extends ServiceImpl<LocalStorageMapper, LocalStorage> implements LocalStorageService {
|
||||
|
||||
private final LocalStorageMapper localStorageMapper;
|
||||
private final FileProperties properties;
|
||||
|
||||
@Override
|
||||
public PageResult<LocalStorage> queryAll(LocalStorageQueryCriteria criteria, Page<Object> page){
|
||||
return PageUtil.toPage(localStorageMapper.findAll(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalStorage> queryAll(LocalStorageQueryCriteria criteria){
|
||||
return localStorageMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LocalStorage create(String name, MultipartFile multipartFile) {
|
||||
FileUtil.checkSize(properties.getMaxSize(), multipartFile.getSize());
|
||||
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
|
||||
String type = FileUtil.getFileType(suffix);
|
||||
File file = FileUtil.upload(multipartFile, properties.getPath().getPath() + type + File.separator);
|
||||
if(ObjectUtil.isNull(file)){
|
||||
throw new BadRequestException("上传失败");
|
||||
}
|
||||
try {
|
||||
name = StringUtils.isBlank(name) ? FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename()) : name;
|
||||
LocalStorage localStorage = new LocalStorage(
|
||||
file.getName(),
|
||||
name,
|
||||
suffix,
|
||||
file.getPath(),
|
||||
type,
|
||||
FileUtil.getSize(multipartFile.getSize())
|
||||
);
|
||||
save(localStorage);
|
||||
return localStorage;
|
||||
}catch (Exception e){
|
||||
FileUtil.del(file);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(LocalStorage resources) {
|
||||
LocalStorage localStorage = getById(resources.getId());
|
||||
localStorage.copy(resources);
|
||||
saveOrUpdate(localStorage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
LocalStorage storage = getById(id);
|
||||
FileUtil.del(storage.getPath());
|
||||
removeById(storage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<LocalStorage> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LocalStorage localStorage : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", localStorage.getRealName());
|
||||
map.put("备注名", localStorage.getName());
|
||||
map.put("文件类型", localStorage.getType());
|
||||
map.put("文件大小", localStorage.getSize());
|
||||
map.put("创建者", localStorage.getCreateBy());
|
||||
map.put("创建日期", localStorage.getCreateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.domain.QiniuConfig;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.mapper.QiniuConfigMapper;
|
||||
import com.fuyuanshen.service.QiNiuConfigService;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class QiNiuConfigServiceImpl extends ServiceImpl<QiniuConfigMapper, QiniuConfig> implements QiNiuConfigService {
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'config'")
|
||||
public QiniuConfig getConfig() {
|
||||
QiniuConfig qiniuConfig = getById(1L);
|
||||
return qiniuConfig == null ? new QiniuConfig() : qiniuConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveConfig(QiniuConfig qiniuConfig) {
|
||||
qiniuConfig.setId(1L);
|
||||
String http = "http://", https = "https://";
|
||||
if (!(qiniuConfig.getHost().toLowerCase().startsWith(http)||qiniuConfig.getHost().toLowerCase().startsWith(https))) {
|
||||
throw new BadRequestException("外链域名必须以http://或者https://开头");
|
||||
}
|
||||
saveOrUpdate(qiniuConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(key = "'config'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateType(String type) {
|
||||
QiniuConfig qiniuConfig = getById(1L);
|
||||
qiniuConfig.setType(type);
|
||||
saveOrUpdate(qiniuConfig);
|
||||
}
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.qiniu.common.QiniuException;
|
||||
import com.qiniu.http.Response;
|
||||
import com.qiniu.storage.BucketManager;
|
||||
import com.qiniu.storage.Configuration;
|
||||
import com.qiniu.storage.UploadManager;
|
||||
import com.qiniu.storage.model.DefaultPutRet;
|
||||
import com.qiniu.storage.model.FileInfo;
|
||||
import com.qiniu.util.Auth;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.domain.QiniuConfig;
|
||||
import com.fuyuanshen.domain.QiniuContent;
|
||||
import com.fuyuanshen.mapper.QiniuContentMapper;
|
||||
import com.fuyuanshen.domain.dto.QiniuQueryCriteria;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import com.fuyuanshen.utils.QiNiuUtil;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.service.QiniuContentService;
|
||||
import com.fuyuanshen.utils.FileUtil;
|
||||
import com.fuyuanshen.utils.PageUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@CacheConfig(cacheNames = "qiNiu")
|
||||
public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, QiniuContent> implements QiniuContentService {
|
||||
|
||||
private final QiniuContentMapper qiniuContentMapper;
|
||||
|
||||
@Value("${qiniu.max-size}")
|
||||
private Long maxSize;
|
||||
|
||||
@Override
|
||||
public PageResult<QiniuContent> queryAll(QiniuQueryCriteria criteria, Page<Object> page){
|
||||
return PageUtil.toPage(qiniuContentMapper.findAll(criteria, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QiniuContent> queryAll(QiniuQueryCriteria criteria) {
|
||||
return qiniuContentMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public QiniuContent upload(MultipartFile file, QiniuConfig qiniuConfig) {
|
||||
FileUtil.checkSize(maxSize, file.getSize());
|
||||
if(qiniuConfig.getId() == null){
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
// 构造一个带指定Zone对象的配置类
|
||||
Configuration cfg = new Configuration(QiNiuUtil.getRegion(qiniuConfig.getZone()));
|
||||
UploadManager uploadManager = new UploadManager(cfg);
|
||||
Auth auth = Auth.create(qiniuConfig.getAccessKey(), qiniuConfig.getSecretKey());
|
||||
String upToken = auth.uploadToken(qiniuConfig.getBucket());
|
||||
try {
|
||||
String key = file.getOriginalFilename();
|
||||
if(qiniuContentMapper.findByKey(key) != null) {
|
||||
key = QiNiuUtil.getKey(key);
|
||||
}
|
||||
Response response = uploadManager.put(file.getBytes(), key, upToken);
|
||||
//解析上传成功的结果
|
||||
DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class);
|
||||
QiniuContent content = qiniuContentMapper.findByKey(FileUtil.getFileNameNoEx(putRet.key));
|
||||
if(content == null){
|
||||
//存入数据库
|
||||
QiniuContent qiniuContent = new QiniuContent();
|
||||
qiniuContent.setSuffix(FileUtil.getExtensionName(putRet.key));
|
||||
qiniuContent.setBucket(qiniuConfig.getBucket());
|
||||
qiniuContent.setType(qiniuConfig.getType());
|
||||
qiniuContent.setKey(FileUtil.getFileNameNoEx(putRet.key));
|
||||
qiniuContent.setUrl(qiniuConfig.getHost() + "/" + putRet.key);
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(String.valueOf(file.getSize()))));
|
||||
save(qiniuContent);
|
||||
}
|
||||
return content;
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String download(QiniuContent content,QiniuConfig config){
|
||||
String finalUrl;
|
||||
String type = "公开";
|
||||
if(type.equals(content.getType())){
|
||||
finalUrl = content.getUrl();
|
||||
} else {
|
||||
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
||||
// 1小时,可以自定义链接过期时间
|
||||
long expireInSeconds = 3600;
|
||||
finalUrl = auth.privateDownloadUrl(content.getUrl(), expireInSeconds);
|
||||
}
|
||||
return finalUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(QiniuContent content, QiniuConfig config) {
|
||||
//构造一个带指定Zone对象的配置类
|
||||
Configuration cfg = new Configuration(QiNiuUtil.getRegion(config.getZone()));
|
||||
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||
try {
|
||||
bucketManager.delete(content.getBucket(), content.getKey() + "." + content.getSuffix());
|
||||
} catch (QiniuException ex) {
|
||||
log.error("七牛云删除文件失败", ex);
|
||||
} finally {
|
||||
removeById(content);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void synchronize(QiniuConfig config) {
|
||||
if(config.getId() == null){
|
||||
throw new BadRequestException("请先添加相应配置,再操作");
|
||||
}
|
||||
//构造一个带指定Zone对象的配置类
|
||||
Configuration cfg = new Configuration(QiNiuUtil.getRegion(config.getZone()));
|
||||
Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey());
|
||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||
//文件名前缀
|
||||
String prefix = "";
|
||||
//每次迭代的长度限制,最大1000,推荐值 1000
|
||||
int limit = 1000;
|
||||
//指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。缺省值为空字符串
|
||||
String delimiter = "";
|
||||
//列举空间文件列表
|
||||
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(config.getBucket(), prefix, limit, delimiter);
|
||||
while (fileListIterator.hasNext()) {
|
||||
//处理获取的file list结果
|
||||
QiniuContent qiniuContent;
|
||||
FileInfo[] items = fileListIterator.next();
|
||||
for (FileInfo item : items) {
|
||||
if(qiniuContentMapper.findByKey(FileUtil.getFileNameNoEx(item.key)) == null){
|
||||
qiniuContent = new QiniuContent();
|
||||
qiniuContent.setSize(FileUtil.getSize(Integer.parseInt(String.valueOf(item.fsize))));
|
||||
qiniuContent.setSuffix(FileUtil.getExtensionName(item.key));
|
||||
qiniuContent.setKey(FileUtil.getFileNameNoEx(item.key));
|
||||
qiniuContent.setType(config.getType());
|
||||
qiniuContent.setBucket(config.getBucket());
|
||||
qiniuContent.setUrl(config.getHost()+"/"+item.key);
|
||||
save(qiniuContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids, QiniuConfig config) {
|
||||
for (Long id : ids) {
|
||||
delete(getById(id), config);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadList(List<QiniuContent> queryAll, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (QiniuContent content : queryAll) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("文件名", content.getKey());
|
||||
map.put("文件类型", content.getSuffix());
|
||||
map.put("空间名称", content.getBucket());
|
||||
map.put("文件大小", content.getSize());
|
||||
map.put("空间类型", content.getType());
|
||||
map.put("创建日期", content.getUpdateTime());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.utils;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.fuyuanshen.domain.AlipayConfig;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 支付宝工具类
|
||||
* @author zhengjie
|
||||
* @date 2018/09/30 14:04:35
|
||||
*/
|
||||
@Component
|
||||
public class AlipayUtils {
|
||||
|
||||
/**
|
||||
* 生成订单号
|
||||
* @return String
|
||||
*/
|
||||
public String getOrderCode() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
int a = (int)(Math.random() * 9000.0D) + 1000;
|
||||
System.out.println(a);
|
||||
Date date = new Date();
|
||||
String str = sdf.format(date);
|
||||
String[] split = str.split("-");
|
||||
String s = split[0] + split[1] + split[2];
|
||||
String[] split1 = s.split(" ");
|
||||
String s1 = split1[0] + split1[1];
|
||||
String[] split2 = s1.split(":");
|
||||
return split2[0] + split2[1] + split2[2] + a;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验签名
|
||||
* @param request HttpServletRequest
|
||||
* @param alipay 阿里云配置
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean rsaCheck(HttpServletRequest request, AlipayConfig alipay){
|
||||
|
||||
// 获取支付宝POST过来反馈信息
|
||||
Map<String,String> params = new HashMap<>(1);
|
||||
Map<String, String[]> requestParams = request.getParameterMap();
|
||||
for (Object o : requestParams.keySet()) {
|
||||
String name = (String) o;
|
||||
String[] values = requestParams.get(name);
|
||||
String valueStr = "";
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
||||
: valueStr + values[i] + ",";
|
||||
}
|
||||
params.put(name, valueStr);
|
||||
}
|
||||
|
||||
try {
|
||||
return AlipaySignature.rsaCheckV1(params,
|
||||
alipay.getPublicKey(),
|
||||
alipay.getCharset(),
|
||||
alipay.getSignType());
|
||||
} catch (AlipayApiException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
71
fys-tools/src/main/java/com/fuyuanshen/utils/QiNiuUtil.java
Normal file
71
fys-tools/src/main/java/com/fuyuanshen/utils/QiNiuUtil.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.utils;
|
||||
|
||||
import com.qiniu.storage.Region;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 七牛云存储工具类
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-31
|
||||
*/
|
||||
public class QiNiuUtil {
|
||||
|
||||
private static final String HUAD = "华东";
|
||||
|
||||
private static final String HUAB = "华北";
|
||||
|
||||
private static final String HUAN = "华南";
|
||||
|
||||
private static final String BEIM = "北美";
|
||||
|
||||
/**
|
||||
* 得到机房的对应关系
|
||||
* @param zone 机房名称
|
||||
* @return Region
|
||||
*/
|
||||
public static Region getRegion(String zone){
|
||||
|
||||
if(HUAD.equals(zone)){
|
||||
return Region.huadong();
|
||||
} else if(HUAB.equals(zone)){
|
||||
return Region.huabei();
|
||||
} else if(HUAN.equals(zone)){
|
||||
return Region.huanan();
|
||||
} else if (BEIM.equals(zone)){
|
||||
return Region.beimei();
|
||||
// 否则就是东南亚
|
||||
} else {
|
||||
return Region.qvmHuadong();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认不指定key的情况下,以文件内容的hash值作为文件名
|
||||
* @param file 文件名
|
||||
* @return String
|
||||
*/
|
||||
public static String getKey(String file){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
Date date = new Date();
|
||||
return FileUtil.getFileNameNoEx(file) + "-" +
|
||||
sdf.format(date) +
|
||||
"." +
|
||||
FileUtil.getExtensionName(file);
|
||||
}
|
||||
}
|
41
fys-tools/src/main/resources/mapper/LocalStorageMapper.xml
Normal file
41
fys-tools/src/main/resources/mapper/LocalStorageMapper.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?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.fuyuanshen.mapper.LocalStorageMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.fuyuanshen.domain.LocalStorage">
|
||||
<id column="storage_id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="real_name" property="realName" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="suffix" property="suffix" jdbcType="VARCHAR"/>
|
||||
<result column="size" property="size" jdbcType="VARCHAR"/>
|
||||
<result column="type" property="type" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="create_by" property="createBy" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
storage_id, real_name, name, suffix, size, type, create_time, update_time, create_by, update_by
|
||||
</sql>
|
||||
|
||||
<select id="findAll" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from tool_local_storage
|
||||
<where>
|
||||
<if test="criteria.blurry != null and criteria.blurry != ''">
|
||||
AND (
|
||||
name LIKE CONCAT('%',#{criteria.blurry},'%')
|
||||
OR suffix LIKE CONCAT('%',#{criteria.blurry},'%')
|
||||
OR type LIKE CONCAT('%',#{criteria.blurry},'%')
|
||||
OR create_by LIKE CONCAT('%',#{criteria.blurry},'%')
|
||||
)
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() > 0">
|
||||
AND update_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY storage_id DESC
|
||||
</select>
|
||||
</mapper>
|
41
fys-tools/src/main/resources/mapper/QiniuContentMapper.xml
Normal file
41
fys-tools/src/main/resources/mapper/QiniuContentMapper.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?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.fuyuanshen.mapper.QiniuContentMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.fuyuanshen.domain.QiniuContent">
|
||||
<id column="content_id" property="id" jdbcType="BIGINT"/>
|
||||
<result column="name" property="key" jdbcType="VARCHAR"/>
|
||||
<result column="size" property="size" jdbcType="VARCHAR"/>
|
||||
<result column="type" property="type" jdbcType="VARCHAR"/>
|
||||
<result column="suffix" property="suffix" jdbcType="VARCHAR"/>
|
||||
<result column="bucket" property="bucket" jdbcType="VARCHAR"/>
|
||||
<result column="url" property="url" jdbcType="VARCHAR"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
content_id, name, size, type, suffix, bucket, url, update_time
|
||||
</sql>
|
||||
|
||||
<select id="findByKey" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tool_qiniu_content
|
||||
WHERE name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="findAll" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
FROM tool_qiniu_content
|
||||
<where>
|
||||
<if test="criteria.key != null and criteria.key != ''">
|
||||
AND name LIKE CONCAT('%',#{criteria.key},'%')
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() > 0">
|
||||
AND update_time BETWEEN #{criteria.createTime[0]} AND #{criteria.createTime[1]}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY content_id DESC
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user