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
a076db8b
Commit
a076db8b
authored
Jun 08, 2022
by
zengtianlai3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
查询设备列表
parent
f0afbbdc
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
430 additions
and
4 deletions
+430
-4
DeviceController.java
...java/iot/sixiang/license/controller/DeviceController.java
+45
-0
DeviceTypeController.java
.../iot/sixiang/license/controller/DeviceTypeController.java
+46
-0
Device.java
license/src/main/java/iot/sixiang/license/entity/Device.java
+31
-0
DeviceType.java
.../src/main/java/iot/sixiang/license/entity/DeviceType.java
+29
-0
License.java
...nse/src/main/java/iot/sixiang/license/entity/License.java
+3
-2
User.java
license/src/main/java/iot/sixiang/license/entity/User.java
+8
-2
DeviceMapper.java
...rc/main/java/iot/sixiang/license/mapper/DeviceMapper.java
+20
-0
DeviceTypeMapper.java
...ain/java/iot/sixiang/license/mapper/DeviceTypeMapper.java
+22
-0
DeviceTypeVo.java
.../main/java/iot/sixiang/license/model/vo/DeviceTypeVo.java
+24
-0
DeviceService.java
.../main/java/iot/sixiang/license/service/DeviceService.java
+20
-0
DeviceTypeService.java
...n/java/iot/sixiang/license/service/DeviceTypeService.java
+19
-0
DeviceServiceImpl.java
...a/iot/sixiang/license/service/impl/DeviceServiceImpl.java
+31
-0
DeviceTypeServiceImpl.java
...t/sixiang/license/service/impl/DeviceTypeServiceImpl.java
+38
-0
CodeGenerator.java
...src/main/java/iot/sixiang/license/util/CodeGenerator.java
+72
-0
DeviceMapper.xml
license/src/main/resources/mapper/DeviceMapper.xml
+22
-0
No files found.
license/src/main/java/iot/sixiang/license/controller/DeviceController.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
iot.sixiang.license.model.RespResult
;
import
iot.sixiang.license.model.vo.DeviceTypeVo
;
import
iot.sixiang.license.service.DeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
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"
)
public
class
DeviceController
{
@Autowired
private
DeviceService
deviceService
;
/**
* 可按条件分页查询所有的user
* @param jsonObject
* @return
*/
@GetMapping
(
"list"
)
public
RespResult
getDeviceList
(
@RequestBody
JSONObject
jsonObject
)
{
int
pageNo
=
(
int
)
jsonObject
.
get
(
"page_no"
);
int
pageSize
=
(
int
)
jsonObject
.
get
(
"page_size"
);
String
typeName
=
jsonObject
.
getString
(
"type_name"
);
String
userId
=
jsonObject
.
getString
(
"user_id"
);
List
<
DeviceTypeVo
>
records
=
deviceService
.
getDeviceList
(
pageNo
,
pageSize
,
typeName
,
userId
);
return
RespResult
.
success
().
record
(
records
);
}
}
license/src/main/java/iot/sixiang/license/controller/DeviceTypeController.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
iot.sixiang.license.model.RespResult
;
import
iot.sixiang.license.model.vo.DeviceTypeVo
;
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.RequestBody
;
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
;
/**
* 可按条件分页查询所有的user
* @param jsonObject
* @return
*/
@GetMapping
(
"list"
)
public
RespResult
getDeviceTypeList
(
@RequestBody
JSONObject
jsonObject
)
{
int
pageNo
=
(
int
)
jsonObject
.
get
(
"page_no"
);
int
pageSize
=
(
int
)
jsonObject
.
get
(
"page_size"
);
String
typeName
=
jsonObject
.
getString
(
"type_name"
);
String
userId
=
jsonObject
.
getString
(
"user_id"
);
List
<
DeviceTypeVo
>
records
=
deviceTypeService
.
getDeviceTypeList
(
pageNo
,
pageSize
,
typeName
,
userId
);
return
RespResult
.
success
().
record
(
records
);
}
}
license/src/main/java/iot/sixiang/license/entity/Device.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
entity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <p>
*
* </p>
*
* @author m33
* @since 2022-06-08
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
Device
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
sn
;
private
String
typeId
;
private
Long
userId
;
}
license/src/main/java/iot/sixiang/license/entity/DeviceType.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
entity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <p>
*
* </p>
*
* @author m33
* @since 2022-06-08
*/
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@Accessors
(
chain
=
true
)
public
class
DeviceType
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Long
typeId
;
private
String
typeName
;
}
license/src/main/java/iot/sixiang/license/entity/License.java
View file @
a076db8b
package
iot
.
sixiang
.
license
.
entity
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <p>
*
...
...
@@ -24,7 +25,7 @@ public class License implements Serializable {
private
String
appKey
;
private
Stri
ng
userId
;
private
Lo
ng
userId
;
}
license/src/main/java/iot/sixiang/license/entity/User.java
View file @
a076db8b
package
iot
.
sixiang
.
license
.
entity
;
import
java.io.Serializable
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
/**
* <p>
*
...
...
@@ -20,9 +23,12 @@ public class User implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
private
String
userId
;
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
userId
;
private
String
password
;
private
String
userName
;
private
String
company
;
}
license/src/main/java/iot/sixiang/license/mapper/DeviceMapper.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
mapper
;
import
iot.sixiang.license.entity.Device
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.model.vo.DeviceTypeVo
;
import
java.util.List
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author m33
* @since 2022-06-08
*/
public
interface
DeviceMapper
extends
BaseMapper
<
Device
>
{
List
<
DeviceTypeVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
typeName
,
String
userId
);
}
license/src/main/java/iot/sixiang/license/mapper/DeviceTypeMapper.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
mapper
;
import
iot.sixiang.license.entity.DeviceType
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
iot.sixiang.license.model.vo.DeviceTypeVo
;
import
java.util.List
;
/**
* <p>
* Mapper 接口
* </p>
*
* @author m33
* @since 2022-06-08
*/
public
interface
DeviceTypeMapper
extends
BaseMapper
<
DeviceType
>
{
List
<
DeviceTypeVo
>
getAllList
();
List
<
DeviceTypeVo
>
getDeviceTypeList
(
int
pageNo
,
int
pageSize
,
String
typeName
,
String
userId
);
}
license/src/main/java/iot/sixiang/license/model/vo/DeviceTypeVo.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
model
.
vo
;
import
iot.sixiang.license.entity.Device
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* Created by m33 on 2022/6/8 13:35
*/
@Data
public
class
DeviceTypeVo
extends
Device
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
typeName
;
private
String
password
;
private
String
userName
;
private
String
company
;
}
license/src/main/java/iot/sixiang/license/service/DeviceService.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.entity.Device
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
iot.sixiang.license.model.vo.DeviceTypeVo
;
import
java.util.List
;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-08
*/
public
interface
DeviceService
extends
IService
<
Device
>
{
List
<
DeviceTypeVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
typeName
,
String
userId
);
}
license/src/main/java/iot/sixiang/license/service/DeviceTypeService.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
service
;
import
iot.sixiang.license.model.vo.DeviceTypeVo
;
import
java.util.List
;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-08
*/
public
interface
DeviceTypeService
{
List
<
DeviceTypeVo
>
getDeviceTypeList
(
int
pageNo
,
int
pageSize
,
String
typeName
,
String
userId
);
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceServiceImpl.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
service
.
impl
;
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.vo.DeviceTypeVo
;
import
iot.sixiang.license.service.DeviceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-08
*/
@Service
public
class
DeviceServiceImpl
extends
ServiceImpl
<
DeviceMapper
,
Device
>
implements
DeviceService
{
@Autowired
private
DeviceMapper
deviceMapper
;
@Override
public
List
<
DeviceTypeVo
>
getDeviceList
(
int
pageNo
,
int
pageSize
,
String
typeName
,
String
userId
)
{
List
<
DeviceTypeVo
>
deviceTypes
=
deviceMapper
.
getDeviceList
(
pageNo
,
pageSize
,
typeName
,
userId
);
return
deviceTypes
;
}
}
license/src/main/java/iot/sixiang/license/service/impl/DeviceTypeServiceImpl.java
0 → 100644
View file @
a076db8b
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.model.vo.DeviceTypeVo
;
import
iot.sixiang.license.service.DeviceTypeService
;
import
iot.sixiang.license.util.JsonUtil
;
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
<
DeviceTypeVo
>
getDeviceTypeList
(
int
pageNo
,
int
pageSize
,
String
typeName
,
String
userId
)
{
if
(
JsonUtil
.
isNull
(
String
.
valueOf
(
pageNo
))
||
JsonUtil
.
isNull
(
String
.
valueOf
(
pageSize
)))
{
List
<
DeviceTypeVo
>
deviceTypes
=
deviceTypeMapper
.
getAllList
();
return
deviceTypes
;
}
else
{
List
<
DeviceTypeVo
>
deviceTypes
=
deviceTypeMapper
.
getDeviceTypeList
(
pageNo
,
pageSize
,
typeName
,
userId
);
return
deviceTypes
;
}
}
}
license/src/main/java/iot/sixiang/license/util/CodeGenerator.java
0 → 100644
View file @
a076db8b
package
iot
.
sixiang
.
license
.
util
;
import
com.baomidou.mybatisplus.annotation.DbType
;
import
com.baomidou.mybatisplus.generator.AutoGenerator
;
import
com.baomidou.mybatisplus.generator.config.DataSourceConfig
;
import
com.baomidou.mybatisplus.generator.config.GlobalConfig
;
import
com.baomidou.mybatisplus.generator.config.PackageConfig
;
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、创建代码生成器
AutoGenerator
mpg
=
new
AutoGenerator
();
// 2、全局配置
GlobalConfig
gc
=
new
GlobalConfig
();
// String projectPath = System.getProperty("user.dir");
gc
.
setOutputDir
(
"C:\\Users\\Administrator\\IdeaProjects\\ioc_sixiang_license\\license"
+
"/src/main/java"
);
gc
.
setAuthor
(
"m33"
);
gc
.
setOpen
(
false
);
//生成后是否打开资源管理器
gc
.
setFileOverride
(
false
);
//重新生成时文件是否覆盖
gc
.
setServiceName
(
"%sService"
);
//去掉Service接口的首字母I
mpg
.
setGlobalConfig
(
gc
);
// 3、数据源配置
DataSourceConfig
dsc
=
new
DataSourceConfig
();
dsc
.
setUrl
(
"jdbc:mysql://localhost:3306/iot_license?serverTimezone=GMT%2B8"
);
dsc
.
setDriverName
(
"com.mysql.cj.jdbc.Driver"
);
dsc
.
setUsername
(
"root"
);
dsc
.
setPassword
(
"123456"
);
dsc
.
setDbType
(
DbType
.
MYSQL
);
mpg
.
setDataSource
(
dsc
);
// 4、包配置
PackageConfig
pc
=
new
PackageConfig
();
pc
.
setModuleName
(
"license"
);
//模块名
pc
.
setParent
(
"iot.sixiang"
);
pc
.
setController
(
"controller"
);
pc
.
setEntity
(
"entity"
);
pc
.
setService
(
"service"
);
pc
.
setMapper
(
"mapper"
);
mpg
.
setPackageInfo
(
pc
);
// 5、策略配置
StrategyConfig
strategy
=
new
StrategyConfig
();
strategy
.
setInclude
(
"device_type"
);
strategy
.
setNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表映射到实体的命名策略
strategy
.
setTablePrefix
(
pc
.
getModuleName
()
+
"_"
);
//生成实体时去掉表前缀
strategy
.
setColumnNaming
(
NamingStrategy
.
underline_to_camel
);
//数据库表字段映射到实体的命名策略
strategy
.
setEntityLombokModel
(
true
);
// lombok 模型 @Accessors(chain = true) setter链式操作
strategy
.
setRestControllerStyle
(
true
);
//restful api风格控制器
strategy
.
setControllerMappingHyphenStyle
(
true
);
//url中驼峰转连字符
mpg
.
setStrategy
(
strategy
);
// 6、执行
mpg
.
execute
();
}
}
license/src/main/resources/mapper/DeviceMapper.xml
0 → 100644
View file @
a076db8b
<?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.DeviceMapper"
>
<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
where 1=1
<if
test=
"null != typeName and '' != typeName"
>
and type_name = #{typeName}
</if>
<if
test=
"null != userId and '' != userId"
>
and us.user_id = #{userId}
</if>
LIMIT #{pageNo}*#{pageSize} - 1,#{pageSize}
</select>
<sql
id=
"DeviceVoColumn"
>
dt.type_id,dt.type_name,de.sn,us.user_id,us.user_name,us.password,us.company
</sql>
</mapper>
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