diff --git a/README.MD b/README.MD index 169e8e3..8322059 100644 --- a/README.MD +++ b/README.MD @@ -38,12 +38,12 @@ Aurora是一个简单高效的后台管理系统。项目基础框架采用全 │ ├─天气查询(开发中) │ └─图床管理 │─第三方工具 -│ │-支付宝支付(开发中) +│ │-支付宝支付 │ │-微信支付(开发中) │ │-百度富文本编辑器 │ │-邮件工具 -│ │-阿里大鱼(开发中) -│ └─七牛云储存(开发中) +│ │-七牛云储存 +│ └─阿里大鱼(开发中) └─任务调度(开发中) ├─定时任务 └─调度日志 diff --git a/pom.xml b/pom.xml index 4701c7b..3dfa903 100644 --- a/pom.xml +++ b/pom.xml @@ -159,6 +159,13 @@ 4.1.8 + + + com.qiniu + qiniu-java-sdk + [7.2.0, 7.2.99] + + javax.mail diff --git a/sql/aurora.sql b/sql/aurora.sql index c2ac24e..2d64c31 100644 --- a/sql/aurora.sql +++ b/sql/aurora.sql @@ -5,13 +5,13 @@ Source Server Type : MySQL Source Server Version : 50559 Source Host : localhost:3306 - Source Schema : aurora + Source Schema : my_aurora Target Server Type : MySQL Target Server Version : 50559 File Encoding : 65001 - Date: 30/09/2018 16:17:12 + Date: 02/10/2018 16:35:37 */ SET NAMES utf8mb4; @@ -80,7 +80,7 @@ CREATE TABLE `zj_menu` ( `sys` bit(1) NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `UK_cbhg0bi3f1emxkhqqtvca9btx`(`soft`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of zj_menu @@ -101,11 +101,12 @@ INSERT INTO `zj_menu` VALUES (13, 'layui-icon-tree', 12, 2, '图床管理', 31, INSERT INTO `zj_menu` VALUES (14, 'layui-icon-tree', 5, 2, '在线用户', 12, '/online/index', '2018-09-21 16:09:38', '2018-09-22 10:17:09', 0, b'0', b'1'); INSERT INTO `zj_menu` VALUES (16, 'layui-icon-tree', 5, 2, 'Redis终端', 16, '/redis/terminal', '2018-09-22 11:18:21', '2018-09-27 13:25:09', 0, b'0', b'1'); INSERT INTO `zj_menu` VALUES (17, 'layui-icon-tree', 7, 2, '接口文档', 7, '/swagger/index', '2018-09-23 09:16:17', '2018-09-23 10:01:06', 0, b'0', b'1'); -INSERT INTO `zj_menu` VALUES (18, 'layui-icon-util', 0, 1, '工具管理', 40, '', '2018-09-24 23:46:02', '2018-09-30 15:16:43', 3, b'0', b'1'); -INSERT INTO `zj_menu` VALUES (19, 'layui-icon-tree', 18, 2, '富文本编辑', 45, '/ueditor/index', '2018-09-24 23:46:47', '2018-09-24 23:46:47', 0, b'0', b'1'); +INSERT INTO `zj_menu` VALUES (18, 'layui-icon-util', 0, 1, '工具管理', 40, '', '2018-09-24 23:46:02', '2018-10-02 11:03:27', 4, b'0', b'1'); +INSERT INTO `zj_menu` VALUES (19, 'layui-icon-code-circle', 18, 2, '富文本编辑', 45, '/ueditor/index', '2018-09-24 23:46:47', '2018-10-02 16:28:18', 0, b'0', b'1'); INSERT INTO `zj_menu` VALUES (21, 'layui-icon-tree', 5, 2, 'SQL监控', 15, '/druid/index.html', '2018-09-27 13:24:25', '2018-09-27 13:24:25', 0, b'1', b'1'); -INSERT INTO `zj_menu` VALUES (22, 'layui-icon-edit', 18, 2, '邮件工具', 41, '/email/index', '2018-09-28 07:32:57', '2018-09-28 07:32:57', 0, b'0', b'1'); -INSERT INTO `zj_menu` VALUES (24, 'layui-icon-tree', 18, 2, '支付宝工具', 42, '/aliPay/index', '2018-09-30 15:16:43', '2018-09-30 15:16:43', 0, b'0', b'0'); +INSERT INTO `zj_menu` VALUES (22, 'layui-icon-edit', 18, 2, '邮件工具', 41, '/email/index', '2018-09-28 07:32:57', '2018-10-02 16:26:01', 0, b'0', b'1'); +INSERT INTO `zj_menu` VALUES (24, 'layui-icon-dollar', 18, 2, '支付宝工具', 42, '/aliPay/index', '2018-09-30 15:16:43', '2018-10-02 16:27:09', 0, b'0', b'0'); +INSERT INTO `zj_menu` VALUES (25, 'layui-icon-upload', 18, 2, '七牛云存储', 43, '/qiNiu/index', '2018-10-02 11:03:27', '2018-10-02 16:26:42', 0, b'0', b'0'); -- ---------------------------- -- Table structure for zj_menus_roles @@ -144,6 +145,7 @@ INSERT INTO `zj_menus_roles` VALUES (19, 1); INSERT INTO `zj_menus_roles` VALUES (21, 1); INSERT INTO `zj_menus_roles` VALUES (22, 1); INSERT INTO `zj_menus_roles` VALUES (24, 1); +INSERT INTO `zj_menus_roles` VALUES (25, 1); INSERT INTO `zj_menus_roles` VALUES (5, 3); INSERT INTO `zj_menus_roles` VALUES (7, 3); INSERT INTO `zj_menus_roles` VALUES (9, 3); @@ -242,6 +244,36 @@ CREATE TABLE `zj_picture` ( -- ---------------------------- INSERT INTO `zj_picture` VALUES (1, '2018-09-21 12:01:57', '1', '200', '8.49KB ', 'https://i.loli.net/2018/09/21/5ba46d305018d.jpg', '200', 1, 'avatar'); +-- ---------------------------- +-- Table structure for zj_qiniu_config +-- ---------------------------- +DROP TABLE IF EXISTS `zj_qiniu_config`; +CREATE TABLE `zj_qiniu_config` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `accessKey` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `bucket` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `host` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `secretKey` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `zone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + +-- ---------------------------- +-- Table structure for zj_qiniu_content +-- ---------------------------- +DROP TABLE IF EXISTS `zj_qiniu_content`; +CREATE TABLE `zj_qiniu_content` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `bucket` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `size` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `updateTime` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + -- ---------------------------- -- Table structure for zj_role -- ---------------------------- @@ -276,7 +308,7 @@ CREATE TABLE `zj_syslog` ( `time` int(11) NULL DEFAULT NULL, `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 88 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 222 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for zj_user @@ -298,7 +330,7 @@ CREATE TABLE `zj_user` ( -- ---------------------------- -- Records of zj_user -- ---------------------------- -INSERT INTO `zj_user` VALUES (1, 'https://www.zhengjie.me/images/avatar.jpg', '2018-08-23 09:11:56', 'zhengjie@tom.com', 1, '2018-09-30 15:30:16', '65a674ce6632479005ea7a9071234cfb', 'aurora'); +INSERT INTO `zj_user` VALUES (1, 'https://www.zhengjie.me/images/avatar.jpg', '2018-08-23 09:11:56', 'zhengjie@tom.com', 1, '2018-10-02 14:03:44', '65a674ce6632479005ea7a9071234cfb', 'aurora'); -- ---------------------------- -- Table structure for zj_user_pictures diff --git a/src/main/java/me/aurora/app/rest/ueditor/UeditorController.java b/src/main/java/me/aurora/app/rest/ueditor/UeditorController.java index 9c0c111..bd6108b 100644 --- a/src/main/java/me/aurora/app/rest/ueditor/UeditorController.java +++ b/src/main/java/me/aurora/app/rest/ueditor/UeditorController.java @@ -19,8 +19,9 @@ import java.io.PrintWriter; @RequestMapping("ueditor") public class UeditorController { + @Log("访问ueditor") @GetMapping(value = "/index") - private ModelAndView index(){ + public ModelAndView index(){ return new ModelAndView("/ueditor/index"); } diff --git a/src/main/java/me/aurora/app/rest/utils/AliPayController.java b/src/main/java/me/aurora/app/rest/utils/AliPayController.java index 9805373..4991e37 100644 --- a/src/main/java/me/aurora/app/rest/utils/AliPayController.java +++ b/src/main/java/me/aurora/app/rest/utils/AliPayController.java @@ -47,10 +47,12 @@ public class AliPayController { @Log("配置支付宝参数") @PostMapping(value = "/config") public ResponseEntity emailConfig(@Validated(AlipayConfig.New.class) @RequestBody AlipayConfig alipayConfig){ + alipayConfig.setId(1L); alipayService.updateConfig(alipayConfig); return ResponseEntity.ok(); } + @Log("支付宝PC网页支付") @ApiOperation(value = "PC网页支付") @PostMapping(value = "/toPayAsPC") public ResponseEntity toPayAsPC(@Validated(TradeVo.New.class) @RequestBody TradeVo trade) throws Exception{ @@ -60,6 +62,7 @@ public class AliPayController { return ResponseEntity.ok(payUrl); } + @Log("支付宝手机网页支付") @ApiOperation(value = "手机网页支付") @PostMapping(value = "/toPayAsWeb") public ResponseEntity toPayAsWeb(@Validated(TradeVo.New.class) @RequestBody TradeVo trade) throws Exception{ @@ -69,6 +72,7 @@ public class AliPayController { return ResponseEntity.ok(payUrl); } + @Log("支付宝回调") @ApiIgnore @GetMapping("/return") @ApiOperation(value = "支付之后跳转的链接") @@ -95,6 +99,7 @@ public class AliPayController { } } + @Log("支付异步通知") @ApiIgnore @RequestMapping("/notify") @ApiOperation(value = "支付异步通知(要公网访问),接收异步通知,检查通知内容app_id、out_trade_no、total_amount是否与请求中的一致,根据trade_status进行后续业务处理") diff --git a/src/main/java/me/aurora/app/rest/utils/EmailController.java b/src/main/java/me/aurora/app/rest/utils/EmailController.java index 915f967..4a4e9be 100644 --- a/src/main/java/me/aurora/app/rest/utils/EmailController.java +++ b/src/main/java/me/aurora/app/rest/utils/EmailController.java @@ -35,7 +35,8 @@ public class EmailController { @Log("配置邮件") @PostMapping(value = "/config") public ResponseEntity emailConfig(@RequestBody @Validated(EmailConfig.Update.class) EmailConfig emailConfig){ - emailService.updateConfig(emailConfig); + emailConfig.setId(1L); + emailService.updateConfig(emailConfig,emailService.findById(1L)); return ResponseEntity.ok(); } diff --git a/src/main/java/me/aurora/app/rest/utils/QiniuController.java b/src/main/java/me/aurora/app/rest/utils/QiniuController.java new file mode 100644 index 0000000..eeafcbe --- /dev/null +++ b/src/main/java/me/aurora/app/rest/utils/QiniuController.java @@ -0,0 +1,121 @@ +package me.aurora.app.rest.utils; + +import lombok.extern.slf4j.Slf4j; +import me.aurora.annotation.Log; +import me.aurora.domain.ResponseEntity; +import me.aurora.domain.utils.QiniuConfig; +import me.aurora.repository.spec.QiNiuContentSpec; +import me.aurora.service.QiNiuService; +import me.aurora.util.HttpContextUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.ModelAndView; +import javax.servlet.http.HttpServletRequest; +import java.io.UnsupportedEncodingException; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("qiNiu") +public class QiniuController { + + @Autowired + private QiNiuService qiNiuService; + + @GetMapping(value = "/index") + public ModelAndView emailIndex(){ + QiniuConfig qiniuConfig = qiNiuService.findById(1L); + HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + request.setAttribute("qiniuConfig",qiniuConfig); + return new ModelAndView("/utils/qiNiu/index"); + } + + /** + * 查询全部文件 + * @param name + * @param page + * @param limit + * @return + */ + @Log("查询七牛云全部文件") + @GetMapping(value = "/getContentInfo") + public Map getContentInfo(@RequestParam(value = "name",required = false) String name, + @RequestParam(value = "page",defaultValue = "1")Integer page, + @RequestParam(value = "limit",defaultValue = "10")Integer limit){ + log.warn("REST request to findAll Log"); + Sort sort = new Sort(Sort.Direction.DESC,"updateTime"); + Pageable pageable = PageRequest.of(page-1,limit,sort); + QiniuConfig qiniuConfig = qiNiuService.findById(1L); + return qiNiuService.getContentInfo(new QiNiuContentSpec(name,qiniuConfig.getBucket()),pageable); + } + + @Log("配置七牛对象存储") + @PostMapping(value = "/config") + public ResponseEntity emailConfig(@RequestBody @Validated(QiniuConfig.Update.class) QiniuConfig qiniuConfig){ + qiniuConfig.setId(1L); + qiNiuService.updateConfig(qiniuConfig); + return ResponseEntity.ok(); + } + + /** + * 去上传页面 + * @return + */ + @GetMapping(value = "/toAddPage") + public ModelAndView toAddPage(){ + log.warn("REST request to addPage"); + return new ModelAndView("/utils/qiNiu/add"); + } + + /** + * 上传文件到七牛云 + * @param file + * @return + */ + @Log("上传文件到七牛云") + @PostMapping(value = "/upload") + public ResponseEntity upload(@RequestParam MultipartFile file){ + qiNiuService.upload(file,qiNiuService.findById(1L)); + return ResponseEntity.ok(); + } + /** + * 同步七牛云数据到数据库 + * @return + */ + @Log("同步七牛云数据到数据库") + @PostMapping(value = "/synchronize") + public ResponseEntity synchronize(){ + qiNiuService.synchronize(qiNiuService.findById(1L)); + return ResponseEntity.ok(); + } + + /** + * 下载七牛云文件 + * @param id + * @return + * @throws Exception + */ + @Log("下载七牛云文件") + @PostMapping(value = "/download") + public ResponseEntity download(@RequestParam Long id) throws UnsupportedEncodingException { + return qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.findById(1L)); + } + + /** + * 删除七牛云文件 + * @param id + * @return + * @throws Exception + */ + @Log("删除七牛云文件") + @DeleteMapping(value = "/delete") + public ResponseEntity delete(@RequestParam Long id) throws UnsupportedEncodingException { + qiNiuService.delete(qiNiuService.findByContentId(id),qiNiuService.findById(1L)); + return ResponseEntity.ok(); + } +} diff --git a/src/main/java/me/aurora/app/rest/web/PictureController.java b/src/main/java/me/aurora/app/rest/web/PictureController.java index 3eab4f2..58e8293 100644 --- a/src/main/java/me/aurora/app/rest/web/PictureController.java +++ b/src/main/java/me/aurora/app/rest/web/PictureController.java @@ -53,7 +53,7 @@ public class PictureController { @Log("查询全部图片") @RequiresPermissions(value={"admin", "picture:all","picture:select"}, logical= Logical.OR) @GetMapping(value = "/getPictureInfo") - public Map getLogInfo(@RequestParam(value = "username",required = false) String username, + public Map getInfo(@RequestParam(value = "username",required = false) String username, @RequestParam(value = "createTime",required = false) Timestamp createTime, @RequestParam(value = "endTime",required = false) Timestamp endTime, @RequestParam(value = "page",defaultValue = "1")Integer page, @@ -85,7 +85,7 @@ public class PictureController { @Log("上传图片") @RequiresPermissions (value={"admin", "picture:all","picture:upload"}, logical= Logical.OR) @PostMapping(value = "/upload") - public ResponseEntity uploadAccessory(@RequestParam MultipartFile file) throws Exception { + public ResponseEntity upload(@RequestParam MultipartFile file) throws Exception { User user = (User) SecurityUtils.getSubject().getPrincipal(); pictureService.upload(file,user); return ResponseEntity.ok(); diff --git a/src/main/java/me/aurora/domain/utils/QiniuConfig.java b/src/main/java/me/aurora/domain/utils/QiniuConfig.java new file mode 100644 index 0000000..58ea2d1 --- /dev/null +++ b/src/main/java/me/aurora/domain/utils/QiniuConfig.java @@ -0,0 +1,64 @@ +package me.aurora.domain.utils; + +import lombok.Data; + +import javax.persistence.*; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 七牛云对象存储配置类 + * @author 郑杰 + * @date 2018/10/02 9:31:11 + */ +@Data +@Entity +@Table(name = "zj_qiniu_config") +public class QiniuConfig implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 一个账号最多拥有两对密钥(Access/Secret Key) + */ + @NotBlank(groups = Update.class) + private String accessKey; + + /** + * 一个账号最多拥有两对密钥(Access/Secret Key) + */ + @NotBlank(groups = Update.class) + private String secretKey; + + /** + * 存储空间名称作为唯一的 Bucket 识别符 + */ + @NotBlank(groups = Update.class) + private String bucket; + + /** + * Zone表示与机房的对应关系 + * 华东 Zone.zone0() + * 华北 Zone.zone1() + * 华南 Zone.zone2() + * 北美 Zone.zoneNa0() + * 东南亚 Zone.zoneAs0() + */ + @NotBlank(groups = Update.class) + private String zone; + + /** + * 外链域名,可自定义,需在七牛云绑定 + */ + @NotBlank(groups = Update.class) + private String host; + + /** + * 空间类型:公开/私有 + */ + private String type = "公开"; + + public interface Update {} +} diff --git a/src/main/java/me/aurora/domain/utils/QiniuContent.java b/src/main/java/me/aurora/domain/utils/QiniuContent.java new file mode 100644 index 0000000..2ea6591 --- /dev/null +++ b/src/main/java/me/aurora/domain/utils/QiniuContent.java @@ -0,0 +1,57 @@ +package me.aurora.domain.utils; + +import lombok.Data; +import org.checkerframework.checker.units.qual.C; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * 上传成功后,存储结果 + * @author 郑杰 + * @date 2018/10/02 10:01:05 + */ +@Data +@Entity +@Table(name = "zj_qiniu_content") +public class QiniuContent implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + /** + * 文件名,如qiniu.jpg + */ + @Column(name = "name",unique = false) + private String key; + + /** + * 空间名 + */ + private String bucket; + + /** + * 大小 + */ + private String size; + + /** + * 文件地址 + */ + private String url; + + /** + * 空间类型:公开/私有 + */ + private String type = "公开"; + + /** + * 更新时间 + */ + @UpdateTimestamp + private Timestamp updateTime; +} diff --git a/src/main/java/me/aurora/repository/QiNiuConfigRepo.java b/src/main/java/me/aurora/repository/QiNiuConfigRepo.java new file mode 100644 index 0000000..e853e08 --- /dev/null +++ b/src/main/java/me/aurora/repository/QiNiuConfigRepo.java @@ -0,0 +1,11 @@ +package me.aurora.repository; + +import me.aurora.domain.utils.QiniuConfig; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * @author 郑杰 + * @date 2018/10/02 10:06:26 + */ +public interface QiNiuConfigRepo extends JpaRepository { +} diff --git a/src/main/java/me/aurora/repository/QiniuContentRepo.java b/src/main/java/me/aurora/repository/QiniuContentRepo.java new file mode 100644 index 0000000..125b999 --- /dev/null +++ b/src/main/java/me/aurora/repository/QiniuContentRepo.java @@ -0,0 +1,19 @@ +package me.aurora.repository; + +import me.aurora.domain.utils.QiniuContent; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** + * @author 郑杰 + * @date 2018/10/02 10:06:26 + */ +public interface QiniuContentRepo extends JpaRepository, JpaSpecificationExecutor { + + /** + * 根据key查询 + * @param key + * @return + */ + QiniuContent findByKey(String key); +} diff --git a/src/main/java/me/aurora/repository/spec/QiNiuContentSpec.java b/src/main/java/me/aurora/repository/spec/QiNiuContentSpec.java new file mode 100644 index 0000000..613a3b8 --- /dev/null +++ b/src/main/java/me/aurora/repository/spec/QiNiuContentSpec.java @@ -0,0 +1,47 @@ +package me.aurora.repository.spec; + +import cn.hutool.core.util.StrUtil; +import me.aurora.domain.utils.QiniuContent; +import org.springframework.data.jpa.domain.Specification; +import javax.persistence.criteria.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @author 郑杰 + * @date 2018/10/02 12:13:46 + */ +public class QiNiuContentSpec implements Specification { + + private String key; + private String bucket; + + public QiNiuContentSpec(String name,String bucket) { + this.key = name; + this.bucket = bucket; + } + + + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder cb) { + List list = new ArrayList(); + + if (!StrUtil.isEmpty(key)) { + list.add(cb.like(root.get("key").as(String.class), "%" + key + "%" )); + } + + if (!StrUtil.isEmpty(bucket)) { + list.add(cb.like(root.get("bucket").as(String.class), bucket)); + } + + Predicate[] p = new Predicate[list.size()]; + return cb.and(list.toArray(p)); + } + + @Override + public String toString() { + return "QiNiuContentSpec{" + + "key='" + key + '\'' + + '}'; + } +} diff --git a/src/main/java/me/aurora/service/EmailService.java b/src/main/java/me/aurora/service/EmailService.java index 29a87cb..d6bdc43 100644 --- a/src/main/java/me/aurora/service/EmailService.java +++ b/src/main/java/me/aurora/service/EmailService.java @@ -4,6 +4,7 @@ import me.aurora.domain.utils.EmailConfig; import me.aurora.domain.vo.EmailVo; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; import org.springframework.scheduling.annotation.Async; @@ -18,8 +19,8 @@ public interface EmailService { * 更新邮件配置 * @param emailConfig */ - @CacheEvict(allEntries = true) - EmailConfig updateConfig(EmailConfig emailConfig); + @CachePut(key = "#p0.getId()") + EmailConfig updateConfig(EmailConfig emailConfig,EmailConfig old); /** * 根据ID查询配置 diff --git a/src/main/java/me/aurora/service/QiNiuService.java b/src/main/java/me/aurora/service/QiNiuService.java new file mode 100644 index 0000000..13aa6d6 --- /dev/null +++ b/src/main/java/me/aurora/service/QiNiuService.java @@ -0,0 +1,88 @@ +package me.aurora.service; + +import me.aurora.domain.ResponseEntity; +import me.aurora.domain.utils.QiniuConfig; +import me.aurora.domain.utils.QiniuContent; +import me.aurora.repository.spec.QiNiuContentSpec; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; + +import java.io.UnsupportedEncodingException; +import java.util.Map; + +/** + * @author 郑杰 + * @date 2018/10/02 10:04:35 + */ +@CacheConfig(cacheNames = "qiNiu") +public interface QiNiuService { + + /** + * 根据id查配置 + * @param id + * @return + */ + @Cacheable(key = "#p0") + QiniuConfig findById(long id); + + /** + * 修改配置 + * @param qiniuConfig + */ + @CacheEvict(allEntries = true) + QiniuConfig updateConfig(QiniuConfig qiniuConfig); + + /** + * 获取所有在数据库存在的文件列表 + * @param qiNiuContentSpec + * @param pageable + * @return + */ + @Cacheable(keyGenerator = "keyGenerator") + Map getContentInfo(QiNiuContentSpec qiNiuContentSpec, Pageable pageable); + + /** + * 上传文件 + * @param file + * @param qiniuConfig + */ + @CacheEvict(allEntries = true) + void upload(MultipartFile file,QiniuConfig qiniuConfig); + + /** + * 查询待下载的文件 + * @param id + * @return + */ + @Cacheable(key = "'content:'+#p0") + QiniuContent findByContentId(Long id); + + /** + * 下载文件 + * @param content + * @param config + * @return + * @throws UnsupportedEncodingException + */ + ResponseEntity download(QiniuContent content,QiniuConfig config) throws UnsupportedEncodingException; + + /** + * 删除文件 + * @param content + * @param config + * @return + */ + @CacheEvict(allEntries = true) + void delete(QiniuContent content, QiniuConfig config); + + /** + * 同步数据 + * @param config + */ + @CacheEvict(allEntries = true) + void synchronize(QiniuConfig config); +} diff --git a/src/main/java/me/aurora/service/impl/AlipayServiceImpl.java b/src/main/java/me/aurora/service/impl/AlipayServiceImpl.java index 87af3ca..9ff20f3 100644 --- a/src/main/java/me/aurora/service/impl/AlipayServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/AlipayServiceImpl.java @@ -13,7 +13,6 @@ import me.aurora.service.AlipayService; import me.aurora.util.pay.AlipayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import java.util.Optional; /** @@ -74,7 +73,7 @@ public class AlipayServiceImpl implements AlipayService { AlipayClient alipayClient = new DefaultAlipayClient(alipay.getGatewayUrl(), alipay.getAppID(), alipay.getPrivateKey(), alipay.getFormat(), alipay.getCharset(), alipay.getPublicKey(), alipay.getSignType()); double money = Double.parseDouble(trade.getTotalAmount()); - if(money <= 0 || money>=500){ + if(money <= 0 || money >= 5000){ throw new AuroraException(HttpStatus.HTTP_BAD_REQUEST,"测试金额过大"); } @@ -116,7 +115,6 @@ public class AlipayServiceImpl implements AlipayService { @Override public AlipayConfig updateConfig(AlipayConfig alipayConfig) { - alipayConfig.setId(1L); alipayRepo.saveAndFlush(alipayConfig); return alipayConfig; } diff --git a/src/main/java/me/aurora/service/impl/EmailServiceImpl.java b/src/main/java/me/aurora/service/impl/EmailServiceImpl.java index 059a0a8..c54e7b1 100644 --- a/src/main/java/me/aurora/service/impl/EmailServiceImpl.java +++ b/src/main/java/me/aurora/service/impl/EmailServiceImpl.java @@ -24,10 +24,11 @@ public class EmailServiceImpl implements EmailService { private EmailRepo emailRepo; @Override - public EmailConfig updateConfig(EmailConfig emailConfig) { - emailConfig.setId(1L); + public EmailConfig updateConfig(EmailConfig emailConfig,EmailConfig old) { try { - emailConfig.setPass(EncryptHelper.desEncrypt(emailConfig.getPass())); + if(!emailConfig.getPass().equals(old.getPass())){ + emailConfig.setPass(EncryptHelper.desEncrypt(emailConfig.getPass())); + } } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/me/aurora/service/impl/QiNiuServiceImpl.java b/src/main/java/me/aurora/service/impl/QiNiuServiceImpl.java new file mode 100644 index 0000000..52ae226 --- /dev/null +++ b/src/main/java/me/aurora/service/impl/QiNiuServiceImpl.java @@ -0,0 +1,165 @@ +package me.aurora.service.impl; + +import cn.hutool.http.HttpStatus; +import com.google.gson.Gson; +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 me.aurora.config.exception.AuroraException; +import me.aurora.domain.ResponseEntity; +import me.aurora.domain.utils.QiniuConfig; +import me.aurora.domain.utils.QiniuContent; +import me.aurora.repository.QiNiuConfigRepo; +import me.aurora.repository.QiniuContentRepo; +import me.aurora.repository.spec.QiNiuContentSpec; +import me.aurora.service.QiNiuService; +import me.aurora.util.PageUtil; +import me.aurora.util.QiNiuUtil; +import me.aurora.util.SizeUtil; +import me.aurora.util.ValidationUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.UnsupportedEncodingException; +import java.sql.Timestamp; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +@Service +public class QiNiuServiceImpl implements QiNiuService { + + @Autowired + private QiNiuConfigRepo qiNiuConfigRepo; + + @Autowired + private QiniuContentRepo qiniuContentRepo; + + private final String TYPE = "公开"; + + @Override + public QiniuConfig findById(long id) { + return qiNiuConfigRepo.findById(id).get(); + } + + @Override + public QiniuConfig updateConfig(QiniuConfig qiniuConfig) { + if (!(qiniuConfig.getHost().toLowerCase().startsWith("http://")||qiniuConfig.getHost().toLowerCase().startsWith("https://"))) { + throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"外链域名必须以http://或者https://开头"); + } + qiNiuConfigRepo.saveAndFlush(qiniuConfig); + return qiniuConfig; + } + + @Override + public Map getContentInfo(QiNiuContentSpec qiNiuContentSpec, Pageable pageable) { + Page qiniuContents = qiniuContentRepo.findAll(qiNiuContentSpec,pageable); + return PageUtil.buildPage(qiniuContents.getContent(),qiniuContents.getTotalElements()); + } + + @Override + public void upload(MultipartFile file,QiniuConfig qiniuConfig) { + + /** + * 构造一个带指定Zone对象的配置类 + */ + Configuration cfg = QiNiuUtil.getConfiguration(qiniuConfig.getZone()); + UploadManager uploadManager = new UploadManager(cfg); + Auth auth = Auth.create(qiniuConfig.getAccessKey(), qiniuConfig.getSecretKey()); + String upToken = auth.uploadToken(qiniuConfig.getBucket()); + try { + Response response = uploadManager.put(file.getBytes(), QiNiuUtil.getKey(file.getOriginalFilename()), upToken); + //解析上传成功的结果 + DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); + //存入数据库 + QiniuContent qiniuContent = new QiniuContent(); + qiniuContent.setBucket(qiniuConfig.getBucket()); + qiniuContent.setType(qiniuConfig.getType()); + qiniuContent.setKey(putRet.key); + qiniuContent.setUrl(qiniuConfig.getHost()+"/"+putRet.key); + qiniuContent.setSize(SizeUtil.getSize(Integer.parseInt(file.getSize()+""))); + qiniuContentRepo.save(qiniuContent); + } catch (Exception e) { + throw new AuroraException(HttpStatus.HTTP_INTERNAL_ERROR,e.getMessage()); + } + } + + @Override + public QiniuContent findByContentId(Long id) { + QiniuContent qiniuContent = qiniuContentRepo.findById(id).get(); + ValidationUtil.isNull(qiniuContent,"文件不存在"); + return qiniuContent; + } + + @Override + public ResponseEntity download(QiniuContent content,QiniuConfig config) throws UnsupportedEncodingException { + String finalUrl = null; + 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 ResponseEntity.ok(finalUrl); + } + + @Override + public void delete(QiniuContent content, QiniuConfig config) { + //构造一个带指定Zone对象的配置类 + Configuration cfg = QiNiuUtil.getConfiguration(config.getZone()); + Auth auth = Auth.create(config.getAccessKey(), config.getSecretKey()); + BucketManager bucketManager = new BucketManager(auth, cfg); + try { + bucketManager.delete(content.getBucket(), content.getKey()); + qiniuContentRepo.delete(content); + } catch (QiniuException ex) { + System.err.println(ex.code()); + System.err.println(ex.response.toString()); + } + } + + @Override + public void synchronize(QiniuConfig config) { + //构造一个带指定Zone对象的配置类 + Configuration cfg = QiNiuUtil.getConfiguration(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 = null; + FileInfo[] items = fileListIterator.next(); + for (FileInfo item : items) { + if(qiniuContentRepo.findByKey(item.key) == null){ + qiniuContent = new QiniuContent(); + qiniuContent.setSize(SizeUtil.getSize(Integer.parseInt(item.fsize+""))); + qiniuContent.setKey(item.key); + qiniuContent.setType(config.getType()); + qiniuContent.setBucket(config.getBucket()); + qiniuContent.setUrl(config.getHost()+"/"+item.key); + qiniuContentRepo.save(qiniuContent); + } + } + } + + } +} diff --git a/src/main/java/me/aurora/util/QiNiuUtil.java b/src/main/java/me/aurora/util/QiNiuUtil.java new file mode 100644 index 0000000..daf283c --- /dev/null +++ b/src/main/java/me/aurora/util/QiNiuUtil.java @@ -0,0 +1,49 @@ +package me.aurora.util; + +import com.qiniu.common.Zone; +import com.qiniu.storage.Configuration; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 七牛云存储工具类 + * @author 郑杰 + * @date 2018/10/02 12:37:37 + */ +public class QiNiuUtil { + + /** + * 得到机房的对应关系 + * @param zone + * @return + */ + public static Configuration getConfiguration(String zone){ + + if(zone.equals("华东")){ + return new Configuration(Zone.zone0()); + } else if(zone.equals("华北")){ + return new Configuration(Zone.zone1()); + } else if(zone.equals("华南")){ + return new Configuration(Zone.zone2()); + } else if (zone.equals("北美")){ + return new Configuration(Zone.zoneNa0()); + } else { + return new Configuration(Zone.zoneAs0()); + } + } + + /** + * 默认不指定key的情况下,以文件内容的hash值作为文件名 + * @param file + * @return + */ + public static String getKey(String file){ + StringBuffer key = new StringBuffer(FileUtil.getFileNameNoEx(file)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + Date date = new Date(); + key.append(sdf.format(date)); + key.append("."); + key.append(FileUtil.getExtensionName(file)); + return key.toString(); + } +} diff --git a/src/main/resources/sql/aurora.sql b/src/main/resources/sql/aurora.sql index c2ac24e..2d64c31 100644 --- a/src/main/resources/sql/aurora.sql +++ b/src/main/resources/sql/aurora.sql @@ -5,13 +5,13 @@ Source Server Type : MySQL Source Server Version : 50559 Source Host : localhost:3306 - Source Schema : aurora + Source Schema : my_aurora Target Server Type : MySQL Target Server Version : 50559 File Encoding : 65001 - Date: 30/09/2018 16:17:12 + Date: 02/10/2018 16:35:37 */ SET NAMES utf8mb4; @@ -80,7 +80,7 @@ CREATE TABLE `zj_menu` ( `sys` bit(1) NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `UK_cbhg0bi3f1emxkhqqtvca9btx`(`soft`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 26 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Records of zj_menu @@ -101,11 +101,12 @@ INSERT INTO `zj_menu` VALUES (13, 'layui-icon-tree', 12, 2, '图床管理', 31, INSERT INTO `zj_menu` VALUES (14, 'layui-icon-tree', 5, 2, '在线用户', 12, '/online/index', '2018-09-21 16:09:38', '2018-09-22 10:17:09', 0, b'0', b'1'); INSERT INTO `zj_menu` VALUES (16, 'layui-icon-tree', 5, 2, 'Redis终端', 16, '/redis/terminal', '2018-09-22 11:18:21', '2018-09-27 13:25:09', 0, b'0', b'1'); INSERT INTO `zj_menu` VALUES (17, 'layui-icon-tree', 7, 2, '接口文档', 7, '/swagger/index', '2018-09-23 09:16:17', '2018-09-23 10:01:06', 0, b'0', b'1'); -INSERT INTO `zj_menu` VALUES (18, 'layui-icon-util', 0, 1, '工具管理', 40, '', '2018-09-24 23:46:02', '2018-09-30 15:16:43', 3, b'0', b'1'); -INSERT INTO `zj_menu` VALUES (19, 'layui-icon-tree', 18, 2, '富文本编辑', 45, '/ueditor/index', '2018-09-24 23:46:47', '2018-09-24 23:46:47', 0, b'0', b'1'); +INSERT INTO `zj_menu` VALUES (18, 'layui-icon-util', 0, 1, '工具管理', 40, '', '2018-09-24 23:46:02', '2018-10-02 11:03:27', 4, b'0', b'1'); +INSERT INTO `zj_menu` VALUES (19, 'layui-icon-code-circle', 18, 2, '富文本编辑', 45, '/ueditor/index', '2018-09-24 23:46:47', '2018-10-02 16:28:18', 0, b'0', b'1'); INSERT INTO `zj_menu` VALUES (21, 'layui-icon-tree', 5, 2, 'SQL监控', 15, '/druid/index.html', '2018-09-27 13:24:25', '2018-09-27 13:24:25', 0, b'1', b'1'); -INSERT INTO `zj_menu` VALUES (22, 'layui-icon-edit', 18, 2, '邮件工具', 41, '/email/index', '2018-09-28 07:32:57', '2018-09-28 07:32:57', 0, b'0', b'1'); -INSERT INTO `zj_menu` VALUES (24, 'layui-icon-tree', 18, 2, '支付宝工具', 42, '/aliPay/index', '2018-09-30 15:16:43', '2018-09-30 15:16:43', 0, b'0', b'0'); +INSERT INTO `zj_menu` VALUES (22, 'layui-icon-edit', 18, 2, '邮件工具', 41, '/email/index', '2018-09-28 07:32:57', '2018-10-02 16:26:01', 0, b'0', b'1'); +INSERT INTO `zj_menu` VALUES (24, 'layui-icon-dollar', 18, 2, '支付宝工具', 42, '/aliPay/index', '2018-09-30 15:16:43', '2018-10-02 16:27:09', 0, b'0', b'0'); +INSERT INTO `zj_menu` VALUES (25, 'layui-icon-upload', 18, 2, '七牛云存储', 43, '/qiNiu/index', '2018-10-02 11:03:27', '2018-10-02 16:26:42', 0, b'0', b'0'); -- ---------------------------- -- Table structure for zj_menus_roles @@ -144,6 +145,7 @@ INSERT INTO `zj_menus_roles` VALUES (19, 1); INSERT INTO `zj_menus_roles` VALUES (21, 1); INSERT INTO `zj_menus_roles` VALUES (22, 1); INSERT INTO `zj_menus_roles` VALUES (24, 1); +INSERT INTO `zj_menus_roles` VALUES (25, 1); INSERT INTO `zj_menus_roles` VALUES (5, 3); INSERT INTO `zj_menus_roles` VALUES (7, 3); INSERT INTO `zj_menus_roles` VALUES (9, 3); @@ -242,6 +244,36 @@ CREATE TABLE `zj_picture` ( -- ---------------------------- INSERT INTO `zj_picture` VALUES (1, '2018-09-21 12:01:57', '1', '200', '8.49KB ', 'https://i.loli.net/2018/09/21/5ba46d305018d.jpg', '200', 1, 'avatar'); +-- ---------------------------- +-- Table structure for zj_qiniu_config +-- ---------------------------- +DROP TABLE IF EXISTS `zj_qiniu_config`; +CREATE TABLE `zj_qiniu_config` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `accessKey` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `bucket` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `host` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `secretKey` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `zone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + +-- ---------------------------- +-- Table structure for zj_qiniu_content +-- ---------------------------- +DROP TABLE IF EXISTS `zj_qiniu_content`; +CREATE TABLE `zj_qiniu_content` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `bucket` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `size` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `updateTime` datetime NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + -- ---------------------------- -- Table structure for zj_role -- ---------------------------- @@ -276,7 +308,7 @@ CREATE TABLE `zj_syslog` ( `time` int(11) NULL DEFAULT NULL, `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 88 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; +) ENGINE = InnoDB AUTO_INCREMENT = 222 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; -- ---------------------------- -- Table structure for zj_user @@ -298,7 +330,7 @@ CREATE TABLE `zj_user` ( -- ---------------------------- -- Records of zj_user -- ---------------------------- -INSERT INTO `zj_user` VALUES (1, 'https://www.zhengjie.me/images/avatar.jpg', '2018-08-23 09:11:56', 'zhengjie@tom.com', 1, '2018-09-30 15:30:16', '65a674ce6632479005ea7a9071234cfb', 'aurora'); +INSERT INTO `zj_user` VALUES (1, 'https://www.zhengjie.me/images/avatar.jpg', '2018-08-23 09:11:56', 'zhengjie@tom.com', 1, '2018-10-02 14:03:44', '65a674ce6632479005ea7a9071234cfb', 'aurora'); -- ---------------------------- -- Table structure for zj_user_pictures diff --git a/src/main/resources/templates/common/app.html b/src/main/resources/templates/common/app.html index fd2da25..c8cba08 100644 --- a/src/main/resources/templates/common/app.html +++ b/src/main/resources/templates/common/app.html @@ -196,10 +196,10 @@
  • 百度富文本编辑器
  • 邮件发送工具
  • -
  • 支付宝支付(开发中)
  • +
  • 支付宝支付
  • +
  • 七牛云储存
  • 微信支付(开发中)
  • 阿里大鱼(开发中)
  • -
  • 七牛云储存(开发中)

diff --git a/src/main/resources/templates/utils/alipay/index.html b/src/main/resources/templates/utils/alipay/index.html index 19a0516..ec5a87f 100644 --- a/src/main/resources/templates/utils/alipay/index.html +++ b/src/main/resources/templates/utils/alipay/index.html @@ -92,7 +92,7 @@
-
商品价格不能为空,测试允许区间(0,500]
+
商品价格不能为空,测试允许区间(0,5000]
diff --git a/src/main/resources/templates/utils/qiNiu/add.html b/src/main/resources/templates/utils/qiNiu/add.html new file mode 100644 index 0000000..7d7ed1e --- /dev/null +++ b/src/main/resources/templates/utils/qiNiu/add.html @@ -0,0 +1,94 @@ + + + + + + Aurora- 上传文件 + + + + + + +
+
+ +
+ + + + + + + + +
文件名大小状态操作
+
+ +
+
+ + + + + + + diff --git a/src/main/resources/templates/utils/qiNiu/index.html b/src/main/resources/templates/utils/qiNiu/index.html new file mode 100644 index 0000000..94e9897 --- /dev/null +++ b/src/main/resources/templates/utils/qiNiu/index.html @@ -0,0 +1,366 @@ + + + + 七牛云存储 + + + + + +
+
    +
  • 参数配置
  • +
  • 文件列表
  • +
  • 使用说明
  • +
+
+
+
+
+ +
+ +
+
账号唯一的accessKey,在安全中心查看
+
+
+ +
+ +
+
账号唯一的secretKey,在安全中心查看
+
+
+ +
+ +
+
存储空间名称作为唯一的 Bucket 识别符
+
+
+ +
+ +
+
外链域名,可自定义,需在七牛云绑定
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+
+ 使用说明 +
+
+ 注意
+
+1、配置时外链域名需带上协议,也就是必须http/https开头
+2、如果七牛云中存在数据,使用同步按钮即可将数据同步到数据库
+3、本次集成了七牛云的常用操作,如:上传,下载,删除,同步,支持私有空间上传下载
+4、项目中配置存入数据库,如需测试,请使用临时空间进行测试,测试完成及时修改配置,反正数据泄露
+
开始使用
+
+#引入依赖
+<dependency>
+  <groupId>com.qiniu</groupId>
+  <artifactId>qiniu-java-sdk</artifactId>
+  <version>[7.2.0, 7.2.99]</version>
+<dependency>
+#简单的上传文件
+//构造一个带指定Zone对象的配置类
+Configuration cfg = new Configuration(Zone.zone0());
+//...其他参数参考类注释
+UploadManager uploadManager = new UploadManager(cfg);
+//...生成上传凭证,然后准备上传
+String accessKey = "your access key";
+String secretKey = "your secret key";
+String bucket = "your bucket name";
+//默认不指定key的情况下,以文件内容的hash值作为文件名
+String key = null;
+try {
+    byte[] uploadBytes = "hello qiniu cloud".getBytes("utf-8");
+    Auth auth = Auth.create(accessKey, secretKey);
+    String upToken = auth.uploadToken(bucket);
+    try {
+        Response response = uploadManager.put(uploadBytes, key, upToken);
+        //解析上传成功的结果
+        DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
+        System.out.println(putRet.key);
+        System.out.println(putRet.hash);
+    } catch (QiniuException ex) {
+        Response r = ex.response;
+        System.err.println(r.toString());
+        try {
+            System.err.println(r.bodyString());
+        } catch (QiniuException ex2) {
+            //ignore
+        }
+    }
+} catch (UnsupportedEncodingException ex) {
+    //ignore
+}
+
+
更多帮助
+
更多帮助请查看系统源码,或者七牛云java开发文档
+七牛云官网:https://sso.qiniu.com/
+七牛云java开发文档:https://developer.qiniu.com/kodo/sdk/1239/java#3
+
+
+
+
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/web/picture/index.html b/src/main/resources/templates/web/picture/index.html index 3992cb3..21ac302 100644 --- a/src/main/resources/templates/web/picture/index.html +++ b/src/main/resources/templates/web/picture/index.html @@ -28,7 +28,7 @@
- +
@@ -123,7 +123,7 @@ }); }); - //监听修改按钮 + //监听按钮 table.on('tool(tools)', function(obj){ var data = obj.data; if(obj.event === 'look'){