Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
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
zengtianlai3
ioc_sixiang_license
Commits
25e5d8db
Commit
25e5d8db
authored
Jan 30, 2023
by
ma
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改报警通知的邮箱
parent
279681d1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
30 deletions
+89
-30
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+30
-19
UpdateNotifyDTO.java
...n/java/iot/sixiang/license/model/dto/UpdateNotifyDTO.java
+15
-0
UserService.java
...rc/main/java/iot/sixiang/license/service/UserService.java
+4
-0
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+40
-11
No files found.
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
25e5d8db
...
@@ -14,6 +14,7 @@ import iot.sixiang.license.log.MyLog;
...
@@ -14,6 +14,7 @@ import iot.sixiang.license.log.MyLog;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.CommonUtil
;
...
@@ -24,7 +25,7 @@ import java.util.List;
...
@@ -24,7 +25,7 @@ import java.util.List;
/**
/**
* <p>
* <p>
*
前端控制器
* 前端控制器
* </p>
* </p>
*
*
* @author m33
* @author m33
...
@@ -40,15 +41,16 @@ public class UserController {
...
@@ -40,15 +41,16 @@ public class UserController {
/**
/**
* 添加user
* 添加user
*
* @param jsonObject
* @param jsonObject
* @return
* @return
*/
*/
@ApiOperation
(
value
=
"用户添加接口"
,
notes
=
"用于添加用户"
)
@ApiOperation
(
value
=
"用户添加接口"
,
notes
=
"用于添加用户"
)
@PostMapping
(
"add"
)
@PostMapping
(
"add"
)
@MyLog
(
title
=
"添加用户"
,
optParam
=
"#{jsonObject}"
,
businessType
=
BusinessType
.
INSERT
)
@MyLog
(
title
=
"添加用户"
,
optParam
=
"#{jsonObject}"
,
businessType
=
BusinessType
.
INSERT
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"userName"
,
value
=
"账户名"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@DynamicParameter
(
name
=
"userName"
,
value
=
"账户名"
,
required
=
true
,
dataTypeClass
=
String
.
class
),
@DynamicParameter
(
name
=
"company"
,
value
=
"公司名"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
@DynamicParameter
(
name
=
"company"
,
value
=
"公司名"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
}))
}))
public
BaseResult
addUser
(
@RequestBody
JSONObject
jsonObject
)
{
public
BaseResult
addUser
(
@RequestBody
JSONObject
jsonObject
)
{
String
userName
=
(
String
)
jsonObject
.
get
(
"userName"
);
String
userName
=
(
String
)
jsonObject
.
get
(
"userName"
);
...
@@ -64,6 +66,7 @@ public class UserController {
...
@@ -64,6 +66,7 @@ public class UserController {
/**
/**
* 删除user
* 删除user
*
* @param userId
* @param userId
* @return
* @return
*/
*/
...
@@ -81,15 +84,16 @@ public class UserController {
...
@@ -81,15 +84,16 @@ public class UserController {
/**
/**
* 修改user
* 修改user
*
* @param jsonObject
* @param jsonObject
* @return
* @return
*/
*/
@ApiOperation
(
value
=
"用户修改接口"
,
notes
=
"修改用户"
)
@ApiOperation
(
value
=
"用户修改接口"
,
notes
=
"修改用户"
)
@PostMapping
(
"update"
)
@PostMapping
(
"update"
)
@MyLog
(
title
=
"修改用户"
,
optParam
=
"#{userId},#{password}"
,
businessType
=
BusinessType
.
UPDATE
)
@MyLog
(
title
=
"修改用户"
,
optParam
=
"#{userId},#{password}"
,
businessType
=
BusinessType
.
UPDATE
)
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@ApiOperationSupport
(
params
=
@DynamicParameters
(
name
=
"jsonObject"
,
properties
=
{
@DynamicParameter
(
name
=
"userId"
,
value
=
"用户Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
@DynamicParameter
(
name
=
"userId"
,
value
=
"用户Id"
,
required
=
true
,
dataTypeClass
=
Integer
.
class
),
@DynamicParameter
(
name
=
"password"
,
value
=
"密码"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
@DynamicParameter
(
name
=
"password"
,
value
=
"密码"
,
required
=
true
,
dataTypeClass
=
String
.
class
)
}))
}))
public
BaseResult
updateUser
(
@RequestBody
JSONObject
jsonObject
)
{
public
BaseResult
updateUser
(
@RequestBody
JSONObject
jsonObject
)
{
int
userId
=
jsonObject
.
getInteger
(
"userId"
);
int
userId
=
jsonObject
.
getInteger
(
"userId"
);
...
@@ -105,6 +109,7 @@ public class UserController {
...
@@ -105,6 +109,7 @@ public class UserController {
/**
/**
* 分页查询所有的user
* 分页查询所有的user
*
* @param pageNo
* @param pageNo
* @param pageSize
* @param pageSize
* @return
* @return
...
@@ -113,24 +118,30 @@ public class UserController {
...
@@ -113,24 +118,30 @@ public class UserController {
@GetMapping
(
"list"
)
@GetMapping
(
"list"
)
@MyLog
(
title
=
"获取用户列表"
,
optParam
=
"#{pageNo},#{pageSize},#{userName},#{company}"
,
businessType
=
BusinessType
.
SELECT
)
@MyLog
(
title
=
"获取用户列表"
,
optParam
=
"#{pageNo},#{pageSize},#{userName},#{company}"
,
businessType
=
BusinessType
.
SELECT
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前在第几页"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"每页显示多少条"
,
required
=
true
,
dataType
=
"int"
),
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
),
@ApiImplicitParam
(
name
=
"userName"
,
value
=
"用户名"
),
@ApiImplicitParam
(
name
=
"company"
,
value
=
"公司名"
)
@ApiImplicitParam
(
name
=
"company"
,
value
=
"公司名"
)
})
})
public
PageResult
<
UserVo
>
getUserList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
public
PageResult
<
UserVo
>
getUserList
(
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"0"
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"0"
)
int
pageSize
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
,
@RequestParam
(
value
=
"company"
,
required
=
false
)
String
company
)
{
@RequestParam
(
value
=
"company"
,
required
=
false
)
String
company
)
{
PageInfoModel
<
UserVo
>
records
=
userService
.
getUserList
(
pageNo
,
pageSize
,
userName
,
company
);
PageInfoModel
<
UserVo
>
records
=
userService
.
getUserList
(
pageNo
,
pageSize
,
userName
,
company
);
int
total
=
records
.
getTotal
();
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
)
{
if
(
mod
!=
0
)
{
pages
=
pages
+
1
;
pages
=
pages
+
1
;
}
}
List
<
UserVo
>
result
=
records
.
getResult
();
List
<
UserVo
>
result
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
}
@ApiOperation
(
value
=
"修改通知人接口"
,
notes
=
"修改通知人邮箱"
)
@PostMapping
(
"update_notify"
)
public
BaseResult
updateNotify
(
@RequestBody
UpdateNotifyDTO
updateNotifyDTO
)
{
return
userService
.
updateNotify
(
updateNotifyDTO
);
}
}
}
}
license/src/main/java/iot/sixiang/license/model/dto/UpdateNotifyDTO.java
0 → 100644
View file @
25e5d8db
package
iot
.
sixiang
.
license
.
model
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* Created by m33
* Date 2023/1/30 14:18
* Description
*/
@Data
public
class
UpdateNotifyDTO
{
@ApiModelProperty
(
"通知人邮箱"
)
private
String
notify
;
}
license/src/main/java/iot/sixiang/license/service/UserService.java
View file @
25e5d8db
package
iot
.
sixiang
.
license
.
service
;
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.model.vo.UserVo
;
/**
/**
...
@@ -20,4 +22,6 @@ public interface UserService{
...
@@ -20,4 +22,6 @@ public interface UserService{
boolean
updateUser
(
int
userId
,
String
password
);
boolean
updateUser
(
int
userId
,
String
password
);
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
);
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
);
BaseResult
updateNotify
(
UpdateNotifyDTO
updateNotifyDTO
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
25e5d8db
...
@@ -2,12 +2,16 @@ package iot.sixiang.license.service.impl;
...
@@ -2,12 +2,16 @@ package iot.sixiang.license.service.impl;
import
cn.hutool.core.lang.Validator
;
import
cn.hutool.core.lang.Validator
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.CommonUtil
;
...
@@ -17,12 +21,13 @@ import org.springframework.stereotype.Service;
...
@@ -17,12 +21,13 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
* <p>
* <p>
*
服务实现类
* 服务实现类
* </p>
* </p>
*
*
* @author m33
* @author m33
...
@@ -35,11 +40,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -35,11 +40,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
UserMapper
userMapper
;
UserMapper
userMapper
;
@Override
@Override
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
)
{
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
}
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
);
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
List
<
UserVo
>
result
=
new
ArrayList
<>();
List
<
UserVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
...
@@ -52,10 +57,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -52,10 +57,34 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
return
objectPageInfoModel
;
return
objectPageInfoModel
;
}
}
@Override
public
BaseResult
updateNotify
(
UpdateNotifyDTO
updateNotifyDTO
)
{
String
notify
=
updateNotifyDTO
.
getNotify
();
String
loginUserId
=
UserUtils
.
getLoginUserId
();
if
(
StringUtils
.
isEmpty
(
notify
)
||
!
Validator
.
isEmail
(
notify
))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
if
(
StringUtils
.
isEmpty
(
loginUserId
))
{
throw
new
IotLicenseException
(
ResultCode
.
UNAUTHORIZED
.
getCode
(),
ResultCode
.
UNAUTHORIZED
.
getMsg
());
}
int
userId
=
Integer
.
parseInt
(
loginUserId
);
User
user
=
new
User
();
user
.
setNotify
(
notify
);
user
.
setUpdateTime
(
new
Date
());
LambdaQueryWrapper
<
User
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
User:
:
getUserId
,
userId
);
int
res
=
userMapper
.
update
(
user
,
wrapper
);
if
(
res
>
0
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
failed
();
}
}
@Override
@Override
public
boolean
deleteUser
(
int
userId
)
{
public
boolean
deleteUser
(
int
userId
)
{
if
(
userId
==
0
)
{
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
}
return
userMapper
.
deleteUser
(
userId
);
return
userMapper
.
deleteUser
(
userId
);
}
}
...
@@ -73,14 +102,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -73,14 +102,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
if
(
res
!=
null
)
{
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
throw
new
IotLicenseException
(
403
,
"用户名已存在"
);
}
}
return
userMapper
.
addUser
(
userName
,
company
,
password
,
notify
);
return
userMapper
.
addUser
(
userName
,
company
,
password
,
notify
);
}
}
@Override
@Override
public
boolean
updateUser
(
int
userId
,
String
password
)
{
public
boolean
updateUser
(
int
userId
,
String
password
)
{
if
(
userId
==
0
||
StringUtils
.
isEmpty
(
password
))
{
if
(
userId
==
0
||
StringUtils
.
isEmpty
(
password
))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
}
return
userMapper
.
updateUser
(
userId
,
password
);
return
userMapper
.
updateUser
(
userId
,
password
);
}
}
}
}
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