Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
data-server
Commits
62967cae
Commit
62967cae
authored
Mar 11, 2021
by
licc
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
0cfc50ce
897fa954
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
372 additions
and
22 deletions
+372
-22
BaseException.java
...ain/java/cn/wisenergy/common/expection/BaseException.java
+2
-0
Constants.java
...on/src/main/java/cn/wisenergy/common/utils/Constants.java
+20
-0
RedisKeyUtils.java
...rc/main/java/cn/wisenergy/common/utils/RedisKeyUtils.java
+39
-0
ShopZxMapper.java
...apper/src/main/java/cn/wisenergy/mapper/ShopZxMapper.java
+7
-0
ShopZxMapper.xml
wisenergy-mapper/src/main/resources/mapper/ShopZxMapper.xml
+21
-1
UsersMapper.xml
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
+0
-3
shopZx.java
...gy-model/src/main/java/cn/wisenergy/model/app/shopZx.java
+10
-2
wisenergy-model.iml
wisenergy-model/wisenergy-model.iml
+171
-0
UploadService.java
...src/main/java/cn/wisenergy/service/app/UploadService.java
+7
-0
UserService.java
...e/src/main/java/cn/wisenergy/service/app/UserService.java
+6
-0
OrderServiceImpl.java
.../java/cn/wisenergy/service/app/impl/OrderServiceImpl.java
+8
-4
UploadServiceImpl.java
...java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
+24
-8
UserServiceImpl.java
...n/java/cn/wisenergy/service/app/impl/UserServiceImpl.java
+19
-4
LoginController.java
...n/wisenergy/web/admin/controller/app/LoginController.java
+29
-0
UploadController.java
.../wisenergy/web/admin/controller/app/UploadController.java
+9
-0
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/expection/BaseException.java
View file @
62967cae
...
...
@@ -35,4 +35,6 @@ public class BaseException extends RuntimeException {
this
.
msg
=
msg
;
this
.
code
=
code
;
}
}
wisenergy-common/src/main/java/cn/wisenergy/common/utils/Constants.java
View file @
62967cae
...
...
@@ -85,4 +85,24 @@ public class Constants {
public
static
String
TOKEN_PRIFIX
=
"token"
;
public
static
String
BANK_PRIFIX
=
"bank"
;
}
/**
* redis常量
*/
public
static
class
Redis
{
/**
* 项目公共 前缀
*/
public
final
static
String
PREFIX
=
"xts"
;
/**
* 短信相关
*/
public
final
static
String
PREFIX_SMS
=
"sms:"
;
/**
* token相关
*/
public
final
static
String
PREFIX_TOKEN
=
"token:"
;
}
}
wisenergy-common/src/main/java/cn/wisenergy/common/utils/RedisKeyUtils.java
0 → 100644
View file @
62967cae
package
cn
.
wisenergy
.
common
.
utils
;
/**
* redis key工具类
* m1991
*/
public
class
RedisKeyUtils
{
/**
* 根据出入的参数创建一个Redis key
* @return 如果参数为空,那么返回null
*/
public
static
String
formatKeys
(
String
...
args
){
if
(
args
!=
null
&&
args
.
length
>
0
){
StringBuilder
key
=
new
StringBuilder
();
for
(
String
s:
args
){
key
.
append
(
s
).
append
(
Constants
.
Connnector
.
UNDERLINE
);
}
return
key
.
toString
();
}
return
null
;
}
/**
* 根据出入的参数创建一个Redis key,自动拼接前缀
* @return 如果参数为空,那么返回null
*/
public
static
String
formatKeyWithPrefix
(
String
...
args
){
if
(
args
!=
null
&&
args
.
length
>
0
){
StringBuilder
key
=
new
StringBuilder
(
Constants
.
Redis
.
PREFIX
).
append
(
Constants
.
Connnector
.
UNDERLINE
);
for
(
String
s:
args
){
key
.
append
(
s
).
append
(
Constants
.
Connnector
.
UNDERLINE
);
}
return
key
.
toString
();
}
return
null
;
}
}
\ No newline at end of file
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/ShopZxMapper.java
View file @
62967cae
...
...
@@ -27,4 +27,11 @@ public interface ShopZxMapper extends BaseMapper<shopZx> {
* 查询资讯数据
*/
List
<
zxUserDto
>
selectPage
(
@Param
(
"pageNum"
)
Integer
pageNum
,
@Param
(
"pageSize"
)
Integer
pageSize
);
/**
* 点赞接口专用
*/
shopZx
selectByzxid
(
@Param
(
"zxid"
)
Integer
zxid
);
int
updateByzxid
(
@Param
(
"zxid"
)
Integer
zxid
,
@Param
(
"zxLikes"
)
Integer
zxLikes
);
}
wisenergy-mapper/src/main/resources/mapper/ShopZxMapper.xml
View file @
62967cae
...
...
@@ -27,6 +27,11 @@
<sql
id=
"vals"
>
#{zxUrl},#{zxField},#{zxAddress},#{inviteCode},#{zxDate}
</sql>
<sql
id=
"updateCondition"
>
<if
test=
"zxLikes != null"
>
zx_likes = #{zxLikes},
</if>
</sql>
<!--资讯内容插入-->
<insert
id=
"zxadd"
parameterType=
"cn.wisenergy.model.app.shopZx"
>
insert into
...
...
@@ -53,9 +58,24 @@
WHERE zx_to_examine != 0
order by zxid desc limit #{pageNum},#{pageSize}
</select>
<!--资讯总记录数查询-->
<select
id=
"selectAllNum"
parameterType=
"cn.wisenergy.model.app.shopZx"
>
select count (*) from shop_zx
</select>
<!--资讯点赞专用sql-->
<select
id=
"selectByzxid"
parameterType=
"java.lang.Integer"
resultType=
"cn.wisenergy.model.app.shopZx"
>
select * from shop_zx where zx_id=#{zxid}
</select>
<update
id=
"updateByzxid"
>
UPDATE
<include
refid=
"table"
/>
<set>
zx_likes = #{zxLikes}
</set>
<where>
zx_id = #{zxid}
</where>
</update>
</mapper>
\ No newline at end of file
wisenergy-mapper/src/main/resources/mapper/UsersMapper.xml
View file @
62967cae
...
...
@@ -83,9 +83,6 @@
<set>
<include
refid=
"updateCondition"
/>
</set>
<where>
id = #{id}
</where>
</update>
<delete
id=
"delById"
parameterType=
"java.lang.Integer"
>
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/app/shopZx.java
View file @
62967cae
...
...
@@ -9,8 +9,6 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigInteger
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -56,6 +54,16 @@ public class shopZx extends Model<shopZx> implements Serializable {
*/
@ApiModelProperty
(
name
=
"zx_field"
,
value
=
"资讯文字输入字段"
)
private
String
zxField
;
public
Integer
getZxLikes
()
{
return
zxLikes
;
}
public
Integer
setZxLikes
(
Integer
zxLikes
)
{
this
.
zxLikes
=
zxLikes
;
return
zxLikes
;
}
/**
* 用户发布地址
*/
...
...
wisenergy-model/wisenergy-model.iml
View file @
62967cae
This diff is collapsed.
Click to expand it.
wisenergy-service/src/main/java/cn/wisenergy/service/app/UploadService.java
View file @
62967cae
...
...
@@ -53,5 +53,12 @@ public interface UploadService {
*/
Map
selectPage
(
Integer
pageNum
,
Integer
pageSize
);
/**
* TODO 资讯点赞
* @param zxid
* @return
*/
Map
Ilike
(
Integer
zxid
);
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/UserService.java
View file @
62967cae
...
...
@@ -47,6 +47,12 @@ public interface UserService {
*/
Map
userByZx
(
String
userId
,
String
beInvitedCode
);
/**
* 用户登出
* @param token
* @return
*/
int
logout
(
String
token
);
Integer
getUserIdById
(
String
userId
);
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/OrderServiceImpl.java
View file @
62967cae
...
...
@@ -40,12 +40,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
private
OrderMapper
orderMapper
;
//有赞客户端
DefaultYZClient
yzClient
=
new
DefaultYZClient
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd
hh
:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd
HH
:mm:ss"
);
Date
startCreatedDate
=
null
;
Date
endCreatedDate
=
null
;
Date
startUpdateDate
=
null
;
Date
endUpdateDate
=
null
;
Date
date
=
new
Date
();
//
Date date = new Date();
/**
* 根据订单的创建时间获取有赞的订单数据 插入本地数据库
...
...
@@ -56,6 +56,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
@XxlJob
(
value
=
"YouZanOrdersjobhandler"
)
@Override
public
void
getYouZanOrdersForCreateTime
()
throws
SDKException
{
Date
date
=
new
Date
();
Token
token
=
youzanToken
();
YouzanTradesSoldGet
youzanTradesSoldGet
=
new
YouzanTradesSoldGet
();
//创建参数对象,并设置参数
...
...
@@ -65,9 +66,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
// startCreatedDate = sdf.parse("2021-01-28 11:04:01");
// endCreatedDate = sdf.parse("2021-03-1 16:39:59");
//当前时间的前1分钟
startCreatedDate
=
sdf
.
parse
(
sdf
.
format
(
new
Date
(
date
.
getTime
()-(
long
)
60
*
1000
)));
startCreatedDate
=
sdf
.
parse
(
sdf
.
format
(
new
Date
(
date
.
getTime
()-(
long
)
5
*
60
*
1000
)));
log
.
info
(
"订单创建开始时间"
+
sdf
.
format
(
startCreatedDate
));
endCreatedDate
=
sdf
.
parse
(
sdf
.
format
(
date
));
String
format
=
sdf
.
format
(
date
);
log
.
info
(
"订单创建结束时间"
+
sdf
.
format
(
endCreatedDate
));
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
...
...
@@ -139,6 +142,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
@XxlJob
(
value
=
"YouZanOrdersForUpdateTimejobhandler"
)
@Override
public
void
getYouZanOrdersForUpdateTime
()
throws
SDKException
{
Date
date
=
new
Date
();
Token
token
=
youzanToken
();
YouzanTradesSoldGet
youzanTradesSoldGet
=
new
YouzanTradesSoldGet
();
//创建参数对象,并设置参数
...
...
@@ -147,7 +151,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
try
{
// startUpdateDate = sdf.parse("2021-02-28 11:04:01");
// endUpdateDate = sdf.parse("2021-03-2 16:39:59");
startUpdateDate
=
sdf
.
parse
(
sdf
.
format
(
new
Date
(
date
.
getTime
()-(
long
)
60
*
1000
)));
startUpdateDate
=
sdf
.
parse
(
sdf
.
format
(
new
Date
(
date
.
getTime
()-(
long
)
5
*
60
*
1000
)));
log
.
info
(
"订单修改开始时间"
+
sdf
.
format
(
startUpdateDate
));
endUpdateDate
=
sdf
.
parse
(
sdf
.
format
(
date
));
log
.
info
(
"订单修改结束时间"
+
sdf
.
format
(
endUpdateDate
));
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
View file @
62967cae
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.wisenergy.common.expection.BaseException
;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.shopZx
;
import
cn.wisenergy.model.app.zxUserDto
;
import
com.alibaba.fastjson.JSON
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.UrlResource
;
import
org.springframework.stereotype.Service
;
...
...
@@ -167,11 +168,9 @@ public class UploadServiceImpl implements UploadService {
if
(
file
.
isEmpty
())
{
System
.
out
.
println
(
"上传图片为空,请重新上传"
);
}
//判断上传文件格式
String
fileType
=
file
.
getContentType
();
if
(
fileType
.
equals
(
"image/jpeg"
)
||
fileType
.
equals
(
"image/png"
))
{
//上传后保存的文件名(需要防止图片重名导致的文件覆盖)
//获取文件名
fileName1
=
file
.
getOriginalFilename
();
...
...
@@ -182,21 +181,18 @@ public class UploadServiceImpl implements UploadService {
//设置文件存储路径,可以存放在你想要指定的路径里面
String
Path
=
"/opt/upload/video/"
;
//上传图片存放位置
zxUrl
+=
localPath
+
fileName
+
","
;
if
(
FileUtils
.
upload
(
file
,
Path
,
fileName
))
{
//文件存放的相对路径(一般存放在数据库用于img标签的src)
String
relativePath
=
"用于判断是否图片上传成功,返回值有:"
+
fileName
;
result
.
put
(
"relativePath"
,
relativePath
);
//前端根据是否存在该字段来判断上传是否成功
result_msg
=
"图片上传成功"
;
result
.
put
(
"zxUrl"
,
zxUrl
);
}
else
{
result_msg
=
"图片上传失败"
;
}
}
else
{
result_msg
=
"图片格式不正确"
;
}
}
result
.
put
(
"result_msg"
,
result_msg
);
root
.
add
(
result
);
...
...
@@ -242,11 +238,9 @@ public class UploadServiceImpl implements UploadService {
if
(
fileName
.
contains
(
".."
))
{
throw
new
FileException
(
"Sorry! Filename contains invalid path sequence "
+
fileName
);
}
// Copy file to the target location (Replacing existing file with the same name)
Path
targetLocation
=
this
.
fileStorageLocation
.
resolve
(
fileName
);
Files
.
copy
(
file
.
getInputStream
(),
targetLocation
,
StandardCopyOption
.
REPLACE_EXISTING
);
return
fileName
;
}
catch
(
IOException
ex
)
{
throw
new
FileException
(
"Could not store file "
+
fileName
+
". Please try again!"
,
ex
);
...
...
@@ -290,4 +284,26 @@ public class UploadServiceImpl implements UploadService {
return
map
;
}
/**
* 资讯点赞实现
* @param zxid
* @return
*/
@Override
public
Map
Ilike
(
Integer
zxid
)
{
Map
map
=
new
HashMap
();
try
{
shopZx
shopZx
=
shopZxMapper
.
selectByzxid
(
zxid
);
int
a
=
shopZx
.
getZxLikes
();
Integer
zxLikes
=
shopZx
.
setZxLikes
(
a
+
1
);
shopZxMapper
.
updateByzxid
(
zxid
,
zxLikes
);
map
.
put
(
"code"
,
0
);
map
.
put
(
"msg"
,
"点赞成功!"
);
}
catch
(
BaseException
e
){
map
.
put
(
"code"
,
1
);
map
.
put
(
"msg"
,
"点赞失败!"
);
};
return
map
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserServiceImpl.java
View file @
62967cae
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.common.utils.RedisUtils
;
import
cn.wisenergy.common.utils.ResultUtils
;
import
cn.wisenergy.common.utils.ShareCodeUtil
;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.mapper.RecommendUserMapper
;
import
cn.wisenergy.mapper.TeamUserInfoMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
...
...
@@ -42,6 +39,9 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
@Autowired
private
TeamUserInfoMapper
teamUserInfoMapper
;
@Autowired
private
RedisUtils
redisUtils
;
@Override
public
User
getById
(
String
userId
)
{
return
usersMapper
.
getByUserId
(
userId
);
...
...
@@ -284,4 +284,19 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
teamgg
(
beInvitedCode
);
return
R
.
ok
(
"团队表普通用户数量+1成功!"
,
0
);
}
/**
* 用户登出
* @param token
* @return
*/
@Override
public
int
logout
(
String
token
)
{
int
succ
=
0
;
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
token
);
redisUtils
.
delete
(
key
);
if
(
redisUtils
.
getValue
(
key
)
==
null
){
succ
=
1
;
}
return
succ
;
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/LoginController.java
View file @
62967cae
...
...
@@ -2,6 +2,7 @@ package cn.wisenergy.web.admin.controller.app;
import
cn.hutool.extra.qrcode.QrCodeUtil
;
import
cn.hutool.extra.qrcode.QrConfig
;
import
cn.wisenergy.common.enums.ResultEnum
;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.model.app.UsersDto
;
...
...
@@ -43,6 +44,9 @@ import java.util.Map;
@RequestMapping
(
"api/user"
)
@RestController
public
class
LoginController
{
@Autowired
private
RedisUtils
redisUtils
;
...
...
@@ -183,4 +187,29 @@ public class LoginController {
return
usersService
.
userByZx
(
userId
,
beInvitedCode
);
}
/**
* 退出登录
* @param request
* @return
*/
@ApiOperation
(
value
=
"退出登录"
,
produces
=
"application/json"
,
notes
=
"退出登录"
)
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"token"
,
value
=
"用户token"
,
required
=
true
,
dataType
=
"String"
)
@PostMapping
(
"/logout"
)
public
Result
logout
(
HttpServletRequest
request
)
{
log
.
info
(
"退出登录"
);
Result
result
=
ResultUtils
.
returnFail
();
String
token
=
request
.
getHeader
(
"token"
);
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
Constants
.
Redis
.
PREFIX_TOKEN
,
token
);
if
(
redisUtils
.
getValue
(
key
)
==
null
){
log
.
info
(
"要退出登录的用户未登录"
);
return
ResultUtils
.
returnResult
(
ResultEnum
.
FILE_NOT_LOGIN
);
}
int
succ
=
usersService
.
logout
(
token
);
if
(
succ
>
0
)
{
result
=
ResultUtils
.
returnSuccess
();
}
return
result
;
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/UploadController.java
View file @
62967cae
...
...
@@ -110,4 +110,13 @@ public class UploadController {
return
uploadService
.
selectPage
(
pageNum
,
pageSize
);
}
/**
* 点赞接口
*/
@ApiImplicitParam
(
name
=
"zxid"
,
value
=
"资讯ID"
,
required
=
true
,
dataType
=
"integer"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/thumbUp"
)
public
Map
like
(
int
zxid
){
return
uploadService
.
Ilike
(
zxid
);
}
}
\ 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