Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
9dc42da8
Commit
9dc42da8
authored
Apr 27, 2020
by
邓实川
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
环境变量配置-阿里云上传、短信,e签宝,系统赠送时间
parent
89a3596b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
301 additions
and
165 deletions
+301
-165
src/main/java/cn/timer/api/callback/wx/WxCallBackController.java
+30
-20
src/main/java/cn/timer/api/controller/LoginController.java
+87
-11
src/main/java/cn/timer/api/controller/dzht/cn/tign/hz/constant/ConfigConstant.java
+19
-9
src/main/java/cn/timer/api/controller/oss/OSSController.java
+7
-4
src/main/java/cn/timer/api/controller/qyzx/QyzxController.java
+4
-1
src/main/java/cn/timer/api/utils/aliyun/AliyunSMS.java
+14
-5
src/main/java/cn/timer/api/utils/aliyun/OSSUtil.java
+71
-102
src/main/java/cn/timer/api/utils/schedule/RemindUtil.java
+6
-4
src/main/resources/application-dev.yml
+27
-3
src/main/resources/application-pro.yml
+18
-3
src/main/resources/application-test.yml
+18
-3
No files found.
src/main/java/cn/timer/api/callback/wx/WxCallBackController.java
View file @
9dc42da8
...
...
@@ -26,6 +26,7 @@ import cn.hutool.core.date.DateField;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.timer.api.bean.qyzx.QyzxEntInfoM
;
import
cn.timer.api.bean.qyzx.businessService.QyzxBuyRecord
;
import
cn.timer.api.bean.qyzx.businessService.QyzxOrderRecord
;
import
cn.timer.api.bean.qyzx.businessService.QyzxRemainingQuantity
;
...
...
@@ -81,10 +82,10 @@ public class WxCallBackController {
if
(!
env
.
equals
(
"dev"
)
&&
!
env
.
equals
(
"test"
))
{
return
ResultUtil
.
error
(
"请切换到开发/测试环境"
);
}
// TODO 加套餐 如果已经存在可用的套餐 ,怎么搞
// TODO 加套餐 如果已经存在可用的套餐 ,怎么搞
// TODO 如果是系统续费 update企业信息表
updateAndInsert
(
orderNo
);
return
ResultUtil
.
data
(
orderNo
,
"购买成功"
);
}
...
...
@@ -102,7 +103,7 @@ public class WxCallBackController {
Integer
expiration
=
jsonObject
.
getInt
(
"expiration"
);
// 商品有效期(天)
Date
expireDate
=
DateUtil
.
offset
(
new
Date
(),
DateField
.
DAY_OF_YEAR
,
expiration
);
// 时间偏移
String
content
=
jsonObject
.
getStr
(
"content"
);
// 商品名称
Integer
specification
=
jsonObject
.
getInt
(
"specification"
);
// 商品规格
Integer
specification
=
jsonObject
.
getInt
(
"specification"
);
// 商品规格
-用于系统续费表示为系统版本0-试用 1-普通 2-专业
String
unit
=
jsonObject
.
getStr
(
"unit"
);
// Double originalPrice = jsonObject.getDouble("originalPrice"); // 商品原价
Double
nowPrice
=
jsonObject
.
getDouble
(
"nowPrice"
);
// 购买价
...
...
@@ -111,23 +112,32 @@ public class WxCallBackController {
Integer
pcid
=
qyzxOrderRecord
.
getPcid
();
// 付费内容id
Integer
createdUser
=
qyzxOrderRecord
.
getCreateUser
();
// 订单创建人
Integer
orgCode
=
qyzxOrderRecord
.
getOrgCode
();
// 公司
QyzxRemainingQuantity
quantity
=
new
QyzxRemainingQuantity
();
quantity
.
setOrderNo
(
orderNo
);
// 订单号
quantity
.
setContent
(
content
);
// 商品名称
quantity
.
setExpireDate
(
expireDate
);
// 到期时间
quantity
.
setSpecification
(
specification
);
// 套餐规格
Integer
totalNum
=
specification
*
count
;
// 套餐总量
quantity
.
setTotalNum
(
totalNum
);
quantity
.
setRemainder
(
totalNum
);
// 套餐剩余数(同上)
quantity
.
setCount
(
count
);
// 购买数量
quantity
.
setPmid
(
pmid
);
// 付费模块id
quantity
.
setPcid
(
pcid
);
// 付费内容id
quantity
.
setUnit
(
unit
);
quantity
.
setCreateUser
(
createdUser
);
quantity
.
setOrgCode
(
orgCode
);
quantity
.
insert
();
if
(
pmid
==
3
)
{
QyzxEntInfoM
qyzxEntInfoM
=
QyzxEntInfoM
.
builder
().
id
(
orgCode
).
build
().
selectById
();
// 企业信息
Date
endTime
=
qyzxEntInfoM
.
getEndTime
();
// 当前到期时间
// Integer level = qyzxEntInfoM.getLevel(); // 原系统版本
// Integer specification = jsonObject.getInt("specification"); // 新系统版本
Date
newEndTime
=
DateUtil
.
offsetDay
(
endTime
,
expiration
*
count
);
// 到期时间+商品有效期x购买数量=系统续费后的时间
qyzxEntInfoM
.
update
(
new
LambdaUpdateWrapper
<
QyzxEntInfoM
>().
eq
(
QyzxEntInfoM:
:
getId
,
orgCode
)
.
set
(
QyzxEntInfoM:
:
getEndTime
,
newEndTime
).
set
(
QyzxEntInfoM:
:
getLevel
,
specification
));
}
else
{
QyzxRemainingQuantity
quantity
=
new
QyzxRemainingQuantity
();
quantity
.
setOrderNo
(
orderNo
);
// 订单号
quantity
.
setContent
(
content
);
// 商品名称
quantity
.
setExpireDate
(
expireDate
);
// 到期时间
quantity
.
setSpecification
(
specification
);
// 套餐规格
quantity
.
setTotalNum
(
totalNum
);
// 套餐总量
quantity
.
setRemainder
(
totalNum
);
// 套餐剩余数(同上)
quantity
.
setCount
(
count
);
// 购买数量
quantity
.
setPmid
(
pmid
);
// 付费模块id
quantity
.
setPcid
(
pcid
);
// 付费内容id
quantity
.
setUnit
(
unit
);
quantity
.
setCreateUser
(
createdUser
);
quantity
.
setOrgCode
(
orgCode
);
quantity
.
insert
();
}
// 插入购买记录表
QyzxBuyRecord
qyzxBuyRecord
=
new
QyzxBuyRecord
();
qyzxBuyRecord
.
setSpecification
(
specification
);
...
...
src/main/java/cn/timer/api/controller/LoginController.java
View file @
9dc42da8
...
...
@@ -3,9 +3,12 @@ package cn.timer.api.controller;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Stream
;
import
javax.annotation.PostConstruct
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpSession
;
...
...
@@ -24,7 +27,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
cn.hutool.core.date.BetweenFormater.Level
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.timer.api.bean.qyzx.QyzxEmpEntAsso
;
...
...
@@ -57,8 +59,85 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping
(
value
=
"/login"
,
produces
=
{
"application/json"
})
public
class
LoginController
{
@Value
(
"${configtest.patht}"
)
public
String
port
;
@Value
(
"${config-8timer.register-free-time}"
)
public
Integer
offset
;
// 系统赠送时间
@Value
(
"${config-8timer.Aliyun.PROJECT_NAME}"
)
private
String
PROJECT_NAME
;
@Value
(
"${config-8timer.Aliyun.REGION_ID}"
)
private
String
REGION_ID
;
@Value
(
"${config-8timer.Aliyun.ACCESSKEY_ID}"
)
private
String
ACCESSKEY_ID
;
@Value
(
"${config-8timer.Aliyun.SECRET}"
)
private
String
SECRET
;
public
static
String
host
;
public
static
String
PROJECT_ID
;
public
static
String
PROJECT_SECRET
;
@Value
(
"${config-8timer.esign.host}"
)
private
String
host_s
;
@Value
(
"${config-8timer.esign.PROJECT_ID}"
)
private
String
PROJECT_ID_s
;
@Value
(
"${config-8timer.esign.PROJECT_SECRET}"
)
private
String
PROJECT_SECRET_s
;
@PostConstruct
public
void
init
()
{
host
=
host_s
;
PROJECT_ID
=
PROJECT_ID_s
;
PROJECT_SECRET
=
PROJECT_SECRET_s
;
}
@Value
(
"${config-8timer.Aliyun.PROJECT_NAME}"
)
private
String
endpoint
;
@Value
(
"${config-8timer.Aliyun.ACCESSKEY_ID}"
)
private
String
accessKeyId
;
@Value
(
"${config-8timer.Aliyun.SECRET}"
)
private
String
accessKeySecret
;
@Value
(
"${config-8timer.Aliyun.bucketName}"
)
private
String
bucketName
;
@Value
(
"${config-8timer.Aliyun.bucketName_pri}"
)
private
String
bucketName_pri
;
@Value
(
"${config-8timer.Aliyun.project_package}"
)
private
String
project_package
;
@Value
(
"${config-8timer.Aliyun.expirationTime}"
)
private
String
expirationTime
;
@Value
(
"${config-8timer.Aliyun.expirationTime_pri}"
)
private
String
expirationTime_pri
;
@GetMapping
(
value
=
"/test"
)
public
Map
<
String
,
Object
>
test
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"1"
,
offset
);
map
.
put
(
"2"
,
PROJECT_NAME
);
map
.
put
(
"3"
,
REGION_ID
);
map
.
put
(
"4"
,
ACCESSKEY_ID
);
map
.
put
(
"5"
,
SECRET
);
map
.
put
(
"6"
,
host
);
map
.
put
(
"7"
,
PROJECT_ID
);
map
.
put
(
"8"
,
PROJECT_SECRET
);
map
.
put
(
"9"
,
endpoint
);
map
.
put
(
"10"
,
accessKeyId
);
map
.
put
(
"11"
,
accessKeySecret
);
map
.
put
(
"12"
,
bucketName
);
map
.
put
(
"13"
,
bucketName_pri
);
map
.
put
(
"14"
,
project_package
);
map
.
put
(
"15"
,
expirationTime
);
map
.
put
(
"16"
,
expirationTime_pri
);
return
map
;
}
@Autowired
private
HttpSession
session
;
...
...
@@ -72,12 +151,6 @@ public class LoginController {
// @Autowired
// private DataSourceTransactionManager transactionManager;
@GetMapping
(
value
=
"/testPro"
)
public
Result
<
String
>
testPro
()
{
System
.
out
.
print
(
port
);
return
ResultUtil
.
success
(
"configtest:"
+
port
);
}
/**
* 发送验证码
*
...
...
@@ -381,7 +454,9 @@ public class LoginController {
}
// 企业信息
QyzxEntInfoM
qyzxEntInfoM
=
QyzxEntInfoM
.
builder
().
name
(
name
).
registerTime
(
DateUtil
.
date
()).
endTime
(
DateUtil
.
nextMonth
()).
level
(
CommonEnum
.
LEVEL_PROBATION
.
getType
()).
build
();
QyzxEntInfoM
qyzxEntInfoM
=
QyzxEntInfoM
.
builder
().
name
(
name
).
registerTime
(
DateUtil
.
date
())
.
endTime
(
DateUtil
.
offsetDay
(
new
Date
(),
offset
)).
level
(
CommonEnum
.
LEVEL_PROBATION
.
getType
())
.
build
();
boolean
b1
=
qyzxEntInfoM
.
insert
();
if
(!
b1
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
...
...
@@ -397,7 +472,8 @@ public class LoginController {
* DateUtil.date()) .endTime(DateUtil.nextMonth()).build();
*/
QyzxEmpLogin
qyzxEmpLogin
=
QyzxEmpLogin
.
builder
().
phone
(
phone
).
pw
(
Md5
.
md5
(
pw
))
.
sts
(
CommonEnum
.
U_STS_ON
.
getType
()).
orgId
(
qyzxEntInfoM
.
getId
()).
regTime
(
DateUtil
.
date
()).
build
();
.
sts
(
CommonEnum
.
U_STS_ON
.
getType
()).
orgId
(
qyzxEntInfoM
.
getId
()).
regTime
(
DateUtil
.
date
())
.
build
();
boolean
b2
=
qyzxEmpLogin
.
insert
();
if
(!
b2
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
...
...
src/main/java/cn/timer/api/controller/dzht/cn/tign/hz/constant/ConfigConstant.java
View file @
9dc42da8
package
cn
.
timer
.
api
.
controller
.
dzht
.
cn
.
tign
.
hz
.
constant
;
import
javax.annotation.PostConstruct
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
/**
* @version 2.0
...
...
@@ -8,15 +11,22 @@ import org.apache.commons.lang3.StringUtils;
*/
public
class
ConfigConstant
{
// 模拟环境域名
public
static
final
String
host
=
"https://smlopenapi.esign.cn"
;
// 生产环境域名
// public static final String host = "https://openapi.esign.cn";
// 项目Id(应用Id)
public
static
final
String
PROJECT_ID
=
"4438775940"
;
// 项目密钥(应用密钥)
public
static
final
String
PROJECT_SECRET
=
"7b100813cca2746081c57837855ac5af"
;
public
static
String
host
;
public
static
String
PROJECT_ID
;
public
static
String
PROJECT_SECRET
;
@Value
(
"${config-8timer.esign.host}"
)
private
String
host_s
;
@Value
(
"${config-8timer.esign.PROJECT_ID}"
)
private
String
PROJECT_ID_s
;
@Value
(
"${config-8timer.esign.PROJECT_SECRET}"
)
private
String
PROJECT_SECRET_s
;
@PostConstruct
public
void
init
()
{
host
=
host_s
;
PROJECT_ID
=
PROJECT_ID_s
;
PROJECT_SECRET
=
PROJECT_SECRET_s
;
}
// 机构认证地址
public
static
final
String
getJgrz_URL
(
String
accountId
)
{
...
...
src/main/java/cn/timer/api/controller/oss/OSSController.java
View file @
9dc42da8
...
...
@@ -5,6 +5,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -25,6 +26,8 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping
(
value
=
"/oss"
,
produces
=
{
"application/json"
})
@RestController
public
class
OSSController
{
@Autowired
private
OSSUtil
oss
;
/**
* 上传普通文件
...
...
@@ -44,7 +47,7 @@ public class OSSController {
return
ResultUtil
.
error
(
"上传的文件为空,请重新选择!"
);
}
else
{
try
{
url
=
OSSUtil
.
uploadFile
(
path
,
file
.
getInputStream
());
url
=
oss
.
uploadFile
(
path
,
file
.
getInputStream
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -70,7 +73,7 @@ public class OSSController {
return
ResultUtil
.
error
(
"上传的文件为空,请重新选择!"
);
}
else
{
try
{
url
=
OSSUtil
.
uploadFile
(
path
,
file
.
getInputStream
());
url
=
oss
.
uploadFile
(
path
,
file
.
getInputStream
());
list
.
add
(
url
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
@@ -92,7 +95,7 @@ public class OSSController {
return
ResultUtil
.
error
(
"上传的文件为空,请重新选择!"
);
}
else
{
try
{
OSSUtil
.
uploadPrivateFile
(
path
,
file
.
getInputStream
());
oss
.
uploadPrivateFile
(
path
,
file
.
getInputStream
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -108,7 +111,7 @@ public class OSSController {
public
Result
<
String
>
getUrlPrivate
(
@CurrentUser
UserBean
userBean
,
@RequestParam
String
moudle
,
@RequestParam
String
fileName
)
{
String
path
=
"8timer2.0/"
+
userBean
.
getOrgCode
()
+
"/"
+
moudle
+
"/"
+
fileName
;
String
url
=
OSSUtil
.
getUrlP
(
path
);
String
url
=
oss
.
getUrlP
(
path
);
return
ResultUtil
.
data
(
url
,
"获取成功"
);
}
...
...
src/main/java/cn/timer/api/controller/qyzx/QyzxController.java
View file @
9dc42da8
...
...
@@ -511,6 +511,9 @@ public class QyzxController {
*/
// 下载系统使用手册 直接提供(OSS公共读权限文件)url地址到前端按钮
@Autowired
OSSUtil
oss
;
/**
* 意见反馈
*/
...
...
@@ -528,7 +531,7 @@ public class QyzxController {
return
ResultUtil
.
error
(
"上传的文件为空,请重新选择!"
);
}
else
{
try
{
url
=
OSSUtil
.
uploadFile
(
path
,
file
.
getInputStream
());
url
=
oss
.
uploadFile
(
path
,
file
.
getInputStream
());
list
.
add
(
url
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
src/main/java/cn/timer/api/utils/aliyun/AliyunSMS.java
View file @
9dc42da8
...
...
@@ -2,6 +2,7 @@ package cn.timer.api.utils.aliyun;
import
java.util.Date
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -32,12 +33,20 @@ import cn.timer.api.dto.qyzx.EntRegisterDto;
*/
@Transactional
public
class
AliyunSMS
{
@Value
(
"${config-8timer.Aliyun.PROJECT_NAME}"
)
private
String
PROJECT_NAME
;
@Value
(
"${config-8timer.Aliyun.REGION_ID}"
)
private
String
REGION_ID
;
@Value
(
"${config-8timer.Aliyun.ACCESSKEY_ID}"
)
private
String
ACCESSKEY_ID
;
@Value
(
"${config-8timer.Aliyun.SECRET}"
)
private
String
SECRET
;
final
static
String
CODE_NAME
=
"TemplateCode"
;
// 短信模板代码参数名
final
static
String
REGION_ID
=
"cn-shenzhen"
;
// 地区参数
final
static
String
PROJECT_NAME
=
"8小时人事管家"
;
// 项目名
final
static
String
ACCESSKEY_ID
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
final
static
String
SECRET
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
final
static
String
TEMPLATE_PARAM
=
"TemplateParam"
;
// 自定义参数
final
static
String
DOMAIN
=
"dysmsapi.aliyuncs.com"
;
final
static
String
VERSION
=
"2017-05-25"
;
...
...
@@ -199,7 +208,7 @@ public class AliyunSMS {
* @return
*/
@SuppressWarnings
(
"deprecation"
)
public
static
String
remind
(
String
name
,
String
htname
,
String
time
,
String
phone
)
{
public
String
remind
(
String
name
,
String
htname
,
String
time
,
String
phone
)
{
Integer
orgCode
=
QyzxEmpLogin
.
builder
().
build
()
.
selectOne
(
new
LambdaQueryWrapper
<
QyzxEmpLogin
>().
eq
(
QyzxEmpLogin:
:
getPhone
,
phone
)).
getOrgId
();
...
...
src/main/java/cn/timer/api/utils/aliyun/OSSUtil.java
View file @
9dc42da8
...
...
@@ -10,6 +10,8 @@ import java.util.Date;
import
java.util.Iterator
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartHttpServletRequest
;
import
org.springframework.web.multipart.commons.CommonsMultipartResolver
;
...
...
@@ -30,20 +32,43 @@ import cn.timer.api.utils.ResultUtil;
* @author dsc
*
*/
@Component
public
class
OSSUtil
{
@Value
(
"${config-8timer.Aliyun.PROJECT_NAME}"
)
private
String
endpoint
;
@Value
(
"${config-8timer.Aliyun.ACCESSKEY_ID}"
)
private
String
accessKeyId
;
@Value
(
"${config-8timer.Aliyun.SECRET}"
)
private
String
accessKeySecret
;
@Value
(
"${config-8timer.Aliyun.bucketName}"
)
private
String
bucketName
;
@Value
(
"${config-8timer.Aliyun.bucketName_pri}"
)
private
String
bucketName_pri
;
@Value
(
"${config-8timer.Aliyun.project_package}"
)
private
String
project_package
;
@Value
(
"${config-8timer.Aliyun.expirationTime}"
)
private
String
expirationTime
;
@Value
(
"${config-8timer.Aliyun.expirationTime_pri}"
)
private
String
expirationTime_pri
;
/**
* 1.创建储存空间 sout控制台輸出 储存空间名
*
* @param bucketName OSS空间名
* @return 成功信息
*/
public
static
Result
<
Void
>
createZone
(
String
bucketName
)
{
public
Result
<
Void
>
createZone
(
String
bucketName
)
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
// 创建存储空间。
...
...
@@ -58,19 +83,12 @@ public class OSSUtil {
/**
* 2.上传文件到8time-v2
*
* @param path 上传路径(用'/'分包)
* @param ins 输入流
* @param ins
输入流
* @return
*/
public
static
String
uploadFile
(
String
path
,
InputStream
ins
)
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
// 上传储存空间设置为8time-v2
String
bucketName
=
"8time-v2"
;
public
String
uploadFile
(
String
path
,
InputStream
ins
)
{
// <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
// String objectName = "8time-v2/test/123.jpg";
// 创建OSSClient实例。
...
...
@@ -78,9 +96,8 @@ public class OSSUtil {
// 创建PutObjectRequest对象。
// 项目名+用户公司id+模块名+文件夹名+文件名
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
path
,
ins
);
//[file1,file2,file3],["mk1/img","mk1"]
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
path
,
ins
);
// [file1,file2,file3],["mk1/img","mk1"]
// 如果需要上传时设置存储类型与访问权限,请参考以下示例代码。
// ObjectMetadata metadata = new ObjectMetadata();
// metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS,
...
...
@@ -91,33 +108,26 @@ public class OSSUtil {
// 上传文件。
ossClient
.
putObject
(
putObjectRequest
);
// 设置URL过期时间为100年。
1s 1h 1d 1y
100y
// 设置URL过期时间为100年。
1s 1h 1d 1y
100y
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
1000
*
3600
*
24
*
365
*
100
);
// 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
System
.
err
.
println
(
url
);
// 关闭OSSClient。
ossClient
.
shutdown
();
// 返回上传成功的文件名
return
url
.
toString
();
}
/**
* 3.上传文件到8time-v2-private
*
* @param path 上传路径(用'/'分包)
* @param ins 输入流
* @param ins
输入流
* @return 文件路径
*/
public
static
String
uploadPrivateFile
(
String
path
,
InputStream
ins
)
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
// 上传储存空间设置为8time-v2
String
bucketName
=
"8time-v2-private"
;
public
String
uploadPrivateFile
(
String
path
,
InputStream
ins
)
{
// <yourObjectName>上传文件到OSS时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
// String objectName = "8time-v2/test/123.jpg";
// 创建OSSClient实例。
...
...
@@ -125,9 +135,8 @@ public class OSSUtil {
// 创建PutObjectRequest对象。
// 项目名+用户公司id+模块名+文件夹名+文件名
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName
,
path
,
ins
);
//[file1,file2,file3],["mk1/img","mk1"]
PutObjectRequest
putObjectRequest
=
new
PutObjectRequest
(
bucketName_pri
,
path
,
ins
);
// [file1,file2,file3],["mk1/img","mk1"]
// 如果需要上传时设置存储类型与访问权限,请参考以下示例代码。
// ObjectMetadata metadata = new ObjectMetadata();
// metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS,
...
...
@@ -141,9 +150,9 @@ public class OSSUtil {
// 设置URL过期时间为10分钟
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
1000
*
600
);
// 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
_pri
,
path
,
expiration
);
System
.
err
.
println
(
url
);
// 关闭OSSClient。
ossClient
.
shutdown
();
// 返回上传成功的文件名
...
...
@@ -161,15 +170,7 @@ public class OSSUtil {
* @param moudle 模块名
* @return 完整文件名
*/
public
static
Result
<
String
>
downloadFile
(
String
orgCode
,
String
moudle
,
String
dir
,
String
fileName
,
String
path
)
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
// 下载储存空间设置为8time-v2
String
bucketName
=
"8time-v2"
;
public
Result
<
String
>
downloadFile
(
String
orgCode
,
String
moudle
,
String
dir
,
String
fileName
,
String
path
)
{
// <yourObjectName>从OSS下载文件时需要指定包含文件后缀在内的完整路径,例如abc/efg/123.jpg。
// String objectName = "8time-v2/test/123.jpg";
// 创建OSSClient实例。
...
...
@@ -177,29 +178,19 @@ public class OSSUtil {
// 下载OSS文件到本地文件。如果指定的本地文件存在会覆盖,不存在则新建。
ossClient
.
getObject
(
new
GetObjectRequest
(
bucketName
,
"8timer2.0/"
+
orgCode
+
"/"
+
moudle
+
"/"
+
dir
+
"/"
+
fileName
),
new
GetObjectRequest
(
bucketName
,
project_package
+
orgCode
+
"/"
+
moudle
+
"/"
+
dir
+
"/"
+
fileName
),
new
File
(
path
+
fileName
));
// 关闭OSSClient。
ossClient
.
shutdown
();
// 完整路径的文件名
System
.
err
.
println
(
"objectName:"
+
"8timer2.0/"
+
orgCode
+
"/"
+
moudle
+
"/"
+
dir
+
"/"
+
fileName
);
System
.
err
.
println
(
"objectName:"
+
project_package
+
orgCode
+
"/"
+
moudle
+
"/"
+
dir
+
"/"
+
fileName
);
System
.
err
.
println
(
"path:"
+
path
+
fileName
);
// 返回成功的本地路径
return
ResultUtil
.
success
(
path
+
fileName
);
}
public
static
Result
<
BufferedReader
>
downloadFile
(
String
objectName
)
throws
IOException
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
// 下载储存空间设置为8time-v2
String
bucketName
=
"8time-v2"
;
public
Result
<
BufferedReader
>
downloadFile
(
String
objectName
)
throws
IOException
{
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
...
...
@@ -231,10 +222,9 @@ public class OSSUtil {
* @param files 批量文件
* @return 返回上传成功或失败的信息
*/
public
static
String
uploadFile
(
MultipartHttpServletRequest
request
,
List
<
MultipartFile
>
files
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
"http://oss-cn-shenzhen.aliyuncs.com"
,
"LTAI4FuaShJWQ1dggsFWG5CC"
,
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
);
public
String
uploadFile
(
MultipartHttpServletRequest
request
,
List
<
MultipartFile
>
files
)
{
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
String
newFileName
=
null
;
URL
url
=
null
;
...
...
@@ -250,13 +240,13 @@ public class OSSUtil {
Iterator
<
String
>
iter
=
multiRequest
.
getFileNames
();
// 此处上传单个文件,如需多个文件改为while循环
while
(
iter
.
hasNext
())
{
// 取得上传文件
files
=
multiRequest
.
getFiles
(
iter
.
next
());
if
(
files
!=
null
)
{
// 取得当前上传文件的文件名称
String
myFileName
=
null
;
for
(
MultipartFile
file
:
files
)
{
myFileName
=
file
.
getOriginalFilename
();
...
...
@@ -265,16 +255,16 @@ public class OSSUtil {
newFileName
=
System
.
currentTimeMillis
()
+
myFileName
.
substring
(
myFileName
.
lastIndexOf
(
"."
));
// 上传客户端文件到oss,如直接上传服务器文件到oss,可使用new FileInputStream( new File("服务器文件路径"))
ossClient
.
putObject
(
"8time-v2"
,
newFileName
,
file
.
getInputStream
());
ossClient
.
putObject
(
bucketName
,
newFileName
,
file
.
getInputStream
());
// 设置URL过期时间为100年。 1s 1h 1d 1y 100y
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
1000
*
3600
*
24
*
365
*
100
);
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
Long
.
parseLong
(
expirationTime
)
);
// 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。
url
=
ossClient
.
generatePresignedUrl
(
"8time-v2"
,
newFileName
,
expiration
);
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
newFileName
,
expiration
);
System
.
err
.
println
(
url
);
}
}
}
}
}
...
...
@@ -286,7 +276,7 @@ public class OSSUtil {
ossClient
.
shutdown
();
}
return
url
.
toString
();
/*
* if (file == null || file.getSize() <= 0) { return
* ResultUtil.error("上传的文件为空,请重新选择!"); } else { try {
...
...
@@ -298,24 +288,17 @@ public class OSSUtil {
/**
* 获取8time-v2文件的url
*
* @return url地址
*/
public
static
String
getUrl
(
String
path
)
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
String
bucketName
=
"8time-v2"
;
public
String
getUrl
(
String
path
)
{
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
// 设置URL过期时间为10年。 1s 1h 1d 1y 10y
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
1000
*
3600
*
24
*
365
*
10
);
// 设置URL过期时间为10
0
年。 1s 1h 1d 1y 10y
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
Long
.
parseLong
(
expirationTime
)
);
// 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
System
.
err
.
println
(
url
);
// 关闭OSSClient。
ossClient
.
shutdown
();
...
...
@@ -324,37 +307,23 @@ public class OSSUtil {
/**
* 获取8time-v2-private文件的url
*
* @return url地址
*/
public
static
String
getUrlP
(
String
path
)
{
// Endpoint以杭州为例,其它Region请按实际情况填写。
String
endpoint
=
"http://oss-cn-shenzhen.aliyuncs.com"
;
// 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录
// https://ram.console.aliyun.com 创建RAM账号。
String
accessKeyId
=
"LTAI4FuaShJWQ1dggsFWG5CC"
;
String
accessKeySecret
=
"EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR"
;
String
bucketName
=
"8time-v2-private"
;
public
String
getUrlP
(
String
path
)
{
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endpoint
,
accessKeyId
,
accessKeySecret
);
// 设置URL过期时间为10分钟。
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
1000
*
600
);
// 设置URL过期时间为10分钟。
Date
expiration
=
new
Date
(
new
Date
().
getTime
()
+
Long
.
parseLong
(
expirationTime_pri
)
);
// 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
URL
url
=
ossClient
.
generatePresignedUrl
(
bucketName
,
path
,
expiration
);
System
.
err
.
println
(
url
);
// 关闭OSSClient。
ossClient
.
shutdown
();
return
url
.
toString
();
}
/*
* (跨域资源) // Endpoint以杭州为例,其它Region请按实际情况填写。 String endpoint =
* "http://oss-cn-hangzhou.aliyuncs.com"; //
...
...
src/main/java/cn/timer/api/utils/schedule/RemindUtil.java
View file @
9dc42da8
...
...
@@ -58,6 +58,8 @@ public class RemindUtil implements SchedulingConfigurer {
*/
// @Scheduled(cron = "0 0 8 * * ?") // 每天8点扫一下看有没要提醒的,有就发一个
public
static
String
reportCurrentTime
()
{
AliyunSMS
sms
=
new
AliyunSMS
();
List
<
HtzzAssoHtgx
>
htgxs
=
HtzzAssoHtgx
.
builder
().
build
().
selectAll
();
for
(
HtzzAssoHtgx
htgx
:
htgxs
)
{
QueryWrapper
<
HtzzAdminZzda
>
q
=
new
QueryWrapper
<
HtzzAdminZzda
>();
...
...
@@ -75,13 +77,13 @@ public class RemindUtil implements SchedulingConfigurer {
System
.
err
.
println
(
name
+
" 的 "
+
htname
+
"还有: "
+
betweenDay
+
" 天到期"
);
if
(
sjc
>
0
)
{
if
(
betweenDay
<=
1
)
{
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于1天短信提醒
sms
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于1天短信提醒
}
else
if
(
betweenDay
==
3
)
{
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于3天短信提醒
sms
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于3天短信提醒
}
else
if
(
betweenDay
==
7
)
{
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于7天短信提醒
sms
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于7天短信提醒
}
else
if
(
betweenDay
==
30
)
{
AliyunSMS
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于30天短信提醒
sms
.
remind
(
name
,
htname
,
time
,
phone
);
// 少于30天短信提醒
}
}
else
{
zzda
.
setTxkgType
(
1
);
// 关闭提醒
...
...
src/main/resources/application-dev.yml
View file @
9dc42da8
...
...
@@ -149,5 +149,29 @@ logging:
# ui-config:
# operations-sorter: method # 它提供了两个配置项:alpha和method,分别代表了按字母表排序以及按方法定义顺序排序
configtest
:
patht
:
'
devPath-dev'
\ No newline at end of file
config-8timer
:
register-free-time
:
90
#系统赠送时间
Aliyun
:
# 阿里云
PROJECT_NAME
:
8小时人事管家
REGION_ID
:
cn-shenzhen
ACCESSKEY_ID
:
LTAI4FuaShJWQ1dggsFWG5CC
SECRET
:
EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR
endpoint
:
http://oss-cn-shenzhen.aliyuncs.com
# accessKeyId: LTAI4FuaShJWQ1dggsFWG5CC
# accessKeySecret: EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR
bucketName
:
8time-v2
bucketName_pri
:
8time-v2-private
project_package
:
8timer2.0/
expirationTime
:
3153600000000L
expirationTime_pri
:
600000L
esign
:
# e签宝
host
:
https://smlopenapi.esign.cn
# test
:
https://smlopenapi.esign.cn
# pro
:
https://openapi.esign.cn
PROJECT_ID
:
4438775940
PROJECT_SECRET
:
7b100813cca2746081c57837855ac5af
\ No newline at end of file
src/main/resources/application-pro.yml
View file @
9dc42da8
...
...
@@ -125,5 +125,20 @@ logging:
# ui-config:
# operations-sorter: method # 它提供了两个配置项:alpha和method,分别代表了按字母表排序以及按方法定义顺序排序
configtest
:
patht
:
'
devPath-pro'
\ No newline at end of file
config-8timer
:
register-free-time
:
90
#系统赠送时间
Aliyun
:
# 阿里云
PROJECT_NAME
:
8小时人事管家
REGION_ID
:
cn-shenzhen
ACCESSKEY_ID
:
LTAI4FuaShJWQ1dggsFWG5CC
SECRET
:
EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR
endpoint
:
http://oss-cn-shenzhen.aliyuncs.com
bucketName
:
8time-v2
bucketName_pri
:
8time-v2-private
project_package
:
8timer2.0/
expirationTime
:
3153600000000L
expirationTime_pri
:
600000L
esign
:
# e签宝
host
:
https://openapi.esign.cn
PROJECT_ID
:
4438775940
PROJECT_SECRET
:
7b100813cca2746081c57837855ac5af
\ No newline at end of file
src/main/resources/application-test.yml
View file @
9dc42da8
...
...
@@ -125,5 +125,20 @@ logging:
# ui-config:
# operations-sorter: method # 它提供了两个配置项:alpha和method,分别代表了按字母表排序以及按方法定义顺序排序
configtest
:
patht
:
'
devPath-test'
\ No newline at end of file
config-8timer
:
register-free-time
:
90
#系统赠送时间
Aliyun
:
# 阿里云
PROJECT_NAME
:
8小时人事管家
REGION_ID
:
cn-shenzhen
ACCESSKEY_ID
:
LTAI4FuaShJWQ1dggsFWG5CC
SECRET
:
EJ6qToT4T4u0B5Rb6qrta9WkyGHvGR
endpoint
:
http://oss-cn-shenzhen.aliyuncs.com
bucketName
:
8time-v2
bucketName_pri
:
8time-v2-private
project_package
:
8timer2.0/
expirationTime
:
3153600000000L
expirationTime_pri
:
600000L
esign
:
# e签宝
host
:
https://smlopenapi.esign.cn
PROJECT_ID
:
4438775940
PROJECT_SECRET
:
7b100813cca2746081c57837855ac5af
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment