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
fb77b8d5
Commit
fb77b8d5
authored
Feb 03, 2023
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
33be21d2
da1218bc
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
59 additions
and
11 deletions
+59
-11
UserController.java
...n/java/iot/sixiang/license/controller/UserController.java
+20
-8
ApplyMapper.java
...src/main/java/iot/sixiang/license/mapper/ApplyMapper.java
+2
-0
DeviceMapper.java
...rc/main/java/iot/sixiang/license/mapper/DeviceMapper.java
+2
-0
ApplyService.java
...c/main/java/iot/sixiang/license/service/ApplyService.java
+2
-0
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+2
-0
ApplyServiceImpl.java
...va/iot/sixiang/license/service/impl/ApplyServiceImpl.java
+5
-0
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+14
-1
UserServiceImpl.java
...ava/iot/sixiang/license/service/impl/UserServiceImpl.java
+1
-1
ApplyMapper.xml
license/src/main/resources/mapper/ApplyMapper.xml
+6
-0
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+4
-0
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+1
-1
No files found.
license/src/main/java/iot/sixiang/license/controller/UserController.java
View file @
fb77b8d5
...
@@ -12,15 +12,15 @@ import io.swagger.annotations.Api;
...
@@ -12,15 +12,15 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
iot.sixiang.license.auth.AuthManager
;
import
iot.sixiang.license.device.DeviceManager
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.Permission
;
import
iot.sixiang.license.entity.Report
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.User
;
import
iot.sixiang.license.entity.UserPermission
;
import
iot.sixiang.license.entity.UserPermission
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.jwt.UserUtils
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.BusinessType
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.log.MyLog
;
import
iot.sixiang.license.mapper.UserMapper
;
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
;
...
@@ -28,10 +28,7 @@ import iot.sixiang.license.model.ResResult;
...
@@ -28,10 +28,7 @@ import iot.sixiang.license.model.ResResult;
import
iot.sixiang.license.model.dto.AssignUserPermissionDTO
;
import
iot.sixiang.license.model.dto.AssignUserPermissionDTO
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.dto.UpdateNotifyDTO
;
import
iot.sixiang.license.model.vo.*
;
import
iot.sixiang.license.model.vo.*
;
import
iot.sixiang.license.service.PermissionService
;
import
iot.sixiang.license.service.*
;
import
iot.sixiang.license.service.ReportService
;
import
iot.sixiang.license.service.UserPermissionService
;
import
iot.sixiang.license.service.UserService
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.CommonUtil
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.EmailUtils
;
import
iot.sixiang.license.util.TreeUtil
;
import
iot.sixiang.license.util.TreeUtil
;
...
@@ -45,7 +42,6 @@ import org.springframework.web.bind.annotation.*;
...
@@ -45,7 +42,6 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -63,12 +59,20 @@ public class UserController {
...
@@ -63,12 +59,20 @@ public class UserController {
@Resource
@Resource
EmailUtils
emailUtils
;
EmailUtils
emailUtils
;
@
Autowired
@
Resource
private
UserService
userService
;
private
UserService
userService
;
@Resource
@Resource
private
PermissionService
permissionService
;
private
PermissionService
permissionService
;
@Resource
@Resource
private
UserPermissionService
userPermissionService
;
private
UserPermissionService
userPermissionService
;
@Resource
private
ApplyService
applyService
;
@Resource
private
DeviceService
deviceService
;
@Resource
private
DeviceManager
deviceManager
;
@Resource
private
AuthManager
authManager
;
@Value
(
"${rsa.private_key}"
)
@Value
(
"${rsa.private_key}"
)
private
String
PRIVATE_KRY
;
private
String
PRIVATE_KRY
;
...
@@ -147,8 +151,16 @@ public class UserController {
...
@@ -147,8 +151,16 @@ public class UserController {
if
(!
CommonUtil
.
checkPermission
(
userPermissions
,
2
))
{
if
(!
CommonUtil
.
checkPermission
(
userPermissions
,
2
))
{
throw
new
IotLicenseException
(
403
,
"您无删除用户权限!"
);
throw
new
IotLicenseException
(
403
,
"您无删除用户权限!"
);
}
}
List
<
UserChildIdVO
>
childUser
=
userService
.
getChildUser
(
Integer
.
parseInt
(
userId
));
if
(!
childUser
.
isEmpty
())
{
throw
new
IotLicenseException
(
403
,
"该账户存在子账号,请先删除所有子账号!"
);
}
deviceService
.
deleteByUserId
(
Integer
.
parseInt
(
userId
));
applyService
.
deleteByUserId
(
Integer
.
parseInt
(
userId
));
boolean
res
=
userService
.
deleteUser
(
Integer
.
parseInt
(
userId
));
boolean
res
=
userService
.
deleteUser
(
Integer
.
parseInt
(
userId
));
userPermissionService
.
deleteUserPermission
(
Integer
.
parseInt
(
userId
));
userPermissionService
.
deleteUserPermission
(
Integer
.
parseInt
(
userId
));
deviceManager
.
initDevices
();
authManager
.
initApps
();
UserUtils
.
removeToken
(
userId
);
UserUtils
.
removeToken
(
userId
);
UserUtils
.
removeTokenExp
(
userId
);
UserUtils
.
removeTokenExp
(
userId
);
if
(
res
)
{
if
(
res
)
{
...
...
license/src/main/java/iot/sixiang/license/mapper/ApplyMapper.java
View file @
fb77b8d5
...
@@ -21,4 +21,6 @@ public interface ApplyMapper extends BaseMapper<Apply> {
...
@@ -21,4 +21,6 @@ public interface ApplyMapper extends BaseMapper<Apply> {
List
<
AppVo
>
getAppList
(
String
appName
,
List
<
Integer
>
userChildIds
);
List
<
AppVo
>
getAppList
(
String
appName
,
List
<
Integer
>
userChildIds
);
Apply
getApplyByAppName
(
String
appName
);
Apply
getApplyByAppName
(
String
appName
);
void
deleteByUserId
(
Integer
userId
);
}
}
license/src/main/java/iot/sixiang/license/mapper/DeviceMapper.java
View file @
fb77b8d5
...
@@ -18,4 +18,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
...
@@ -18,4 +18,6 @@ public interface DeviceMapper extends BaseMapper<Device> {
boolean
addDevice
(
String
sn
,
String
appId
);
boolean
addDevice
(
String
sn
,
String
appId
);
int
updateDeviceById
(
Device
device
);
int
updateDeviceById
(
Device
device
);
void
deleteByUserId
(
int
userId
);
}
}
license/src/main/java/iot/sixiang/license/service/ApplyService.java
View file @
fb77b8d5
...
@@ -20,4 +20,6 @@ public interface ApplyService extends IService<Apply> {
...
@@ -20,4 +20,6 @@ public interface ApplyService extends IService<Apply> {
boolean
addApply
(
String
appName
,
String
appKey
,
int
userId
);
boolean
addApply
(
String
appName
,
String
appKey
,
int
userId
);
PageInfoModel
<
AppVo
>
getAppList
(
int
pageNo
,
int
pageSize
,
String
appName
,
List
<
Integer
>
userChildIds
);
PageInfoModel
<
AppVo
>
getAppList
(
int
pageNo
,
int
pageSize
,
String
appName
,
List
<
Integer
>
userChildIds
);
void
deleteByUserId
(
Integer
userId
);
}
}
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
fb77b8d5
...
@@ -30,4 +30,6 @@ public interface DeviceService extends IService<Device> {
...
@@ -30,4 +30,6 @@ public interface DeviceService extends IService<Device> {
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
ResResult
getBindStatus
(
TerminalDevieUnBindDTO
terminalDevieUnBindDTO
);
BaseResult
platFormBind
(
PlatFormBindDTO
platFormBindDTO
);
BaseResult
platFormBind
(
PlatFormBindDTO
platFormBindDTO
);
void
deleteByUserId
(
int
userId
);
}
}
license/src/main/java/iot/sixiang/license/service/impl/ApplyServiceImpl.java
View file @
fb77b8d5
...
@@ -71,4 +71,9 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
...
@@ -71,4 +71,9 @@ public class ApplyServiceImpl extends ServiceImpl<ApplyMapper, Apply> implements
objectPageInfoModel
.
setResult
(
result
);
objectPageInfoModel
.
setResult
(
result
);
return
objectPageInfoModel
;
return
objectPageInfoModel
;
}
}
@Override
public
void
deleteByUserId
(
Integer
userId
)
{
applyMapper
.
deleteByUserId
(
userId
);
}
}
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
fb77b8d5
...
@@ -156,7 +156,15 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
...
@@ -156,7 +156,15 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
if
(
deviceId
.
equals
(
device
.
getDeviceId
()))
{
if
(
deviceId
.
equals
(
device
.
getDeviceId
()))
{
return
BaseResult
.
success
();
return
BaseResult
.
success
();
}
else
{
}
else
{
return
BaseResult
.
failed
().
setMsgValue
(
"设备sn已被绑定"
);
return
BaseResult
.
failed
().
setMsgValue
(
"设备编码已被绑定"
);
}
}
LambdaQueryWrapper
<
Device
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
lambdaQueryWrapper
.
eq
(
Device:
:
getSn
,
sn
).
last
(
"limit 1"
);
Device
device1
=
deviceMapper
.
selectOne
(
lambdaQueryWrapper
);
if
(
device1
!=
null
)
{
if
(!
deviceId
.
equals
(
device1
.
getDeviceId
()))
{
return
BaseResult
.
failed
().
setMsgValue
(
"SN已存在"
);
}
}
}
}
LambdaQueryWrapper
<
Device
>
wrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
Device
>
wrapper
=
new
LambdaQueryWrapper
<>();
...
@@ -180,4 +188,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
...
@@ -180,4 +188,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
return
BaseResult
.
failed
();
return
BaseResult
.
failed
();
}
}
}
}
@Override
public
void
deleteByUserId
(
int
userId
)
{
deviceMapper
.
deleteByUserId
(
userId
);
}
}
}
license/src/main/java/iot/sixiang/license/service/impl/UserServiceImpl.java
View file @
fb77b8d5
...
@@ -45,7 +45,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
...
@@ -45,7 +45,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
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
,
userIds
);
List
<
UserVo
>
records
=
userMapper
.
getUserList
(
userName
,
company
,
userIds
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
collect
(
Collectors
.
toList
());
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
UserVo:
:
getCreateTime
,
Comparator
.
reverseOrder
())).
sorted
(
Comparator
.
comparing
(
UserVo:
:
getLevel
)).
collect
(
Collectors
.
toList
());
List
<
UserVo
>
result
=
new
ArrayList
<>();
List
<
UserVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
records
.
size
()
>
0
)
{
if
(
begin
>=
0
&&
records
.
size
()
>
0
)
{
...
...
license/src/main/resources/mapper/ApplyMapper.xml
View file @
fb77b8d5
...
@@ -6,9 +6,15 @@
...
@@ -6,9 +6,15 @@
app.app_id, app.app_name, app.app_key, app.create_time, app.update_time, us.user_id,
app.app_id, app.app_name, app.app_key, app.create_time, app.update_time, us.user_id,
COUNT(sn) AS deviceCount, us.user_name, us.company
COUNT(sn) AS deviceCount, us.user_name, us.company
</sql>
</sql>
<insert
id=
"addApply"
parameterType=
"iot.sixiang.license.entity.Apply"
>
<insert
id=
"addApply"
parameterType=
"iot.sixiang.license.entity.Apply"
>
insert into apply(app_id,app_name, app_key, user_id, create_time, update_time) values (#{appId}, #{appName}, #{appKey}, #{userId}, now(), now())
insert into apply(app_id,app_name, app_key, user_id, create_time, update_time) values (#{appId}, #{appName}, #{appKey}, #{userId}, now(), now())
</insert>
</insert>
<delete
id=
"deleteByUserId"
>
delete from `apply` where user_id = #{userId}
</delete>
<select
id=
"getAppList"
resultType=
"iot.sixiang.license.model.vo.AppVo"
>
<select
id=
"getAppList"
resultType=
"iot.sixiang.license.model.vo.AppVo"
>
SELECT
<include
refid=
"AppVoColumn"
/>
SELECT
<include
refid=
"AppVoColumn"
/>
FROM apply AS app LEFT JOIN device AS de ON app.app_id = de.app_id
FROM apply AS app LEFT JOIN device AS de ON app.app_id = de.app_id
...
...
license/src/main/resources/mapper/DeviceMapper.xml
View file @
fb77b8d5
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"iot.sixiang.license.mapper.DeviceMapper"
>
<mapper
namespace=
"iot.sixiang.license.mapper.DeviceMapper"
>
<delete
id=
"deleteByUserId"
>
delete device from device,apply,`user` WHERE device.app_id = apply.app_id
and user.user_id = apply.user_id and user.user_id = #{userId}
</delete>
<select
id=
"getDeviceList"
resultType=
"iot.sixiang.license.model.vo.DeviceVo"
>
<select
id=
"getDeviceList"
resultType=
"iot.sixiang.license.model.vo.DeviceVo"
>
SELECT de.device_id, de.app_id, app_name,user_name,sn,sn_bind,de.status,de.create_time,de.update_time,de.device_id IN (select
SELECT de.device_id, de.app_id, app_name,user_name,sn,sn_bind,de.status,de.create_time,de.update_time,de.device_id IN (select
...
...
license/src/main/resources/mapper/UserMapper.xml
View file @
fb77b8d5
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
</update>
</update>
<select
id=
"getUserList"
resultType=
"iot.sixiang.license.model.vo.UserVo"
>
<select
id=
"getUserList"
resultType=
"iot.sixiang.license.model.vo.UserVo"
>
SELECT user.user_id, user_name, password, company, user.create_time, user.update_time,
SELECT user.user_id, user_name, password, company, user.
level, user.
create_time, user.update_time,
COUNT(device.`device_id`) totalDevice,
COUNT(device.`device_id`) totalDevice,
COUNT(if(device.device_id is NOT NULL, if (device.`status` = 0 or device.`status` is NULL, 1, NULL), NULL))
COUNT(if(device.device_id is NOT NULL, if (device.`status` = 0 or device.`status` is NULL, 1, NULL), NULL))
unUseDevice,
unUseDevice,
...
...
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