Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
OSmall
/
linjiashop
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 92caea32
authored
Jan 22, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改删除banner逻辑
1 parent
4513c5f7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
shop-core/src/main/java/com/glsx/shop/bean/entity/shop/CategoryBannerRel.java
shop-core/src/main/java/com/glsx/shop/dao/shop/CategoryBannerRelRepository.java
shop-core/src/main/java/com/glsx/shop/service/cms/BannerService.java
shop-core/src/main/java/com/glsx/shop/service/shop/CategoryService.java
shop-core/src/main/java/com/glsx/shop/bean/entity/shop/CategoryBannerRel.java
View file @
92caea3
...
@@ -12,6 +12,7 @@ import com.glsx.shop.bean.entity.BaseEntity;
...
@@ -12,6 +12,7 @@ import com.glsx.shop.bean.entity.BaseEntity;
import
com.glsx.shop.bean.entity.cms.Banner
;
import
com.glsx.shop.bean.entity.cms.Banner
;
import
lombok.Data
;
import
lombok.Data
;
import
org.hibernate.annotations.NotFound
;
import
org.hibernate.annotations.NotFound
;
import
org.hibernate.annotations.NotFoundAction
;
import
org.hibernate.annotations.Table
;
import
org.hibernate.annotations.Table
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
import
org.springframework.data.jpa.domain.support.AuditingEntityListener
;
...
@@ -30,10 +31,10 @@ public class CategoryBannerRel extends BaseEntity {
...
@@ -30,10 +31,10 @@ public class CategoryBannerRel extends BaseEntity {
private
Long
idBanner
;
private
Long
idBanner
;
@JoinColumn
(
name
=
"id_category"
,
insertable
=
false
,
updatable
=
false
,
foreignKey
=
@ForeignKey
(
name
=
"none"
,
value
=
ConstraintMode
.
NO_CONSTRAINT
))
@JoinColumn
(
name
=
"id_category"
,
insertable
=
false
,
updatable
=
false
,
foreignKey
=
@ForeignKey
(
name
=
"none"
,
value
=
ConstraintMode
.
NO_CONSTRAINT
))
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@NotFound
@NotFound
(
action
=
NotFoundAction
.
IGNORE
)
private
Category
category
;
private
Category
category
;
@JoinColumn
(
name
=
"id_banner"
,
insertable
=
false
,
updatable
=
false
,
foreignKey
=
@ForeignKey
(
name
=
"none"
,
value
=
ConstraintMode
.
NO_CONSTRAINT
))
@JoinColumn
(
name
=
"id_banner"
,
insertable
=
false
,
updatable
=
false
,
foreignKey
=
@ForeignKey
(
name
=
"none"
,
value
=
ConstraintMode
.
NO_CONSTRAINT
))
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@ManyToOne
(
fetch
=
FetchType
.
LAZY
)
@NotFound
(
action
=
NotFoundAction
.
IGNORE
)
private
Banner
banner
;
private
Banner
banner
;
}
}
shop-core/src/main/java/com/glsx/shop/dao/shop/CategoryBannerRelRepository.java
View file @
92caea3
...
@@ -6,6 +6,7 @@ import com.glsx.shop.dao.BaseRepository;
...
@@ -6,6 +6,7 @@ import com.glsx.shop.dao.BaseRepository;
public
interface
CategoryBannerRelRepository
extends
BaseRepository
<
CategoryBannerRel
,
Long
>
{
public
interface
CategoryBannerRelRepository
extends
BaseRepository
<
CategoryBannerRel
,
Long
>
{
void
deleteByIdCategory
(
Long
idCategory
);
void
deleteByIdBanner
(
Long
idBanner
);
void
deleteByIdBanner
(
Long
idBanner
);
}
}
shop-core/src/main/java/com/glsx/shop/service/cms/BannerService.java
View file @
92caea3
...
@@ -36,7 +36,7 @@ public class BannerService extends BaseService<Banner, Long, BannerRepository> {
...
@@ -36,7 +36,7 @@ public class BannerService extends BaseService<Banner, Long, BannerRepository> {
}
}
@Transactional
@Transactional
public
void
deleteB
yBannerId
(
Long
bannerId
)
{
public
void
deleteB
anner
(
Long
bannerId
)
{
this
.
bannerRepository
.
deleteById
(
bannerId
);
this
.
bannerRepository
.
deleteById
(
bannerId
);
this
.
categoryBannerRelRepository
.
deleteByIdBanner
(
bannerId
);
this
.
categoryBannerRelRepository
.
deleteByIdBanner
(
bannerId
);
}
}
...
...
shop-core/src/main/java/com/glsx/shop/service/shop/CategoryService.java
View file @
92caea3
...
@@ -2,12 +2,14 @@ package com.glsx.shop.service.shop;
...
@@ -2,12 +2,14 @@ package com.glsx.shop.service.shop;
import
com.glsx.shop.bean.entity.shop.Category
;
import
com.glsx.shop.bean.entity.shop.Category
;
import
com.glsx.shop.dao.shop.CategoryBannerRelRepository
;
import
com.glsx.shop.dao.shop.CategoryRepository
;
import
com.glsx.shop.dao.shop.CategoryRepository
;
import
com.glsx.shop.service.BaseService
;
import
com.glsx.shop.service.BaseService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
@Service
public
class
CategoryService
extends
BaseService
<
Category
,
Long
,
CategoryRepository
>
{
public
class
CategoryService
extends
BaseService
<
Category
,
Long
,
CategoryRepository
>
{
...
@@ -15,5 +17,12 @@ public class CategoryService extends BaseService<Category, Long, CategoryReposit
...
@@ -15,5 +17,12 @@ public class CategoryService extends BaseService<Category, Long, CategoryReposit
@Autowired
@Autowired
private
CategoryRepository
categoryRepository
;
private
CategoryRepository
categoryRepository
;
}
@Autowired
private
CategoryBannerRelRepository
categoryBannerRelRepository
;
@Transactional
public
void
deleteCategory
(
Long
categoryId
)
{
this
.
categoryRepository
.
deleteById
(
categoryId
);
this
.
categoryBannerRelRepository
.
deleteByIdCategory
(
categoryId
);
}
}
Write
Preview
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