Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
lirenhao
/
task-center
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
1a4c983f
authored
2022-09-14 15:49:04 +0800
by
李仁豪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[feat] 店铺增删改查接口
1 parent
7cec7e07
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
169 additions
and
7 deletions
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/application/impl/ShopServiceImpl.java
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/common/dto/ShopDTO.java
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/converter/mapper/ShopConverter.java
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/persistence/dao/ShopDao.java
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/persistence/dao/impl/ShopDaoImpl.java
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/persistence/mapper/ShopMapper.java
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/application/impl/ShopServiceImpl.java
View file @
1a4c983
...
...
@@ -3,11 +3,21 @@ package com.ql.backend.ploycenter.application.impl;
import
com.ql.backend.core.interfaces.vo.PageVO
;
import
com.ql.backend.ploycenter.application.ShopService
;
import
com.ql.backend.ploycenter.domain.condition.ShopCondition
;
import
com.ql.backend.ploycenter.domain.po.ShopPO
;
import
com.ql.backend.ploycenter.infrastructure.converter.mapper.ShopConverter
;
import
com.ql.backend.ploycenter.infrastructure.persistence.dao.ShopDao
;
import
com.ql.backend.ploycenter.interfaces.request.ShopCreateRequest
;
import
com.ql.backend.ploycenter.interfaces.request.ShopUpdateRequest
;
import
com.ql.backend.ploycenter.interfaces.vo.ShopVO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.ObjectUtils
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
/**
* @author lirenhao
...
...
@@ -17,26 +27,56 @@ import org.springframework.stereotype.Service;
@Service
public
class
ShopServiceImpl
implements
ShopService
{
@Resource
private
ShopDao
shopDao
;
@Override
@Transactional
public
String
createShop
(
ShopCreateRequest
request
)
{
/* todo 创建店铺 */
return
null
;
ShopPO
po
=
ShopConverter
.
INSTANCE
.
convertRequest2Po
(
request
);
po
.
setShopId
(
UUID
.
randomUUID
().
toString
());
po
.
setGmtCreated
(
new
Date
());
po
.
setGmtModified
(
new
Date
());
po
.
setIsDeleted
(
Boolean
.
FALSE
);
shopDao
.
save
(
po
);
if
(!
ObjectUtils
.
isEmpty
(
request
.
getBindPloyId
()))
{
/* todo 绑定策略 */
}
return
po
.
getShopId
();
}
@Override
@Transactional
public
void
updateShop
(
String
id
,
ShopUpdateRequest
request
)
{
/* todo 更新店铺信息 */
ShopPO
po
=
ShopConverter
.
INSTANCE
.
convertRequest2Po
(
request
);
po
.
setShopId
(
id
);
po
.
setGmtModified
(
new
Date
());
shopDao
.
updateById
(
po
);
if
(!
ObjectUtils
.
isEmpty
(
request
.
getBindPloyId
()))
{
/* todo 绑定策略 */
}
}
@Override
public
PageVO
<
ShopVO
>
findShop
(
ShopCondition
condition
)
{
/* todo 查询店铺列表 */
return
null
;
long
total
=
shopDao
.
countByCondition
(
condition
);
List
<
ShopPO
>
list
=
shopDao
.
listByCondition
(
condition
);
return
PageVO
.<
ShopVO
>
builder
()
.
page
(
condition
.
getPage
())
.
size
(
condition
.
getSize
())
.
total
(
total
)
.
list
(
ShopConverter
.
INSTANCE
.
convertPo2Vo
(
list
))
.
build
();
}
@Override
public
ShopVO
getShop
(
String
id
)
{
/* todo 查询店铺详情 */
return
null
;
ShopPO
po
=
shopDao
.
getShopById
(
id
);
ShopVO
vo
=
ShopConverter
.
INSTANCE
.
convertPo2Vo
(
po
);
/* todo 查询策略详情, 并查询绑定的店铺信息 */
return
vo
;
}
}
...
...
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/common/dto/ShopDTO.java
0 → 100644
View file @
1a4c983
package
com
.
ql
.
backend
.
ploycenter
.
common
.
dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @author lirenhao
* date: 2022/9/14 15:33
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
ShopDTO
{
private
String
shopId
;
}
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/converter/mapper/ShopConverter.java
0 → 100644
View file @
1a4c983
package
com
.
ql
.
backend
.
ploycenter
.
infrastructure
.
converter
.
mapper
;
import
com.ql.backend.ploycenter.common.dto.ShopDTO
;
import
com.ql.backend.ploycenter.domain.po.ShopPO
;
import
com.ql.backend.ploycenter.interfaces.request.ShopCreateRequest
;
import
com.ql.backend.ploycenter.interfaces.request.ShopUpdateRequest
;
import
com.ql.backend.ploycenter.interfaces.vo.ShopVO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.NullValueCheckStrategy
;
import
org.mapstruct.NullValuePropertyMappingStrategy
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.factory.Mappers
;
import
java.util.List
;
/**
* @author lirenhao
* date: 2022/9/5 17:45
*/
@Mapper
(
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
,
nullValuePropertyMappingStrategy
=
NullValuePropertyMappingStrategy
.
IGNORE
,
nullValueCheckStrategy
=
NullValueCheckStrategy
.
ALWAYS
)
public
interface
ShopConverter
extends
CommonConverter
<
ShopPO
,
ShopDTO
,
ShopVO
>
{
ShopConverter
INSTANCE
=
Mappers
.
getMapper
(
ShopConverter
.
class
);
ShopPO
convertRequest2Po
(
ShopCreateRequest
request
);
ShopPO
convertRequest2Po
(
ShopUpdateRequest
request
);
List
<
ShopVO
>
convertPo2Vo
(
List
<
ShopPO
>
pos
);
ShopVO
convertPo2Vo
(
ShopPO
po
);
}
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/persistence/dao/ShopDao.java
0 → 100644
View file @
1a4c983
package
com
.
ql
.
backend
.
ploycenter
.
infrastructure
.
persistence
.
dao
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.ql.backend.ploycenter.domain.condition.ShopCondition
;
import
com.ql.backend.ploycenter.domain.po.ShopPO
;
import
java.util.List
;
/**
* @author lirenhao
* date: 2022/9/14 15:29
*/
public
interface
ShopDao
extends
IService
<
ShopPO
>
{
ShopPO
getShopById
(
String
id
);
long
countByCondition
(
ShopCondition
condition
);
List
<
ShopPO
>
listByCondition
(
ShopCondition
condition
);
}
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/persistence/dao/impl/ShopDaoImpl.java
0 → 100644
View file @
1a4c983
package
com
.
ql
.
backend
.
ploycenter
.
infrastructure
.
persistence
.
dao
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.ql.backend.ploycenter.domain.condition.ShopCondition
;
import
com.ql.backend.ploycenter.domain.po.ShopPO
;
import
com.ql.backend.ploycenter.infrastructure.persistence.dao.ShopDao
;
import
com.ql.backend.ploycenter.infrastructure.persistence.mapper.ShopMapper
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author lirenhao
* date: 2022/9/14 15:30
*/
@Service
public
class
ShopDaoImpl
extends
ServiceImpl
<
ShopMapper
,
ShopPO
>
implements
ShopDao
{
@Override
public
ShopPO
getShopById
(
String
id
)
{
LambdaQueryWrapper
<
ShopPO
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
ShopPO:
:
getShopId
,
id
);
return
this
.
baseMapper
.
selectOne
(
wrapper
);
}
@Override
public
long
countByCondition
(
ShopCondition
condition
)
{
LambdaQueryWrapper
<
ShopPO
>
wrapper
=
new
LambdaQueryWrapper
<>();
return
count
(
wrapper
);
}
@Override
public
List
<
ShopPO
>
listByCondition
(
ShopCondition
condition
)
{
LambdaQueryWrapper
<
ShopPO
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
last
(
"LIMIT "
+
(
condition
.
getPage
()
*
condition
.
getSize
())
+
", "
+
condition
.
getSize
());
return
this
.
list
(
wrapper
);
}
}
ql-backend-ploycenter/src/main/java/com/ql/backend/ploycenter/infrastructure/persistence/mapper/ShopMapper.java
0 → 100644
View file @
1a4c983
package
com
.
ql
.
backend
.
ploycenter
.
infrastructure
.
persistence
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.ql.backend.ploycenter.domain.po.ShopPO
;
/**
* @author lirenhao
* date: 2022/9/14 15:29
*/
public
interface
ShopMapper
extends
BaseMapper
<
ShopPO
>
{
}
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment