Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
on-site-service
Project
Project
Details
Activity
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
external
on-site-service
Commits
ff9a774e
Commit
ff9a774e
authored
Jul 19, 2022
by
lining
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: common/tree接口
parent
53916982
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
66 deletions
+86
-66
RedisKeyConstants.java
...om/onsiteservice/constant/constant/RedisKeyConstants.java
+2
-0
ServiceAreaController.java
...ervice/miniapp/controller/area/ServiceAreaController.java
+0
-62
HomeCommonController.java
...ice/miniapp/controller/category/HomeCommonController.java
+8
-0
ServiceAreaVO.java
...service/miniapp/controller/category/vo/ServiceAreaVO.java
+38
-0
HomeCommonService.java
...teservice/miniapp/service/category/HomeCommonService.java
+38
-4
No files found.
constant/src/main/java/com/onsiteservice/constant/constant/RedisKeyConstants.java
View file @
ff9a774e
...
@@ -14,6 +14,8 @@ public class RedisKeyConstants {
...
@@ -14,6 +14,8 @@ public class RedisKeyConstants {
*/
*/
public
static
final
String
BASE_AREA_TREE
=
"base:area_tree"
;
public
static
final
String
BASE_AREA_TREE
=
"base:area_tree"
;
public
static
final
String
SERVICE_AREA_TREE
=
"service:area_tree"
;
public
static
final
String
CHECK_CODE_KEY
=
"code:%s:%s"
;
public
static
final
String
CHECK_CODE_KEY
=
"code:%s:%s"
;
public
static
final
int
CODE_EXPIRED
=
10
*
60
*
1000
;
public
static
final
int
CODE_EXPIRED
=
10
*
60
*
1000
;
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/controller/area/ServiceAreaController.java
deleted
100644 → 0
View file @
53916982
package
com
.
onsiteservice
.
miniapp
.
controller
.
area
;
import
com.onsiteservice.entity.area.ServiceArea
;
import
com.onsiteservice.miniapp.service.area.ServiceAreaService
;
import
com.onsiteservice.core.result.Result
;
import
com.onsiteservice.dao.common.page.PageInfoVO
;
import
com.onsiteservice.dao.common.page.PageParams
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.NonNull
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
springfox.documentation.annotations.ApiIgnore
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.Positive
;
import
static
com
.
onsiteservice
.
core
.
result
.
ResultGenerator
.
success
;
import
static
com
.
onsiteservice
.
core
.
result
.
ResultGenerator
.
fail
;
/**
* @author 潘维吉
* @date 2022-07-08 09:11
* @description ServiceAreaController控制类
*/
@ApiIgnore
@Api
(
tags
=
"ServiceAreaController"
)
@RestController
@RequestMapping
(
"/service/area"
)
@Validated
public
class
ServiceAreaController
{
@Resource
private
ServiceAreaService
serviceAreaService
;
@ApiOperation
(
value
=
"分页查询列表"
,
notes
=
"作者: 潘维吉"
)
@PostMapping
(
"/page"
)
public
Result
<
PageInfoVO
>
getPage
(
@RequestBody
@NonNull
@Validated
PageParams
param
)
{
return
success
(
serviceAreaService
.
getPage
(
param
),
"获取分页列表"
);
}
@ApiOperation
(
value
=
"根据id查询"
,
notes
=
"作者: 潘维吉"
)
@GetMapping
(
"/{id}"
)
public
Result
<
ServiceArea
>
getDetails
(
@PathVariable
@Positive
Long
id
)
{
return
success
(
serviceAreaService
.
selectByPrimaryKey
(
id
),
"根据id获取详情"
);
}
@ApiOperation
(
value
=
"新增或修改"
,
notes
=
"作者: 潘维吉"
)
@PostMapping
(
"/save-or-update"
)
public
Result
saveOrUpdate
(
@RequestBody
@NonNull
@Validated
ServiceArea
serviceArea
)
{
return
success
(
serviceAreaService
.
saveOrUpdate
(
serviceArea
),
serviceArea
.
getId
()
==
null
?
"新增成功"
:
"修改成功"
);
}
@ApiOperation
(
value
=
"根据id删除"
,
notes
=
"作者: 潘维吉"
)
@DeleteMapping
(
"/{id}"
)
public
Result
deleteById
(
@PathVariable
@Positive
Long
id
)
{
return
success
(
serviceAreaService
.
deleteByPrimaryKey
(
id
),
"删除成功"
);
}
}
mini-app/src/main/java/com/onsiteservice/miniapp/controller/category/HomeCommonController.java
View file @
ff9a774e
...
@@ -2,6 +2,7 @@ package com.onsiteservice.miniapp.controller.category;
...
@@ -2,6 +2,7 @@ package com.onsiteservice.miniapp.controller.category;
import
com.onsiteservice.core.result.Result
;
import
com.onsiteservice.core.result.Result
;
import
com.onsiteservice.miniapp.controller.category.vo.HomeViewVO
;
import
com.onsiteservice.miniapp.controller.category.vo.HomeViewVO
;
import
com.onsiteservice.miniapp.controller.category.vo.ServiceAreaVO
;
import
com.onsiteservice.miniapp.service.category.HomeCommonService
;
import
com.onsiteservice.miniapp.service.category.HomeCommonService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.List
;
/**
/**
* <P>服务大类模块</P>
* <P>服务大类模块</P>
...
@@ -36,5 +38,11 @@ public class HomeCommonController {
...
@@ -36,5 +38,11 @@ public class HomeCommonController {
return
homeCommonService
.
home
();
return
homeCommonService
.
home
();
}
}
@ApiOperation
(
value
=
"地域树"
)
@GetMapping
(
"tree"
)
public
Result
tree
()
{
return
homeCommonService
.
tree
();
}
}
}
mini-app/src/main/java/com/onsiteservice/miniapp/controller/category/vo/ServiceAreaVO.java
0 → 100644
View file @
ff9a774e
package
com
.
onsiteservice
.
miniapp
.
controller
.
category
.
vo
;
import
com.onsiteservice.common.controller.vo.AreaTreeVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
@Data
@ApiModel
(
"服务区域值对象"
)
public
class
ServiceAreaVO
{
@ApiModelProperty
(
"主键"
)
private
Long
id
;
@ApiModelProperty
(
"编码"
)
private
String
code
;
@ApiModelProperty
(
"父编码"
)
private
String
parentCode
;
@ApiModelProperty
(
"名称"
)
private
String
name
;
@ApiModelProperty
(
"名称路径"
)
private
String
namePath
;
@ApiModelProperty
(
"市区街道 city district street"
)
private
String
level
;
@ApiModelProperty
(
"经度,纬度"
)
private
String
center
;
@ApiModelProperty
(
"子节点"
)
private
List
<
ServiceAreaVO
>
children
;
}
\ No newline at end of file
mini-app/src/main/java/com/onsiteservice/miniapp/service/category/HomeCommonService.java
View file @
ff9a774e
package
com
.
onsiteservice
.
miniapp
.
service
.
category
;
package
com
.
onsiteservice
.
miniapp
.
service
.
category
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.onsiteservice.constant.constant.BizConstants
;
import
com.onsiteservice.constant.constant.BizConstants
;
import
com.onsiteservice.constant.constant.RedisKeyConstants
;
import
com.onsiteservice.core.result.Result
;
import
com.onsiteservice.core.result.Result
;
import
com.onsiteservice.core.result.ResultGenerator
;
import
com.onsiteservice.core.result.ResultGenerator
;
import
com.onsiteservice.dao.mapper.banner.BannerMapper
;
import
com.onsiteservice.dao.mapper.banner.BannerMapper
;
import
com.onsiteservice.dao.mapper.home.HomeNoticeMapper
;
import
com.onsiteservice.dao.mapper.home.HomeNoticeMapper
;
import
com.onsiteservice.dao.mapper.service.ServiceAreaMapper
;
import
com.onsiteservice.entity.area.ServiceArea
;
import
com.onsiteservice.entity.banner.Banner
;
import
com.onsiteservice.entity.banner.Banner
;
import
com.onsiteservice.entity.home.HomeNotice
;
import
com.onsiteservice.entity.home.HomeNotice
;
import
com.onsiteservice.miniapp.controller.category.vo.BannerVO
;
import
com.onsiteservice.miniapp.controller.category.vo.*
;
import
com.onsiteservice.miniapp.controller.category.vo.HomeNoticeVO
;
import
com.onsiteservice.miniapp.controller.category.vo.HomeViewVO
;
import
com.onsiteservice.miniapp.controller.category.vo.ServiceCategoryVO
;
import
com.onsiteservice.util.AttrCopyUtils
;
import
com.onsiteservice.util.AttrCopyUtils
;
import
com.onsiteservice.util.tree.TreeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
tk.mybatis.mapper.entity.Condition
;
import
tk.mybatis.mapper.entity.Condition
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -21,6 +29,7 @@ import java.util.List;
...
@@ -21,6 +29,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
@Slf4j
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
HomeCommonService
{
public
class
HomeCommonService
{
...
@@ -31,9 +40,15 @@ public class HomeCommonService {
...
@@ -31,9 +40,15 @@ public class HomeCommonService {
@Resource
@Resource
private
HomeNoticeMapper
homeNoticeMapper
;
private
HomeNoticeMapper
homeNoticeMapper
;
@Resource
private
ServiceAreaMapper
serviceAreaMapper
;
@Resource
@Resource
private
ServiceCategoryService
serviceCategoryService
;
private
ServiceCategoryService
serviceCategoryService
;
@Autowired
private
StringRedisTemplate
redisTemplate
;
public
Result
<
HomeViewVO
>
home
()
{
public
Result
<
HomeViewVO
>
home
()
{
// 轮播图
// 轮播图
...
@@ -60,5 +75,24 @@ public class HomeCommonService {
...
@@ -60,5 +75,24 @@ public class HomeCommonService {
return
ResultGenerator
.
success
(
homeViewVO
);
return
ResultGenerator
.
success
(
homeViewVO
);
}
}
public
Result
tree
()
{
String
value
=
redisTemplate
.
opsForValue
().
get
(
RedisKeyConstants
.
SERVICE_AREA_TREE
);
try
{
List
<
ServiceAreaVO
>
data
=
JSONArray
.
parseArray
(
value
,
ServiceAreaVO
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
data
))
{
return
ResultGenerator
.
success
(
data
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"common tree, 转型失败 "
,
e
);
}
List
<
ServiceArea
>
serviceAreaList
=
serviceAreaMapper
.
selectAll
();
List
<
ServiceAreaVO
>
serviceAreaVOList
=
serviceAreaList
.
parallelStream
().
map
(
e
->
AttrCopyUtils
.
copy
(
e
,
new
ServiceAreaVO
())).
collect
(
Collectors
.
toList
());
List
<
ServiceAreaVO
>
list
=
TreeUtils
.
getTree
(
serviceAreaVOList
,
ServiceAreaVO:
:
getCode
,
ServiceAreaVO:
:
getParentCode
,
ServiceAreaVO:
:
setChildren
);
redisTemplate
.
opsForValue
().
set
(
RedisKeyConstants
.
SERVICE_AREA_TREE
,
JSON
.
toJSONString
(
list
));
return
ResultGenerator
.
success
(
list
);
}
}
}
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