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
67038584
Commit
67038584
authored
Jun 09, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'm33' into 'master'
完善apply等接口 See merge request
!10
parents
c91046a0
9c1fdb8b
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
307 additions
and
171 deletions
+307
-171
ApplyController.java
.../java/iot/sixiang/license/controller/ApplyController.java
+67
-0
DeviceController.java
...java/iot/sixiang/license/controller/DeviceController.java
+7
-8
DeviceTypeController.java
.../iot/sixiang/license/controller/DeviceTypeController.java
+0
-40
Apply.java
license/src/main/java/iot/sixiang/license/entity/Apply.java
+10
-4
Device.java
license/src/main/java/iot/sixiang/license/entity/Device.java
+1
-4
JwtFilter.java
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
+1
-2
JwtUtil.java
license/src/main/java/iot/sixiang/license/jwt/JwtUtil.java
+2
-2
ApplyMapper.java
...src/main/java/iot/sixiang/license/mapper/ApplyMapper.java
+24
-0
DeviceMapper.java
...rc/main/java/iot/sixiang/license/mapper/DeviceMapper.java
+3
-3
AppVo.java
...nse/src/main/java/iot/sixiang/license/model/vo/AppVo.java
+21
-0
DeviceVo.java
.../src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
+4
-5
UserVo.java
...se/src/main/java/iot/sixiang/license/model/vo/UserVo.java
+1
-1
ApplyService.java
...c/main/java/iot/sixiang/license/service/ApplyService.java
+21
-0
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+3
-3
DeviceTypeService.java
...n/java/iot/sixiang/license/service/DeviceTypeService.java
+0
-19
ApplyServiceImpl.java
...va/iot/sixiang/license/service/impl/ApplyServiceImpl.java
+55
-0
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+8
-8
DeviceTypeServiceImpl.java
...t/sixiang/license/service/impl/DeviceTypeServiceImpl.java
+0
-31
CodeGenerator.java
...src/main/java/iot/sixiang/license/util/CodeGenerator.java
+1
-6
JsonUtil.java
license/src/main/java/iot/sixiang/license/util/JsonUtil.java
+0
-1
application-dev.yml
license/src/main/resources/application-dev.yml
+14
-0
application-prod.yml
license/src/main/resources/application-prod.yml
+11
-0
application-test.yml
license/src/main/resources/application-test.yml
+11
-0
application.properties
license/src/main/resources/application.properties
+0
-8
application.yml
license/src/main/resources/application.yml
+5
-0
ApplyMapper.xml
license/src/main/resources/mapper/ApplyMapper.xml
+27
-0
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+8
-12
DeviceTypeMapper.xml
license/src/main/resources/mapper/DeviceTypeMapper.xml
+0
-12
UserMapper.xml
license/src/main/resources/mapper/UserMapper.xml
+2
-2
No files found.
license/src/main/java/iot/sixiang/license/controller/ApplyController.java
0 → 100644
View file @
67038584
package
iot
.
sixiang
.
license
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.vo.AppVo
;
import
iot.sixiang.license.service.ApplyService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-09
*/
@RestController
@RequestMapping
(
"/iot_license/apply"
)
public
class
ApplyController
{
@Autowired
private
ApplyService
applyService
;
/**
* 添加apply
* @param jsonObject
* @return
*/
@PostMapping
(
"add"
)
public
BaseResult
addUser
(
@RequestBody
JSONObject
jsonObject
)
{
String
appName
=
jsonObject
.
getString
(
"appName"
);
String
appKey
=
jsonObject
.
getString
(
"appKey"
);
int
userId
=
jsonObject
.
getInteger
(
"userId"
);
boolean
res
=
applyService
.
addApply
(
appName
,
appKey
,
userId
);
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
return
BaseResult
.
fail
();
}
}
/**
* 分页查询所有的apply
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping
(
"list"
)
public
PageResult
getUserList
(
@RequestParam
(
"pageNo"
)
int
pageNo
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
value
=
"appName"
,
required
=
false
)
String
appName
)
{
PageInfoModel
<
AppVo
>
records
=
applyService
.
getAppList
(
pageNo
,
pageSize
,
appName
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
){
pages
=
pages
+
1
;
}
List
<
AppVo
>
result
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
result
);
}
}
\ No newline at end of file
license/src/main/java/iot/sixiang/license/controller/DeviceController.java
View file @
67038584
...
...
@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
iot.sixiang.license.model.BaseResult
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.PageResult
;
import
iot.sixiang.license.model.vo.Device
Type
Vo
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.DeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -34,10 +34,9 @@ public class DeviceController {
*/
@PostMapping
(
"add"
)
public
BaseResult
addDevice
(
@RequestBody
JSONObject
jsonObject
)
{
int
userId
=
jsonObject
.
getInteger
(
"userId"
);
int
typeId
=
jsonObject
.
getInteger
(
"typeId"
);
int
appId
=
jsonObject
.
getInteger
(
"appId"
);
int
count
=
jsonObject
.
getInteger
(
"count"
);
boolean
res
=
deviceService
.
addDevice
(
userId
,
type
Id
,
count
);
boolean
res
=
deviceService
.
addDevice
(
app
Id
,
count
);
if
(
res
)
{
return
BaseResult
.
success
();
}
else
{
...
...
@@ -49,23 +48,23 @@ public class DeviceController {
* 可按条件分页查询所有的user
* @param pageNo
* @param pageSize
* @param
type
Name
* @param
app
Name
* @param userName
* @return
*/
@GetMapping
(
"list"
)
public
PageResult
getDeviceList
(
@RequestParam
(
"pageNo"
)
int
pageNo
,
@RequestParam
(
"pageSize"
)
int
pageSize
,
@RequestParam
(
value
=
"
typeName"
,
required
=
false
)
String
type
Name
,
@RequestParam
(
value
=
"
appName"
,
required
=
false
)
String
app
Name
,
@RequestParam
(
value
=
"userName"
,
required
=
false
)
String
userName
)
{
PageInfoModel
<
Device
TypeVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
type
Name
,
userName
);
PageInfoModel
<
Device
Vo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
app
Name
,
userName
);
int
total
=
records
.
getTotal
();
int
pages
=
total
/
pageSize
;
//pages为总页数
int
mod
=
total
%
pageSize
;
if
(
mod
!=
0
){
pages
=
pages
+
1
;
}
List
<
Device
Type
Vo
>
pageResult
=
records
.
getResult
();
List
<
DeviceVo
>
pageResult
=
records
.
getResult
();
return
new
PageResult
(
200
,
"查找成功"
,
pageNo
,
pages
,
total
,
pageResult
);
}
}
...
...
license/src/main/java/iot/sixiang/license/controller/DeviceTypeController.java
deleted
100644 → 0
View file @
c91046a0
package
iot
.
sixiang
.
license
.
controller
;
import
iot.sixiang.license.entity.DeviceType
;
import
iot.sixiang.license.model.ResResult
;
import
iot.sixiang.license.service.DeviceTypeService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-08
*/
@RestController
@RequestMapping
(
"/iot_license/device_type"
)
public
class
DeviceTypeController
{
@Autowired
private
DeviceTypeService
deviceTypeService
;
/**
* 查询所有的device_type
* @param
* @return
*/
@GetMapping
(
"type"
)
public
ResResult
getDeviceTypeList
()
{
List
<
DeviceType
>
records
=
deviceTypeService
.
getDeviceTypeList
();
return
ResResult
.
success
().
record
(
records
);
}
}
license/src/main/java/iot/sixiang/license/entity/
DeviceType
.java
→
license/src/main/java/iot/sixiang/license/entity/
Apply
.java
View file @
67038584
package
iot
.
sixiang
.
license
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
...
...
@@ -12,18 +14,22 @@ import java.io.Serializable;
* </p>
*
* @author m33
* @since 2022-06-0
8
* @since 2022-06-0
9
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
DeviceType
implements
Serializable
{
public
class
Apply
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Integer
typeId
;
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
appId
;
private
String
type
Name
;
private
String
app
Name
;
private
String
appKey
;
private
Integer
userId
;
}
license/src/main/java/iot/sixiang/license/entity/Device.java
View file @
67038584
...
...
@@ -28,9 +28,6 @@ public class Device implements Serializable {
private
String
sn
;
private
Integer
typeId
;
private
Integer
userId
;
private
Integer
applyId
;
}
license/src/main/java/iot/sixiang/license/jwt/JwtFilter.java
View file @
67038584
...
...
@@ -7,14 +7,13 @@ import iot.sixiang.license.model.ResResult;
import
lombok.extern.slf4j.Slf4j
;
import
javax.servlet.*
;
import
javax.servlet.annotation.WebFilter
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.Map
;
@Slf4j
@WebFilter
(
filterName
=
"jwtFilter"
,
urlPatterns
=
"/iot_license/*"
)
//
@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*")
public
class
JwtFilter
implements
Filter
{
...
...
license/src/main/java/iot/sixiang/license/jwt/JwtUtil.java
View file @
67038584
package
iot
.
sixiang
.
license
.
jwt
;
import
com.auth0.jwt.JWT
;
import
com.auth0.jwt.JWTVerifier
;
import
com.auth0.jwt.algorithms.Algorithm
;
import
com.auth0.jwt.interfaces.Claim
;
import
com.auth0.jwt.interfaces.DecodedJWT
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -20,7 +20,7 @@ public class JwtUtil {
/**
* 过期时间
**/
private
static
final
long
EXPIRATION
=
18
00L
;
//单位为秒
private
static
final
long
EXPIRATION
=
36
00L
;
//单位为秒
private
static
HashMap
<
String
,
String
>
tokens
=
new
HashMap
<>();
/**
...
...
license/src/main/java/iot/sixiang/license/mapper/
DeviceType
Mapper.java
→
license/src/main/java/iot/sixiang/license/mapper/
Apply
Mapper.java
View file @
67038584
package
iot
.
sixiang
.
license
.
mapper
;
import
iot.sixiang.license.entity.Apply
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.
entity.DeviceType
;
import
iot.sixiang.license.
model.vo.AppVo
;
import
java.util.List
;
...
...
@@ -11,9 +12,13 @@ import java.util.List;
* </p>
*
* @author m33
* @since 2022-06-0
8
* @since 2022-06-0
9
*/
public
interface
DeviceTypeMapper
extends
BaseMapper
<
DeviceType
>
{
public
interface
ApplyMapper
extends
BaseMapper
<
Apply
>
{
List
<
DeviceType
>
getDeviceTypeList
();
boolean
addApply
(
String
appName
,
String
appKey
,
int
userId
);
List
<
AppVo
>
getAppList
(
String
appName
);
Apply
getApplyByAppName
(
String
appName
);
}
license/src/main/java/iot/sixiang/license/mapper/DeviceMapper.java
View file @
67038584
...
...
@@ -2,7 +2,7 @@ package iot.sixiang.license.mapper;
import
iot.sixiang.license.entity.Device
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.model.vo.Device
Type
Vo
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
java.util.List
;
...
...
@@ -16,7 +16,7 @@ import java.util.List;
*/
public
interface
DeviceMapper
extends
BaseMapper
<
Device
>
{
List
<
Device
TypeVo
>
getDeviceList
(
String
type
Name
,
String
userName
);
List
<
Device
Vo
>
getDeviceList
(
String
app
Name
,
String
userName
);
boolean
addDevice
(
String
sn
,
int
userId
,
int
type
Id
);
boolean
addDevice
(
String
sn
,
int
app
Id
);
}
license/src/main/java/iot/sixiang/license/model/vo/AppVo.java
0 → 100644
View file @
67038584
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
iot.sixiang.license.entity.Apply
;
import
lombok.Data
;
/**
* Created by m33 on 2022/6/9 16:50
*/
@Data
public
class
AppVo
extends
Apply
{
public
int
deviceCount
;
public
String
userName
;
public
String
company
;
public
String
sn
;
public
int
deviceId
;
}
license/src/main/java/iot/sixiang/license/model/vo/Device
Type
Vo.java
→
license/src/main/java/iot/sixiang/license/model/vo/DeviceVo.java
View file @
67038584
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
iot.sixiang.license.entity.Device
;
import
lombok.Data
;
import
java.io.Serializable
;
...
...
@@ -9,16 +8,16 @@ import java.io.Serializable;
* Created by m33 on 2022/6/8 13:35
*/
@Data
public
class
Device
TypeVo
extends
Device
implements
Serializable
{
public
class
Device
Vo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
typeName
;
private
int
deviceId
;
private
String
password
;
private
String
appName
;
private
String
userName
;
private
String
company
;
private
String
sn
;
}
license/src/main/java/iot/sixiang/license/model/vo/UserVo.java
View file @
67038584
...
...
@@ -8,5 +8,5 @@ import lombok.Data;
*/
@Data
public
class
UserVo
extends
User
{
public
int
device
Count
;
public
int
app
Count
;
}
license/src/main/java/iot/sixiang/license/service/ApplyService.java
0 → 100644
View file @
67038584
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.Apply
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.AppVo
;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-09
*/
public
interface
ApplyService
extends
IService
<
Apply
>
{
boolean
addApply
(
String
appName
,
String
appKey
,
int
userId
);
PageInfoModel
<
AppVo
>
getAppList
(
int
pageNo
,
int
pageSize
,
String
appName
);
}
license/src/main/java/iot/sixiang/license/service/DeviceService.java
View file @
67038584
...
...
@@ -3,7 +3,7 @@ package iot.sixiang.license.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.entity.Device
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.Device
Type
Vo
;
import
iot.sixiang.license.model.vo.DeviceVo
;
/**
* <p>
...
...
@@ -15,7 +15,7 @@ import iot.sixiang.license.model.vo.DeviceTypeVo;
*/
public
interface
DeviceService
extends
IService
<
Device
>
{
PageInfoModel
<
Device
TypeVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
type
Name
,
String
userName
);
PageInfoModel
<
Device
Vo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
app
Name
,
String
userName
);
boolean
addDevice
(
int
userId
,
int
type
Id
,
int
count
);
boolean
addDevice
(
int
app
Id
,
int
count
);
}
license/src/main/java/iot/sixiang/license/service/DeviceTypeService.java
deleted
100644 → 0
View file @
c91046a0
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.DeviceType
;
import
java.util.List
;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-08
*/
public
interface
DeviceTypeService
{
List
<
DeviceType
>
getDeviceTypeList
();
}
license/src/main/java/iot/sixiang/license/service/impl/ApplyServiceImpl.java
0 → 100644
View file @
67038584
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.entity.Apply
;
import
iot.sixiang.license.handler.IotLicenseException
;
import
iot.sixiang.license.mapper.ApplyMapper
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.AppVo
;
import
iot.sixiang.license.service.ApplyService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-09
*/
@Service
public
class
ApplyServiceImpl
extends
ServiceImpl
<
ApplyMapper
,
Apply
>
implements
ApplyService
{
@Resource
ApplyMapper
applyMapper
;
@Override
public
boolean
addApply
(
String
appName
,
String
appKey
,
int
userId
)
{
Apply
res
=
applyMapper
.
getApplyByAppName
(
appName
);
if
(
res
!=
null
)
{
throw
new
IotLicenseException
(
400
,
"应用名已存在"
);
}
return
applyMapper
.
addApply
(
appName
,
appKey
,
userId
);
}
@Override
public
PageInfoModel
<
AppVo
>
getAppList
(
int
pageNo
,
int
pageSize
,
String
appName
)
{
List
<
AppVo
>
records
=
applyMapper
.
getAppList
(
appName
);
records
=
records
.
stream
().
sorted
(
Comparator
.
comparing
(
AppVo:
:
getAppId
)).
collect
(
Collectors
.
toList
());
List
<
AppVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
records
.
size
()
>
0
)
{
result
=
records
.
stream
().
skip
(
begin
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
PageInfoModel
<
AppVo
>
objectPageInfoModel
=
new
PageInfoModel
<>();
objectPageInfoModel
.
setTotal
(
records
.
size
());
objectPageInfoModel
.
setResult
(
result
);
return
objectPageInfoModel
;
}
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
View file @
67038584
...
...
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
iot.sixiang.license.entity.Device
;
import
iot.sixiang.license.mapper.DeviceMapper
;
import
iot.sixiang.license.model.PageInfoModel
;
import
iot.sixiang.license.model.vo.Device
Type
Vo
;
import
iot.sixiang.license.model.vo.DeviceVo
;
import
iot.sixiang.license.service.DeviceService
;
import
iot.sixiang.license.util.CommonUtil
;
import
org.springframework.stereotype.Service
;
...
...
@@ -30,25 +30,25 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
private
DeviceMapper
deviceMapper
;
@Override
public
PageInfoModel
<
Device
TypeVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
type
Name
,
String
userName
)
{
List
<
Device
TypeVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
type
Name
,
userName
);
deviceTypes
=
deviceTypes
.
stream
().
sorted
(
Comparator
.
comparing
(
Device
Type
Vo:
:
getDeviceId
)).
collect
(
Collectors
.
toList
());
List
<
Device
Type
Vo
>
result
=
new
ArrayList
<>();
public
PageInfoModel
<
Device
Vo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
app
Name
,
String
userName
)
{
List
<
Device
Vo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
app
Name
,
userName
);
deviceTypes
=
deviceTypes
.
stream
().
sorted
(
Comparator
.
comparing
(
DeviceVo:
:
getDeviceId
)).
collect
(
Collectors
.
toList
());
List
<
DeviceVo
>
result
=
new
ArrayList
<>();
int
begin
=
(
pageNo
-
1
)
*
pageSize
;
if
(
begin
>=
0
&&
deviceTypes
.
size
()
>
0
)
{
result
=
deviceTypes
.
stream
().
skip
(
begin
).
limit
(
pageSize
).
collect
(
Collectors
.
toList
());
}
PageInfoModel
<
Device
Type
Vo
>
objectPageInfoModel
=
new
PageInfoModel
<>();
PageInfoModel
<
DeviceVo
>
objectPageInfoModel
=
new
PageInfoModel
<>();
objectPageInfoModel
.
setTotal
(
deviceTypes
.
size
());
objectPageInfoModel
.
setResult
(
result
);
return
objectPageInfoModel
;
}
@Override
public
boolean
addDevice
(
int
userId
,
int
type
Id
,
int
count
)
{
public
boolean
addDevice
(
int
app
Id
,
int
count
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
String
sn
=
CommonUtil
.
genRandomNum
(
18
);
boolean
res
=
deviceMapper
.
addDevice
(
sn
,
userId
,
type
Id
);
boolean
res
=
deviceMapper
.
addDevice
(
sn
,
app
Id
);
if
(!
res
)
{
return
false
;
}
...
...
license/src/main/java/iot/sixiang/license/service/impl/DeviceTypeServiceImpl.java
deleted
100644 → 0
View file @
c91046a0
package
iot
.
sixiang
.
license
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
iot.sixiang.license.entity.DeviceType
;
import
iot.sixiang.license.mapper.DeviceTypeMapper
;
import
iot.sixiang.license.service.DeviceTypeService
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-08
*/
@Service
public
class
DeviceTypeServiceImpl
extends
ServiceImpl
<
DeviceTypeMapper
,
DeviceType
>
implements
DeviceTypeService
{
@Resource
private
DeviceTypeMapper
deviceTypeMapper
;
@Override
public
List
<
DeviceType
>
getDeviceTypeList
()
{
List
<
DeviceType
>
deviceTypes
=
deviceTypeMapper
.
getDeviceTypeList
();
return
deviceTypes
;
}
}
license/src/main/java/iot/sixiang/license/util/CodeGenerator.java
View file @
67038584
...
...
@@ -10,11 +10,6 @@ import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import
com.baomidou.mybatisplus.generator.config.rules.NamingStrategy
;
/**
* @author
* @since 2018/12/13
*/
public
class
CodeGenerator
{
public
static
void
main
(
String
[]
args
)
{
// 1、创建代码生成器
...
...
@@ -52,7 +47,7 @@ public class CodeGenerator {
// 5、策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
strategy
.
setInclude
(
"
device_type
"
);
strategy
.
setInclude
(
"
apply
"
);
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体时去掉表前缀
...
...
license/src/main/java/iot/sixiang/license/util/JsonUtil.java
View file @
67038584
package
iot
.
sixiang
.
license
.
util
;
import
com.alibaba.fastjson.JSONObject
;
/**
* Created by m33 on 2022/6/8 9:57
...
...
license/src/main/resources/application-dev.yml
0 → 100644
View file @
67038584
server
:
port
:
8868
logging
:
level
:
root
:
info
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://localhost:3306/iot_license?serverTimezone=GMT%2B8
username
:
root
password
:
123456
mybatis-plus
:
mapper-locations
:
classpath:/mapper/**.xml
type-aliases-package
:
iot.sixiang.license.entity
\ No newline at end of file
license/src/main/resources/application-prod.yml
0 → 100644
View file @
67038584
server
:
port
:
8868
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://localhost:3306/iot_license?serverTimezone=GMT%2B8
username
:
root
password
:
123456
mybatis-plus
:
mapper-locations
:
classpath:/mapper/**.xml
type-aliases-package
:
iot.sixiang.license.entity
\ No newline at end of file
license/src/main/resources/application-test.yml
0 → 100644
View file @
67038584
server
:
port
:
8868
spring
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://192.168.1.19:3306/iot_license?serverTimezone=GMT%2B8
username
:
root
password
:
123456
mybatis-plus
:
mapper-locations
:
classpath:/mapper/**.xml
type-aliases-package
:
iot.sixiang.license.entity
\ No newline at end of file
license/src/main/resources/application.properties
deleted
100644 → 0
View file @
c91046a0
server.port
=
8868
logging.level.root
=
debug
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.datasource.url
=
jdbc:mysql://localhost:3306/iot_license?serverTimezone=GMT%2B8
spring.datasource.username
=
root
spring.datasource.password
=
123456
mybatis-plus.mapper-locations
=
classpath:/mapper/**.xml
mybatis-plus.type-aliases-package
=
iot.sixiang.license.entity
\ No newline at end of file
license/src/main/resources/application.yml
0 → 100644
View file @
67038584
spring
:
profiles
:
active
:
prod
application
:
name
:
iot_license
#当前服务的名称
\ No newline at end of file
license/src/main/resources/mapper/ApplyMapper.xml
0 → 100644
View file @
67038584
<?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">
<mapper
namespace=
"iot.sixiang.license.mapper.ApplyMapper"
>
<sql
id=
"AppVoColumn"
>
app.app_id, app.app_name, app.app_key, us.user_id,
COUNT(sn) AS deviceCount, us.user_name, us.company,
sn, de.device_id
</sql>
<insert
id=
"addApply"
parameterType=
"iot.sixiang.license.entity.Apply"
>
insert into apply(app_name, app_key, user_id) values (#{appName}, #{appKey}, #{userId})
</insert>
<select
id=
"getAppList"
resultType=
"iot.sixiang.license.model.vo.AppVo"
>
SELECT
<include
refid=
"AppVoColumn"
/>
FROM apply AS app LEFT JOIN device AS de ON app.app_id = de.app_id
LEFT JOIN user AS us ON us.user_id = app.user_id
where 1=1
<if
test=
"null != _parameter and '' != _parameter"
>
and app_name like concat('%',#{_parameter},'%')
</if>
GROUP BY app.app_id
</select>
<select
id=
"getApplyByAppName"
resultType=
"iot.sixiang.license.entity.Apply"
>
select app_id from apply where app_name = #{appName}
</select>
</mapper>
license/src/main/resources/mapper/DeviceMapper.xml
View file @
67038584
...
...
@@ -2,25 +2,21 @@
<!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"
>
<sql
id=
"DeviceVoColumn"
>
dt.type_id,dt.type_name,de.device_id,de.sn,us.user_id,us.user_name,us.password,us.company
</sql>
<select
id=
"getDeviceList"
resultType=
"iot.sixiang.license.model.vo.DeviceTypeVo"
>
SELECT
<include
refid=
"DeviceVoColumn"
/>
FROM device_type AS dt
JOIN device AS de ON dt.type_id = de.type_id
JOIN USER AS us ON de.user_id = us.user_id
<select
id=
"getDeviceList"
resultType=
"iot.sixiang.license.model.vo.DeviceVo"
>
SELECT de.device_id,app_name,user_name,sn FROM device AS de
JOIN apply AS app ON de.app_id = app.app_id
JOIN USER AS us ON us.user_id = app.user_id
where 1=1
<if
test=
"null !=
typeName and '' != type
Name"
>
and
type_name like concat('%',#{type
Name},'%')
<if
test=
"null !=
appName and '' != app
Name"
>
and
app_name like concat('%',#{app
Name},'%')
</if>
<if
test=
"null != userName and '' != userName"
>
and us
.us
er_name like concat('%',#{userName},'%')
and user_name like concat('%',#{userName},'%')
</if>
</select>
<insert
id=
"addDevice"
parameterType=
"iot.sixiang.license.entity.Device"
>
insert into device(sn,
type_id, user_id) values (#{sn},#{typeId}, #{user
Id})
insert into device(sn,
app_id) values (#{sn},#{app
Id})
</insert>
</mapper>
license/src/main/resources/mapper/DeviceTypeMapper.xml
deleted
100644 → 0
View file @
c91046a0
<?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">
<mapper
namespace=
"iot.sixiang.license.mapper.DeviceTypeMapper"
>
<!-- <sql id="DeviceTypeVoColumn">-->
<!-- dt.type_id,dt.type_name,de.sn,us.user_id,us.user_name,us.password,us.company-->
<!-- </sql>-->
<select
id=
"getDeviceTypeList"
resultType=
"iot.sixiang.license.entity.DeviceType"
>
SELECT type_id, type_name FROM device_type
</select>
</mapper>
license/src/main/resources/mapper/UserMapper.xml
View file @
67038584
...
...
@@ -15,8 +15,8 @@
</update>
<select
id=
"getUserList"
resultType=
"iot.sixiang.license.model.vo.UserVo"
>
SELECT user.user_id, user_name, password, company, COUNT(
sn) AS device
Count
FROM USER LEFT JOIN
device ON user.user_id = device
.user_id
SELECT user.user_id, user_name, password, company, COUNT(
app_name) AS app
Count
FROM USER LEFT JOIN
apply ON user.user_id = apply
.user_id
where 1=1
<if
test=
"null != userName and '' != userName"
>
and user_name like concat('%',#{userName},'%')
...
...
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