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
f5b89732
Commit
f5b89732
authored
Jul 08, 2022
by
kretee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: order表添加字段,address表添加字段
parent
796b966f
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
317 additions
and
2 deletions
+317
-2
BizCodeEnum.java
...in/java/com/onsiteservice/constant/enums/BizCodeEnum.java
+7
-1
ServiceException.java
...va/com/onsiteservice/core/exception/ServiceException.java
+5
-0
ServiceAreaMapper.java
...m/onsiteservice/dao/mapper/service/ServiceAreaMapper.java
+7
-0
ServiceAreaMapper.xml
dao/src/main/resources/mapper/service/ServiceAreaMapper.xml
+19
-0
ServiceAddress.java
...java/com/onsiteservice/entity/address/ServiceAddress.java
+12
-0
ServiceArea.java
.../main/java/com/onsiteservice/entity/area/ServiceArea.java
+82
-0
ServiceOrder.java
...ain/java/com/onsiteservice/entity/order/ServiceOrder.java
+7
-0
SaveServiceAddressDTO.java
...miniapp/controller/address/dto/SaveServiceAddressDTO.java
+12
-0
UpdateServiceAddressDTO.java
...niapp/controller/address/dto/UpdateServiceAddressDTO.java
+12
-0
ServiceAddressVO.java
...rvice/miniapp/controller/address/vo/ServiceAddressVO.java
+11
-0
ServiceOrderVO.java
...teservice/miniapp/controller/order/vo/ServiceOrderVO.java
+2
-0
ServiceAreaController.java
...ice/miniapp/controller/service/ServiceAreaController.java
+62
-0
ServiceAddressService.java
...ervice/miniapp/service/address/ServiceAddressService.java
+26
-0
ServiceOrderService.java
...iteservice/miniapp/service/order/ServiceOrderService.java
+5
-1
ServiceAreaService.java
...teservice/miniapp/service/service/ServiceAreaService.java
+48
-0
No files found.
constant/src/main/java/com/onsiteservice/constant/enums/BizCodeEnum.java
View file @
f5b89732
...
...
@@ -14,7 +14,13 @@ public enum BizCodeEnum {
/**
* 订单分组
*/
SERVICE_ORDER_NOT_EXIST
(
"订单不存在"
);
SERVICE_ORDER_NOT_EXIST
(
"订单不存在"
),
/**
* 区域分组
*/
SERVICE_AREA_NOT_EXIST
(
"区域不存在"
);
@Getter
private
String
msg
;
...
...
core/src/main/java/com/onsiteservice/core/exception/ServiceException.java
View file @
f5b89732
package
com
.
onsiteservice
.
core
.
exception
;
import
com.onsiteservice.constant.enums.BizCodeEnum
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -29,6 +30,10 @@ public class ServiceException extends RuntimeException {
super
(
message
);
}
public
ServiceException
(
BizCodeEnum
biz
)
{
super
(
biz
.
getMsg
());
}
/**
* 自定义传入code状态码和异常信息
*/
...
...
dao/src/main/java/com/onsiteservice/dao/mapper/service/ServiceAreaMapper.java
0 → 100644
View file @
f5b89732
package
com
.
onsiteservice
.
dao
.
mapper
.
service
;
import
com.onsiteservice.dao.common.Mapper
;
import
com.onsiteservice.entity.area.ServiceArea
;
public
interface
ServiceAreaMapper
extends
Mapper
<
ServiceArea
>
{
}
\ No newline at end of file
dao/src/main/resources/mapper/service/ServiceAreaMapper.xml
0 → 100644
View file @
f5b89732
<?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=
"com.onsiteservice.dao.mapper.service.ServiceAreaMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.onsiteservice.entity.area.ServiceArea"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"code"
jdbcType=
"VARCHAR"
property=
"code"
/>
<result
column=
"parent_code"
jdbcType=
"VARCHAR"
property=
"parentCode"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"name_path"
jdbcType=
"VARCHAR"
property=
"namePath"
/>
<result
column=
"level"
jdbcType=
"VARCHAR"
property=
"level"
/>
<result
column=
"center"
jdbcType=
"VARCHAR"
property=
"center"
/>
<result
column=
"enabled"
jdbcType=
"BIT"
property=
"enabled"
/>
<result
column=
"modify_time"
jdbcType=
"TIMESTAMP"
property=
"modifyTime"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
</resultMap>
</mapper>
\ No newline at end of file
entity/src/main/java/com/onsiteservice/entity/address/ServiceAddress.java
View file @
f5b89732
...
...
@@ -42,6 +42,18 @@ public class ServiceAddress implements Serializable {
@ApiModelProperty
(
"手机或电话"
)
private
String
phone
;
/**
* 区域id
*/
@ApiModelProperty
(
"区域id"
)
private
Long
areaId
;
/**
* 区域名称路径
*/
@ApiModelProperty
(
"区域名称路径"
)
private
String
namePath
;
/**
* 地址
*/
...
...
entity/src/main/java/com/onsiteservice/entity/area/ServiceArea.java
0 → 100644
View file @
f5b89732
package
com
.
onsiteservice
.
entity
.
area
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.persistence.*
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
@Getter
@Setter
@ToString
@ApiModel
(
"服务区域"
)
@Table
(
name
=
"service_area"
)
public
class
ServiceArea
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
"主键"
)
private
Long
id
;
/**
* 编码
*/
@ApiModelProperty
(
"编码"
)
private
String
code
;
/**
* 父编码
*/
@Column
(
name
=
"parent_code"
)
@ApiModelProperty
(
"父编码"
)
private
String
parentCode
;
/**
* 名称
*/
@ApiModelProperty
(
"名称"
)
private
String
name
;
/**
* 名称路径
*/
@Column
(
name
=
"name_path"
)
@ApiModelProperty
(
"名称路径"
)
private
String
namePath
;
/**
* 市区街道 city district street
*/
@ApiModelProperty
(
"市区街道 city district street"
)
private
String
level
;
/**
* 经度,纬度
*/
@ApiModelProperty
(
"经度,纬度"
)
private
String
center
;
/**
* 是否启用
*/
@ApiModelProperty
(
"是否启用"
)
private
Boolean
enabled
;
/**
* 修改时间
*/
@Column
(
name
=
"modify_time"
)
@ApiModelProperty
(
"修改时间"
)
private
Date
modifyTime
;
/**
* 创建时间
*/
@Column
(
name
=
"create_time"
)
@ApiModelProperty
(
"创建时间"
)
private
Date
createTime
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
entity/src/main/java/com/onsiteservice/entity/order/ServiceOrder.java
View file @
f5b89732
...
...
@@ -24,6 +24,13 @@ public class ServiceOrder implements Serializable {
@ApiModelProperty
(
"主键"
)
private
Long
id
;
/**
* 订单号
*/
@Column
(
name
=
"order_no"
)
@ApiModelProperty
(
"订单号"
)
private
String
orderNo
;
/**
* 账号
*/
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/controller/address/dto/SaveServiceAddressDTO.java
View file @
f5b89732
...
...
@@ -20,6 +20,18 @@ public class SaveServiceAddressDTO {
@ApiModelProperty
(
value
=
"手机或电话"
,
required
=
true
)
private
String
phone
;
/**
* 区域id
*/
@ApiModelProperty
(
value
=
"区域id"
,
required
=
true
)
private
Long
areaId
;
/**
* 区域名称路径
*/
@ApiModelProperty
(
value
=
"区域名称路径"
,
required
=
true
)
private
String
namePath
;
/**
* 地址
*/
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/controller/address/dto/UpdateServiceAddressDTO.java
View file @
f5b89732
...
...
@@ -23,6 +23,18 @@ public class UpdateServiceAddressDTO {
@ApiModelProperty
(
value
=
"手机或电话"
,
required
=
true
)
private
String
phone
;
/**
* 区域id
*/
@ApiModelProperty
(
value
=
"区域id"
,
required
=
true
)
private
Long
areaId
;
/**
* 区域名称路径
*/
@ApiModelProperty
(
value
=
"区域名称路径"
,
required
=
true
)
private
String
namePath
;
/**
* 地址
*/
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/controller/address/vo/ServiceAddressVO.java
View file @
f5b89732
package
com
.
onsiteservice
.
miniapp
.
controller
.
address
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
...
...
@@ -19,6 +20,16 @@ public class ServiceAddressVO {
*/
private
String
phone
;
/**
* 区域id
*/
private
Long
areaId
;
/**
* 区域名称路径
*/
private
String
namePath
;
/**
* 地址
*/
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/controller/order/vo/ServiceOrderVO.java
View file @
f5b89732
...
...
@@ -16,6 +16,8 @@ public class ServiceOrderVO {
private
Long
id
;
private
String
orderNo
;
private
Long
accountNo
;
/**
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/controller/service/ServiceAreaController.java
0 → 100644
View file @
f5b89732
package
com
.
onsiteservice
.
miniapp
.
controller
.
service
;
import
com.onsiteservice.entity.area.ServiceArea
;
import
com.onsiteservice.miniapp.service.service.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/service/address/ServiceAddressService.java
View file @
f5b89732
package
com
.
onsiteservice
.
miniapp
.
service
.
address
;
import
com.onsiteservice.constant.enums.BizCodeEnum
;
import
com.onsiteservice.core.exception.ServiceException
;
import
com.onsiteservice.core.result.Result
;
import
com.onsiteservice.core.result.ResultGenerator
;
import
com.onsiteservice.dao.mapper.service.ServiceAreaMapper
;
import
com.onsiteservice.entity.address.ServiceAddress
;
import
com.onsiteservice.entity.area.ServiceArea
;
import
com.onsiteservice.miniapp.controller.address.dto.PageServiceAddressDTO
;
import
com.onsiteservice.miniapp.controller.address.dto.SaveServiceAddressDTO
;
import
com.onsiteservice.miniapp.controller.address.dto.UpdateServiceAddressDTO
;
...
...
@@ -20,6 +24,7 @@ import tk.mybatis.mapper.entity.Condition;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
static
com
.
onsiteservice
.
core
.
result
.
ResultGenerator
.
success
;
...
...
@@ -28,9 +33,14 @@ import static com.onsiteservice.core.result.ResultGenerator.success;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
ServiceAddressService
extends
AbstractMapper
<
ServiceAddress
>
{
@Resource
private
ServiceAddressBizMapper
serviceAddressBizMapper
;
@Resource
private
ServiceAreaMapper
serviceAreaMapper
;
/**
* 分页查询列表
*/
...
...
@@ -60,6 +70,8 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
public
int
save
(
SaveServiceAddressDTO
dto
,
Long
userId
)
{
checkServiceArea
(
dto
.
getAreaId
());
ServiceAddress
serviceAddress
=
AttrCopyUtils
.
copy
(
dto
,
new
ServiceAddress
());
serviceAddress
.
setAccountNo
(
userId
);
return
this
.
insertSelective
(
serviceAddress
);
...
...
@@ -67,9 +79,23 @@ public class ServiceAddressService extends AbstractMapper<ServiceAddress> {
public
int
update
(
UpdateServiceAddressDTO
dto
)
{
checkServiceArea
(
dto
.
getAreaId
());
ServiceAddress
serviceAddress
=
AttrCopyUtils
.
copy
(
dto
,
new
ServiceAddress
());
return
this
.
updateByPrimaryKey
(
serviceAddress
);
}
/**
* 判断区域存在
*
* @param areaId 区域id
*/
private
void
checkServiceArea
(
long
areaId
){
ServiceArea
serviceArea
=
serviceAreaMapper
.
selectByPrimaryKey
(
areaId
);
if
(
Objects
.
isNull
(
serviceArea
))
{
throw
new
ServiceException
(
BizCodeEnum
.
SERVICE_AREA_NOT_EXIST
);
}
}
}
mini-app/src/main/java/com/onsiteservice/miniapp/service/order/ServiceOrderService.java
View file @
f5b89732
...
...
@@ -16,6 +16,7 @@ import com.onsiteservice.miniapp.controller.order.vo.ServiceOrderVO;
import
com.onsiteservice.miniapp.mapper.order.ServiceOrderBizMapper
;
import
com.onsiteservice.miniapp.service.address.ServiceAddressService
;
import
com.onsiteservice.util.AttrCopyUtils
;
import
com.onsiteservice.util.RandomUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -62,7 +63,10 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
public
int
save
(
SaveServiceOrderDTO
dto
,
Long
uid
)
{
ServiceOrder
serviceOrder
=
AttrCopyUtils
.
copy
(
dto
,
new
ServiceOrder
());
// 账户号
serviceOrder
.
setAccountNo
(
uid
);
// 订单号
serviceOrder
.
setOrderNo
(
RandomUtils
.
orderNum
());
return
this
.
insertSelective
(
serviceOrder
);
}
...
...
@@ -71,7 +75,7 @@ public class ServiceOrderService extends AbstractMapper<ServiceOrder> {
ServiceOrder
serviceOrder
=
this
.
selectByPrimaryKey
(
dto
.
getId
());
// 找不到订单
if
(
Objects
.
isNull
(
serviceOrder
))
{
throw
new
ServiceException
(
BizCodeEnum
.
SERVICE_ORDER_NOT_EXIST
.
getMsg
()
);
throw
new
ServiceException
(
BizCodeEnum
.
SERVICE_ORDER_NOT_EXIST
);
}
// 估价价格
...
...
mini-app/src/main/java/com/onsiteservice/miniapp/service/service/ServiceAreaService.java
0 → 100644
View file @
f5b89732
package
com
.
onsiteservice
.
miniapp
.
service
.
service
;
import
com.onsiteservice.entity.area.ServiceArea
;
import
com.onsiteservice.dao.mapper.service.ServiceAreaMapper
;
import
com.onsiteservice.miniapp.mapper.service.ServiceAreaBizMapper
;
import
com.onsiteservice.dao.common.AbstractMapper
;
import
com.onsiteservice.dao.common.page.PageParams
;
import
com.onsiteservice.dao.common.page.PageInfoVO
;
import
com.github.pagehelper.PageHelper
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
/**
* @author 潘维吉
* @date 2022-07-08 09:11
* @description ServiceAreaService服务类
*/
@Service
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
ServiceAreaService
extends
AbstractMapper
<
ServiceArea
>
{
@Resource
private
ServiceAreaMapper
serviceAreaMapper
;
@Resource
private
ServiceAreaBizMapper
serviceAreaBizMapper
;
/**
* 分页查询列表
*/
public
PageInfoVO
getPage
(
PageParams
param
)
{
PageHelper
.
startPage
(
param
.
getPage
(),
param
.
getSize
());
return
new
PageInfoVO
(
this
.
selectAll
());
}
/**
* 保存或更新方法
*/
public
int
saveOrUpdate
(
ServiceArea
serviceArea
)
{
if
(
serviceArea
.
getId
()
==
null
)
{
return
this
.
insertSelective
(
serviceArea
);
}
else
{
return
this
.
updateByPrimaryKeySelective
(
serviceArea
);
}
}
}
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