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