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
e777f499
Commit
e777f499
authored
Jun 15, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'm33' into 'master'
完善状态码 See merge request
!29
parents
c3a5aa34
3d0dfa88
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
188 additions
and
118 deletions
+188
-118
ResultCode.java
.../src/main/java/iot/sixiang/license/consts/ResultCode.java
+27
-0
ApplyController.java
.../java/iot/sixiang/license/controller/ApplyController.java
+1
-1
DeviceController.java
...java/iot/sixiang/license/controller/DeviceController.java
+1
-1
LoginController.java
.../java/iot/sixiang/license/controller/LoginController.java
+3
-3
OperateController.java
...ava/iot/sixiang/license/controller/OperateController.java
+4
-4
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+3
-3
GlobalExceptionHandler.java
...a/iot/sixiang/license/handler/GlobalExceptionHandler.java
+2
-2
IotLicenseException.java
...java/iot/sixiang/license/handler/IotLicenseException.java
+1
-1
BaseResult.java
...e/src/main/java/iot/sixiang/license/model/BaseResult.java
+49
-15
PageResult.java
...e/src/main/java/iot/sixiang/license/model/PageResult.java
+1
-0
ResResult.java
...se/src/main/java/iot/sixiang/license/model/ResResult.java
+50
-11
AlarmReadServiceImpl.java
...ot/sixiang/license/service/impl/AlarmReadServiceImpl.java
+2
-1
AlarmServiceImpl.java
...va/iot/sixiang/license/service/impl/AlarmServiceImpl.java
+2
-1
ApplyServiceImpl.java
...va/iot/sixiang/license/service/impl/ApplyServiceImpl.java
+7
-15
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+5
-10
ResourceServiceImpl.java
...iot/sixiang/license/service/impl/ResourceServiceImpl.java
+3
-2
ServerServiceImpl.java
...a/iot/sixiang/license/service/impl/ServerServiceImpl.java
+14
-13
SysOperLogServiceImpl.java
...t/sixiang/license/service/impl/SysOperLogServiceImpl.java
+3
-5
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+10
-16
JsonUtil.java
license/src/main/java/iot/sixiang/license/util/JsonUtil.java
+0
-14
No files found.
license/src/main/java/iot/sixiang/license/consts/ResultCode.java
0 → 100644
View file @
e777f499
package
iot
.
sixiang
.
license
.
consts
;
/**
* Created by m33 on 2022/6/15 9:43
*/
public
enum
ResultCode
{
SUCCESS
(
200
,
"操作成功"
),
SERVER_EXCEPTION
(
400
,
"服务异常"
),
UNAUTHORIZED
(
401
,
"暂未登录或token已经过期"
),
VALIDATE_FAILED
(
402
,
"参数检验失败"
),
FAILED
(
403
,
"操作失败"
);
private
long
code
;
private
String
msg
;
private
ResultCode
(
long
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
long
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
}
license/src/main/java/iot/sixiang/license/controller/ApplyController.java
View file @
e777f499
...
...
@@ -58,7 +58,7 @@ public class ApplyController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
license/src/main/java/iot/sixiang/license/controller/DeviceController.java
View file @
e777f499
...
...
@@ -57,7 +57,7 @@ public class DeviceController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
license/src/main/java/iot/sixiang/license/controller/LoginController.java
View file @
e777f499
...
...
@@ -60,7 +60,7 @@ public class LoginController {
return
ResResult
.
success
().
record
(
loginVo
);
}
}
return
ResResult
.
fail
().
msg
(
"用户名或密码错误"
);
return
ResResult
.
fail
ed
().
msg
(
"用户名或密码错误"
);
}
@ApiOperation
(
value
=
"注销接口"
,
notes
=
"注销接口"
)
...
...
@@ -72,7 +72,7 @@ public class LoginController {
@GetMapping
(
"fail"
)
@ApiIgnore
public
Res
Result
fail
(
HttpServletRequest
request
)
{
return
ResResult
.
fail
().
msg
(
request
.
getAttribute
(
"msg"
).
toString
()
);
public
Base
Result
fail
(
HttpServletRequest
request
)
{
return
BaseResult
.
unauthorized
(
);
}
}
license/src/main/java/iot/sixiang/license/controller/OperateController.java
View file @
e777f499
...
...
@@ -107,7 +107,7 @@ public class OperateController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
@@ -148,7 +148,7 @@ public class OperateController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
@@ -165,7 +165,7 @@ public class OperateController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
@@ -188,7 +188,7 @@ public class OperateController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
e777f499
...
...
@@ -58,7 +58,7 @@ public class UserController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
@@ -75,7 +75,7 @@ public class UserController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
@@ -98,7 +98,7 @@ public class UserController {
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
return
BaseResult
.
fail
ed
();
}
}
...
...
license/src/main/java/iot/sixiang/license/handler/GlobalExceptionHandler.java
View file @
e777f499
...
...
@@ -16,7 +16,7 @@ public class GlobalExceptionHandler {
@ResponseBody
//为了返回数据
public
BaseResult
error
(
Exception
e
){
e
.
printStackTrace
();
return
BaseResult
.
fail
().
msg
(
"执行了全局的异常类..."
);
return
BaseResult
.
serverException
(
);
}
//自定义异常
...
...
@@ -24,6 +24,6 @@ public class GlobalExceptionHandler {
@ResponseBody
//为了返回数据
public
BaseResult
error
(
IotLicenseException
e
){
e
.
printStackTrace
();
return
BaseResult
.
fail
().
msg
(
e
.
getMsg
()).
code
(
e
.
getCode
());
return
BaseResult
.
fail
ed
().
msg
(
e
.
getMsg
()).
code
(
e
.
getCode
());
}
}
license/src/main/java/iot/sixiang/license/handler/IotLicenseException.java
View file @
e777f499
...
...
@@ -12,7 +12,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
//生成无参构造
public
class
IotLicenseException
extends
RuntimeException
{
private
Integer
code
;
private
long
code
;
private
String
msg
;
//异常信息
}
license/src/main/java/iot/sixiang/license/model/BaseResult.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
model
;
import
iot.sixiang.license.consts.ResultCode
;
//@Data
public
class
BaseResult
{
private
int
code
;
private
long
code
;
private
String
msg
;
public
BaseResult
(
int
code
,
String
reason
)
{
public
BaseResult
(
long
code
,
String
msg
)
{
super
();
this
.
code
=
code
;
this
.
msg
=
reason
;
this
.
msg
=
msg
;
}
public
BaseResult
()
{
...
...
@@ -16,21 +18,53 @@ public class BaseResult {
// TODO Auto-generated constructor stub
}
/**
* code = 200
* msg = 操作成功
* @return
*/
public
static
BaseResult
success
()
{
BaseResult
respResult
=
new
BaseResult
();
respResult
.
setCode
(
200
);
respResult
.
setMsg
(
"success"
);
return
respResult
;
return
new
BaseResult
(
ResultCode
.
SUCCESS
.
getCode
(),
ResultCode
.
SUCCESS
.
getMsg
());
}
public
static
BaseResult
fail
()
{
BaseResult
respResult
=
new
BaseResult
();
respResult
.
setCode
(
400
);
respResult
.
setMsg
(
"fail"
);
return
respResult
;
/**
* code = 400
* msg = 服务异常
* @return
*/
public
static
BaseResult
serverException
()
{
return
new
BaseResult
(
ResultCode
.
SERVER_EXCEPTION
.
getCode
(),
ResultCode
.
SERVER_EXCEPTION
.
getMsg
());
}
/**
* code = 401
* msg = 暂未登录或token已经过期
* @return
*/
public
static
BaseResult
unauthorized
()
{
return
new
BaseResult
(
ResultCode
.
UNAUTHORIZED
.
getCode
(),
ResultCode
.
UNAUTHORIZED
.
getMsg
());
}
/**
* code = 402
* msg = 参数校验失败
* @return
*/
public
static
BaseResult
validate_failed
()
{
return
new
BaseResult
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
/**
* code = 403
* msg = 操作失败(数据库增删改查等失败)
* @return
*/
public
static
BaseResult
failed
()
{
return
new
BaseResult
(
ResultCode
.
SUCCESS
.
getCode
(),
ResultCode
.
SUCCESS
.
getMsg
());
}
public
BaseResult
code
(
int
code
)
{
public
BaseResult
code
(
long
code
)
{
this
.
code
=
code
;
return
this
;
}
...
...
@@ -41,11 +75,11 @@ public class BaseResult {
return
this
;
}
public
int
getCode
()
{
public
long
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
public
void
setCode
(
long
code
)
{
this
.
code
=
code
;
}
...
...
license/src/main/java/iot/sixiang/license/model/PageResult.java
View file @
e777f499
...
...
@@ -24,6 +24,7 @@ public class PageResult<T> {
this
.
record
=
record
;
}
public
PageResult
()
{
super
();
// TODO Auto-generated constructor stub
...
...
license/src/main/java/iot/sixiang/license/model/ResResult.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
model
;
import
iot.sixiang.license.consts.ResultCode
;
import
lombok.Data
;
/**
...
...
@@ -12,25 +13,63 @@ import lombok.Data;
*/
@Data
public
class
ResResult
<
T
>
{
private
int
code
;
private
long
code
;
private
String
msg
;
private
T
record
;
public
ResResult
(
long
code
,
String
msg
)
{
super
();
this
.
code
=
code
;
this
.
msg
=
msg
;
}
/**
* code = 200
* msg = 操作成功
* @return
*/
public
static
ResResult
success
()
{
ResResult
respResult
=
new
ResResult
();
respResult
.
setCode
(
200
);
respResult
.
setMsg
(
"success"
);
return
respResult
;
return
new
ResResult
(
ResultCode
.
SUCCESS
.
getCode
(),
ResultCode
.
SUCCESS
.
getMsg
());
}
/**
* code = 400
* msg = 服务异常
* @return
*/
public
static
ResResult
serverException
()
{
return
new
ResResult
(
ResultCode
.
SERVER_EXCEPTION
.
getCode
(),
ResultCode
.
SERVER_EXCEPTION
.
getMsg
());
}
public
static
ResResult
fail
()
{
ResResult
respResult
=
new
ResResult
();
respResult
.
setCode
(
400
);
respResult
.
setMsg
(
"fail"
);
return
respResult
;
/**
* code = 401
* msg = 暂未登录或token已经过期
* @return
*/
public
static
ResResult
unauthorized
()
{
return
new
ResResult
(
ResultCode
.
UNAUTHORIZED
.
getCode
(),
ResultCode
.
UNAUTHORIZED
.
getMsg
());
}
/**
* code = 402
* msg = 参数校验失败
* @return
*/
public
static
ResResult
validate_failed
()
{
return
new
ResResult
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
/**
* code = 403
* msg = 操作失败(数据库增删改查等失败)
* @return
*/
public
static
ResResult
failed
()
{
return
new
ResResult
(
ResultCode
.
SUCCESS
.
getCode
(),
ResultCode
.
SUCCESS
.
getMsg
());
}
public
ResResult
code
(
int
code
)
{
public
ResResult
code
(
long
code
)
{
this
.
code
=
code
;
return
this
;
}
...
...
license/src/main/java/iot/sixiang/license/service/impl/AlarmReadServiceImpl.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.AlarmRead
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.AlarmMapper
;
...
...
@@ -31,7 +32,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
@Override
public
boolean
readAlarm
(
int
userId
)
{
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
400
,
"用户Id不能为空"
);
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
()
);
}
List
<
AlarmVo
>
alarmList
=
alarmMapper
.
getAlarmList
(
userId
);
for
(
AlarmVo
alarm:
alarmList
)
{
...
...
license/src/main/java/iot/sixiang/license/service/impl/AlarmServiceImpl.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.Alarm
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.AlarmMapper
;
...
...
@@ -24,7 +25,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements
@Override
public
List
<
AlarmVo
>
getAlarmList
(
int
userId
)
{
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
400
,
"用户Id不能为空"
);
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
()
);
}
return
alarmMapper
.
getAlarmList
(
userId
);
}
...
...
license/src/main/java/iot/sixiang/license/service/impl/ApplyServiceImpl.java
View file @
e777f499
...
...
@@ -2,6 +2,7 @@ package iot.sixiang.license.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.auth.AuthManager
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.Apply
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.ApplyMapper
;
...
...
@@ -33,18 +34,13 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
ApplyMapper
applyMapper
;
@Override
public
boolean
addApply
(
String
appName
,
String
appKey
,
int
userId
)
{
if
(
StringUtils
.
isEmpty
(
appName
))
{
throw
new
IotLicenseException
(
400
,
"应用名不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
appKey
))
{
throw
new
IotLicenseException
(
400
,
"应用key不能为空"
);
}
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
400
,
"用户Id不能为空"
);
if
(
StringUtils
.
isEmpty
(
appName
)
||
StringUtils
.
isEmpty
(
appKey
)
||
userId
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
Apply
res
=
applyMapper
.
getApplyByAppName
(
appName
);
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
400
,
"应用名已存在"
);
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
}
boolean
re
=
applyMapper
.
addApply
(
appName
,
appKey
,
userId
);
if
(!
re
)
{
...
...
@@ -57,13 +53,9 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
@Override
public
PageInfoModel
<
AppVo
>
getAppList
(
int
pageNo
,
int
pageSize
,
String
appName
)
{
if
(
pageNo
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageNo不能为空"
);
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
()
);
}
if
(
pageSize
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageSize不能为空"
);
}
List
<
AppVo
>
records
=
applyMapper
.
getAppList
(
appName
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
AppVo:
:
getAppId
)).
collect
(
Collectors
.
toList
());
List
<
AppVo
>
result
=
new
ArrayList
<>();
...
...
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.device.DeviceManager
;
import
iot.sixiang.license.entity.Device
;
import
iot.sixiang.license.handler.IotLicenseException
;
...
...
@@ -34,11 +35,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
@Override
public
PageInfoModel
<
DeviceVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
appName
,
String
userName
)
{
if
(
pageNo
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageNo不能为空"
);
}
if
(
pageSize
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageSize不能为空"
);
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
DeviceVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
appName
,
userName
);
deviceTypes
=
deviceTypes
.
stream
().
sorted
(
Comparator
.
comparing
(
DeviceVo:
:
getDeviceId
)).
collect
(
Collectors
.
toList
());
...
...
@@ -55,11 +53,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
@Override
public
boolean
addDevice
(
int
appId
,
int
count
)
{
if
(
appId
==
0
)
{
throw
new
IotLicenseException
(
400
,
"应用Id不能为空"
);
}
if
(
count
==
0
)
{
throw
new
IotLicenseException
(
400
,
"count不能为零或空"
);
if
(
appId
==
0
||
count
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
String
sn
=
CommonUtil
.
genRandomNum
(
18
);
...
...
license/src/main/java/iot/sixiang/license/service/impl/ResourceServiceImpl.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.ResourceMapper
;
import
iot.sixiang.license.model.vo.ResourceVo
;
...
...
@@ -20,8 +21,8 @@ public class ResourceServiceImpl implements ResourceService {
@Override
public
List
<
ResourceVo
>
getResource
(
int
userId
)
{
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
400
,
"用户Id不能为空"
);
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
()
);
}
List
<
ResourceVo
>
record
=
resourceMapper
.
getResource
(
userId
);
return
record
;
...
...
license/src/main/java/iot/sixiang/license/service/impl/ServerServiceImpl.java
View file @
e777f499
...
...
@@ -2,11 +2,12 @@ package iot.sixiang.license.service.impl;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.Server
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.ServerMapper
;
import
iot.sixiang.license.service.ServerService
;
import
iot.sixiang.license.util.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
...
...
@@ -14,7 +15,7 @@ import java.util.List;
/**
* <p>
*
服务实现类
* 服务实现类
* </p>
*
* @author m33
...
...
@@ -28,33 +29,33 @@ public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> impleme
@Override
public
List
<
Server
>
getServerList
(
int
pageNo
,
int
pageSize
)
{
Page
<
Server
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
baseMapper
.
selectPage
(
page
,
null
);
Page
<
Server
>
page
=
new
Page
<>(
pageNo
,
pageSize
);
baseMapper
.
selectPage
(
page
,
null
);
List
<
Server
>
records
=
page
.
getRecords
();
return
records
;
}
@Override
public
boolean
deleteServer
(
String
serverIp
)
{
if
(
JsonUtil
.
isNull
(
serverIp
))
{
return
false
;
if
(
StringUtils
.
isEmpty
(
serverIp
))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
())
;
}
return
serverMapper
.
deleteServer
(
serverIp
);
}
@Override
public
boolean
addServer
(
String
serverIp
,
int
port
)
{
if
(
JsonUtil
.
isNull
(
serverIp
)
||
JsonUtil
.
isNull
(
String
.
valueOf
(
port
))
)
{
return
false
;
if
(
StringUtils
.
isEmpty
(
serverIp
)
||
port
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
())
;
}
return
serverMapper
.
addServer
(
serverIp
,
port
);
return
serverMapper
.
addServer
(
serverIp
,
port
);
}
@Override
public
boolean
updateServer
(
String
serverIp
,
int
port
)
{
if
(
JsonUtil
.
isNull
(
serverIp
)
||
JsonUtil
.
isNull
(
String
.
valueOf
(
port
))
)
{
return
false
;
if
(
StringUtils
.
isEmpty
(
serverIp
)
||
port
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
())
;
}
return
serverMapper
.
updateServer
(
serverIp
,
port
);
return
serverMapper
.
updateServer
(
serverIp
,
port
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/SysOperLogServiceImpl.java
View file @
e777f499
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.SysOperLog
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.SysOperLogMapper
;
...
...
@@ -37,11 +38,8 @@ public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOper
@Override
public
PageInfoModel
<
SysOperLog
>
getOperLogList
(
int
pageNo
,
int
pageSize
)
{
if
(
pageNo
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageNo不能为空"
);
}
if
(
pageSize
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageSize不能为空"
);
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
SysOperLog
>
records
=
sysOperLogMapper
.
getOperLogList
();
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
SysOperLog:
:
getId
)).
collect
(
Collectors
.
toList
());
...
...
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
e777f499
...
...
@@ -2,13 +2,13 @@ package iot.sixiang.license.service.impl;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.consts.ResultCode
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.UserMapper
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.UserVo
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.JsonUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -34,11 +34,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
public
PageInfoModel
<
UserVo
>
getUserList
(
int
pageNo
,
int
pageSize
,
String
userName
,
String
company
)
{
if
(
pageNo
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageNo不能为空"
);
}
if
(
pageSize
==
0
)
{
throw
new
IotLicenseException
(
400
,
"pageSize不能为空"
);
if
(
pageNo
==
0
||
pageSize
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getUserId
)).
collect
(
Collectors
.
toList
());
...
...
@@ -55,31 +52,28 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Override
public
boolean
deleteUser
(
int
userId
)
{
if
(
JsonUtil
.
isNull
(
String
.
valueOf
(
userId
))
)
{
return
false
;
if
(
userId
==
0
)
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
())
;
}
return
userMapper
.
deleteUser
(
userId
);
}
@Override
public
boolean
addUser
(
String
userName
,
String
company
,
String
password
)
{
if
(
StringUtils
.
isEmpty
(
userName
))
{
throw
new
IotLicenseException
(
400
,
"用户名不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
company
))
{
throw
new
IotLicenseException
(
400
,
"公司名不能为空"
);
if
(
StringUtils
.
isEmpty
(
userName
)
||
StringUtils
.
isEmpty
(
company
))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
());
}
User
res
=
userMapper
.
getUserByUserName
(
userName
);
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
400
,
"用户名已存在"
);
throw
new
IotLicenseException
(
ResultCode
.
FAILED
.
getCode
(),
ResultCode
.
FAILED
.
getMsg
()
);
}
return
userMapper
.
addUser
(
userName
,
company
,
password
);
}
@Override
public
boolean
updateUser
(
int
userId
,
String
password
)
{
if
(
JsonUtil
.
isNull
(
String
.
valueOf
(
userId
))
||
JsonUtil
.
isNull
(
password
))
{
return
false
;
if
(
userId
==
0
||
StringUtils
.
isEmpty
(
password
))
{
throw
new
IotLicenseException
(
ResultCode
.
VALIDATE_FAILED
.
getCode
(),
ResultCode
.
VALIDATE_FAILED
.
getMsg
())
;
}
return
userMapper
.
updateUser
(
userId
,
password
);
}
...
...
license/src/main/java/iot/sixiang/license/util/JsonUtil.java
deleted
100644 → 0
View file @
c3a5aa34
package
iot
.
sixiang
.
license
.
util
;
/**
* Created by m33 on 2022/6/8 9:57
*/
public
class
JsonUtil
{
public
static
boolean
isNull
(
String
str
)
{
if
(
str
==
null
||
str
.
isEmpty
())
{
return
true
;
}
return
false
;
}
}
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