Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
znks
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
王夏晖
znks
Commits
6d940399
Commit
6d940399
authored
Sep 21, 2018
by
leyboy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.位置信息接口
2.锁记录接口修改
parent
670858a4
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
445 additions
and
268 deletions
+445
-268
workspace.xml
.idea/workspace.xml
+296
-213
DozerConfig.java
...ain/src/main/java/com/adc/da/main/config/DozerConfig.java
+7
-7
PositionController.java
...n/java/com/adc/da/znks/controller/PositionController.java
+46
-29
PositionDao.java
...a-main/src/main/java/com/adc/da/znks/dao/PositionDao.java
+4
-1
PositionService.java
...rc/main/java/com/adc/da/znks/service/PositionService.java
+7
-0
PositionVO.java
adc-da-main/src/main/java/com/adc/da/znks/vo/PositionVO.java
+31
-0
banner.txt
adc-da-main/src/main/resources/banner.txt
+1
-1
dozer-mappings.xml
adc-da-main/src/main/resources/dozer/dozer-mappings.xml
+10
-0
LockRecordMapper.xml
...c/main/resources/mybatis/mapper/znks/LockRecordMapper.xml
+2
-2
PositionMapper.xml
...src/main/resources/mybatis/mapper/znks/PositionMapper.xml
+41
-15
No files found.
.idea/workspace.xml
View file @
6d940399
This diff is collapsed.
Click to expand it.
adc-da-main/src/main/java/com/adc/da/main/config/DozerConfig.java
View file @
6d940399
...
...
@@ -13,12 +13,12 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public
class
DozerConfig
{
@Bean
(
name
=
"org.dozer.Mapper"
)
public
DozerBeanMapper
dozer
()
{
List
<
String
>
mappingFiles
=
Arrays
.
asList
(
"dozer/dozer-mappings-sy
s.xml"
);
DozerBeanMapper
dozerBean
=
new
DozerBeanMapper
();
dozerBean
.
setMappingFiles
(
mappingFiles
);
return
dozerBean
;
}
@Bean
(
name
=
"org.dozer.Mapper"
)
public
DozerBeanMapper
dozer
()
{
List
<
String
>
mappingFiles
=
Arrays
.
asList
(
"dozer/dozer-mapping
s.xml"
);
DozerBeanMapper
dozerBean
=
new
DozerBeanMapper
();
dozerBean
.
setMappingFiles
(
mappingFiles
);
return
dozerBean
;
}
}
adc-da-main/src/main/java/com/adc/da/znks/controller/PositionController.java
View file @
6d940399
package
com
.
adc
.
da
.
znks
.
controller
;
import
com.adc.da.util.utils.BeanMapper
;
import
com.adc.da.znks.entity.Position
;
import
com.adc.da.znks.entity.ResponseEntity
;
import
com.adc.da.znks.entity.User
;
import
com.adc.da.znks.page.PositionPage
;
import
com.adc.da.znks.service.PositionService
;
import
com.adc.da.znks.service.UserService
;
import
com.adc.da.znks.util.GenResponse
;
import
com.adc.da.znks.vo.PositionVO
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
com.adc.da.base.web.BaseController
;
import
com.adc.da.util.http.PageInfo
;
import
com.adc.da.util.http.ResponseMessage
;
import
com.adc.da.util.http.Result
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -29,37 +35,48 @@ public class PositionController extends BaseController<Position> {
@Autowired
private
PositionService
positionService
;
@Autowired
private
UserService
userService
;
@Autowired
private
BeanMapper
beanMapper
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PositionController
.
class
);
// @ApiOperation(value = "|Position|分页查询")
// @GetMapping("/page")
// public ResponseMessage<PageInfo<Position>> page(PositionPage page) throws Exception {
// List<Position> rows = positionService.queryByPage(page);
// return Result.success(getPageInfo(page.getPager(), rows));
// }
//
// @ApiOperation(value = "|Position|查询")
// @GetMapping("")
// public ResponseMessage<List<Position>> list(PositionPage page) throws Exception {
// return Result.success(positionService.queryByList(page));
// }
//
// @ApiOperation(value = "|Position|详情")
// @GetMapping("/position/{positionId}")
// public ResponseMessage<Position> find(@PathVariable String positionId) throws Exception {
// return Result.success(positionService.selectByPrimaryKey(positionId));
// }
@ApiOperation
(
value
=
"|Position|分页查询"
)
@GetMapping
(
"/page"
)
public
ResponseEntity
<
PageInfo
>
page
(
@RequestParam
(
required
=
false
)
String
telphone
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
pageNum
,
@RequestParam
(
defaultValue
=
"8"
)
Integer
pageSize
)
throws
Exception
{
try
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
List
<
PositionVO
>
positionVOS
=
positionService
.
listPositionsByPage
(
telphone
,
pageNum
,
pageSize
);
PageInfo
positionVOPageInfo
=
new
PageInfo
(
positionVOS
);
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"查询位置信息成功"
,
positionVOPageInfo
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
GenResponse
.
fail
(
"查询位置信息失败"
);
}
}
@ApiOperation
(
value
=
"|Position|新增"
)
@PostMapping
(
"/position"
)
public
ResponseMessage
<
Boolean
>
create
(
@RequestBody
Position
position
)
throws
Exception
{
position
.
setPositionId
(
UUID
.
randomUUID
().
toString
());
position
.
setRecordTime
(
new
Date
(
System
.
currentTimeMillis
()));
int
result
=
positionService
.
insertSelective
(
position
);
if
(
result
!=
0
)
{
return
Result
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"新增位置成功"
,
true
);
@PostMapping
(
value
=
"/position"
,
consumes
=
{
"application/x-www-form-urlencoded"
})
public
ResponseEntity
<
Boolean
>
create
(
PositionVO
positionVO
)
throws
Exception
{
Position
position
=
beanMapper
.
map
(
positionVO
,
Position
.
class
);
String
userTelphone
=
positionVO
.
getTelphone
();
User
user
=
userService
.
getByPhoneNumber
(
userTelphone
);
if
(
user
!=
null
)
{
position
.
setPositionId
(
UUID
.
randomUUID
().
toString
());
position
.
setRecordTime
(
new
Date
(
System
.
currentTimeMillis
()));
position
.
setUserId
(
user
.
getId
());
int
result
=
positionService
.
insertSelective
(
position
);
if
(
result
!=
0
)
{
return
GenResponse
.
success
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"新增位置成功"
,
true
);
}
else
{
return
GenResponse
.
fail
(
"新增位置失败"
);
}
}
else
{
return
Result
.
error
(
String
.
valueOf
(
HttpStatus
.
OK
.
value
()),
"新增位置失败"
,
false
);
return
GenResponse
.
fail
(
"用户手机号在数据库不存在"
);
}
}
...
...
adc-da-main/src/main/java/com/adc/da/znks/dao/PositionDao.java
View file @
6d940399
...
...
@@ -2,15 +2,18 @@ package com.adc.da.znks.dao;
import
com.adc.da.base.dao.BaseDao
;
import
com.adc.da.znks.entity.Position
;
import
com.adc.da.znks.vo.PositionVO
;
import
org.apache.ibatis.annotations.*
;
import
java.util.List
;
import
java.util.Map
;
/**
*
* <br>
* <b>功能:</b>PositionDao<br>
*/
@Mapper
public
interface
PositionDao
extends
BaseDao
<
Position
>
{
List
<
PositionVO
>
listPositionByPage
(
@Param
(
"telphone"
)
String
telphone
,
@Param
(
"pageNum"
)
Integer
pageNum
,
@Param
(
"pageSize"
)
Integer
pageSize
);
}
adc-da-main/src/main/java/com/adc/da/znks/service/PositionService.java
View file @
6d940399
...
...
@@ -3,6 +3,7 @@ package com.adc.da.znks.service;
import
com.adc.da.base.service.BaseService
;
import
com.adc.da.znks.dao.PositionDao
;
import
com.adc.da.znks.entity.Position
;
import
com.adc.da.znks.vo.PositionVO
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -10,6 +11,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* <br>
...
...
@@ -28,4 +31,8 @@ public class PositionService extends BaseService<Position, String> {
return
dao
;
}
public
List
<
PositionVO
>
listPositionsByPage
(
String
telphone
,
Integer
pageNum
,
Integer
pageSize
)
{
return
dao
.
listPositionByPage
(
telphone
,
pageNum
,
pageSize
);
}
}
adc-da-main/src/main/java/com/adc/da/znks/vo/PositionVO.java
0 → 100644
View file @
6d940399
package
com
.
adc
.
da
.
znks
.
vo
;
import
com.adc.da.znks.entity.Position
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
/**
* @author ley
**/
public
class
PositionVO
extends
Position
{
private
String
telphone
;
private
String
recordTimeStr
;
public
String
getTelphone
()
{
return
telphone
;
}
public
void
setTelphone
(
String
telphone
)
{
this
.
telphone
=
telphone
;
}
public
String
getRecordTimeStr
()
{
recordTimeStr
=
DateFormatUtils
.
format
(
getRecordTime
(),
"yyyy-MM-dd HH:mm:ss"
);
return
recordTimeStr
;
}
public
void
setRecordTimeStr
(
String
recordTimeStr
)
{
this
.
recordTimeStr
=
recordTimeStr
;
}
}
adc-da-main/src/main/resources/banner.txt
View file @
6d940399
...
...
@@ -6,4 +6,4 @@ ${AnsiColor.RED} _ _
${AnsiColor.YELLOW}------------------------------------------------
${AnsiColor.YELLOW} :: ${AnsiColor.YELLOW}@数据资源中心
${AnsiColor.YELLOW}------------------------------------------------${AnsiColor.WHITE}
\ No newline at end of file
${AnsiColor.YELLOW}------------------------------------------------${AnsiColor.BLACK}
\ No newline at end of file
adc-da-main/src/main/resources/dozer/dozer-mappings.xml
0 → 100644
View file @
6d940399
<?xml version="1.0" encoding="UTF-8"?>
<mappings
xmlns=
"http://dozer.sourceforge.net"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://dozer.sourceforge.net
http://dozer.sourceforge.net/schema/beanmapping.xsd"
>
<mapping>
<!--配置EO和VO全类名对应-->
<class-a>
com.adc.da.znks.entity.Position
</class-a>
<class-b>
com.adc.da.znks.vo.PositionVO
</class-b>
</mapping>
</mappings>
\ No newline at end of file
adc-da-main/src/main/resources/mybatis/mapper/znks/LockRecordMapper.xml
View file @
6d940399
...
...
@@ -52,8 +52,8 @@
u.temphone LIKE #{telphoneLike} and
</if>
u.id = d.user_id and
d.
code = lr.device_i
d
and
lr.lock_type != ''
d.
id = lr.device_id an
d
lr.lock_type != ''
</where>
</select>
...
...
adc-da-main/src/main/resources/mybatis/mapper/znks/PositionMapper.xml
View file @
6d940399
...
...
@@ -41,20 +41,21 @@
<!-- 插入记录 -->
<insert
id=
"insert"
parameterType=
"com.adc.da.znks.entity.Position"
>
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="position_id">
SELECT SEQ_tb_position.NEXTVAL FROM DUAL
</selectKey> -->
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="position_id">
SELECT SEQ_tb_position.NEXTVAL FROM DUAL
</selectKey> -->
insert into tb_position(
<include
refid=
"Base_Column_List"
/>
)
values (#{positionId, jdbcType=VARCHAR}, #{recordTime, jdbcType=TIMESTAMP}, #{positionName, jdbcType=VARCHAR}, #{userId, jdbcType=VARCHAR})
values (#{positionId, jdbcType=VARCHAR}, #{recordTime, jdbcType=TIMESTAMP}, #{positionName, jdbcType=VARCHAR},
#{userId, jdbcType=VARCHAR})
</insert>
<!-- 动态插入记录 主键是序列 -->
<insert
id=
"insertSelective"
parameterType=
"com.adc.da.znks.entity.Position"
>
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="position_id">
SELECT SEQ_tb_position.NEXTVAL FROM DUAL
</selectKey> -->
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="position_id">
SELECT SEQ_tb_position.NEXTVAL FROM DUAL
</selectKey> -->
insert into tb_position
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"positionId != null"
>
position_id,
</if>
...
...
@@ -70,7 +71,7 @@
</trim>
</insert>
<!-- 根据pk,修改记录-->
<!-- 根据pk,修改记录-->
<update
id=
"updateByPrimaryKey"
parameterType=
"com.adc.da.znks.entity.Position"
>
update tb_position
set record_time = #{recordTime},
...
...
@@ -84,13 +85,13 @@
update tb_position
<set>
<if
test=
"recordTime != null"
>
record_time = #{recordTime},
record_time = #{recordTime},
</if>
<if
test=
"positionName != null"
>
position_name = #{positionName},
position_name = #{positionName},
</if>
<if
test=
"userId != null"
>
user_id = #{userId},
user_id = #{userId},
</if>
</set>
where position_id = #{positionId}
...
...
@@ -103,7 +104,7 @@
<include
refid=
"Base_Column_List"
/>
from tb_position
where position_id = #{value}
</select>
<!-- 删除记录 -->
...
...
@@ -114,7 +115,7 @@
</delete>
<!-- tb_position 列表总数-->
<select
id=
"queryByCount"
resultType=
"java.lang.Integer"
parameterType=
"com.adc.da.base.page.BasePage"
>
select count(1) from tb_position
...
...
@@ -128,7 +129,7 @@
from tb_position
<include
refid=
"Base_Where_Clause"
/>
<if
test=
"pager.orderCondition != null and pager.orderCondition != ''"
>
${pager.orderCondition}
${pager.orderCondition}
</if>
limit ${pager.pageOffset},${pageSize}
</select>
...
...
@@ -140,8 +141,33 @@
from tb_position
<include
refid=
"Base_Where_Clause"
/>
<if
test=
"pager.orderCondition != null and pager.orderCondition != ''"
>
${pager.orderCondition}
${pager.orderCondition}
</if>
</select>
<resultMap
id=
"PositionVOMap"
type=
"com.adc.da.znks.vo.PositionVO"
>
<id
column=
"position_id"
property=
"positionId"
/>
<result
column=
"record_time"
property=
"recordTime"
/>
<result
column=
"position_name"
property=
"positionName"
/>
<result
column=
"user_id"
property=
"userId"
/>
<result
column=
"temphone"
property=
"telphone"
/>
</resultMap>
<sql
id=
"Position_VO_Column"
>
p.position_id,p.record_time, p.position_name, p.user_id,u.temphone
</sql>
<select
id=
"listPositionByPage"
parameterType=
"object"
resultMap=
"PositionVOMap"
>
select
<include
refid=
"Position_VO_Column"
/>
from tb_position p INNER JOIN tb_user u ON p.user_id = u.id
<where>
<if
test=
"telphone!=null and telphone!=''"
>
<bind
name=
"telphoneLike"
value=
"'%'+telphone+'%'"
/>
u.temphone LIKE #{telphoneLike}
</if>
</where>
</select>
</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