Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-store
Overview
Overview
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
base_platform_enterprise
gic-store
Commits
dbce60d6
Commit
dbce60d6
authored
Jul 02, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店分组
parent
d63a956b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
99 additions
and
15 deletions
+99
-15
StoreGroupErrorEnum.java
...main/java/com/gic/store/constant/StoreGroupErrorEnum.java
+2
-1
StoreGroupApiService.java
...main/java/com/gic/store/service/StoreGroupApiService.java
+8
-1
TabStoreGroupMapper.java
...in/java/com/gic/store/dao/mapper/TabStoreGroupMapper.java
+3
-0
StoreGroupApiServiceImpl.java
...com/gic/store/service/outer/StoreGroupApiServiceImpl.java
+54
-8
TabStoreGroupMapper.xml
...service/src/main/resources/mapper/TabStoreGroupMapper.xml
+15
-1
StoreGroupController.java
...va/com/gic/store/web/controller/StoreGroupController.java
+7
-2
StoreGroupQO.java
...in/java/com/gic/store/web/qo/storegroup/StoreGroupQO.java
+10
-2
No files found.
gic-store-api/src/main/java/com/gic/store/constant/StoreGroupErrorEnum.java
View file @
dbce60d6
...
...
@@ -12,7 +12,8 @@ public enum StoreGroupErrorEnum {
ParentStoreGroupParamError
(
"4000"
,
"父级ID参数错误"
),
EditDefaultStoreGroupError
(
"5000"
,
"默认分组:未分组门店,不可编辑"
),
StoreGroupNotExist
(
"6000"
,
"门店分组主键错误,数据未查到"
),
SortError
(
"7000"
,
"排序错误!"
);
SortError
(
"7000"
,
"排序错误!"
),
ParamError
(
"8000"
,
"参数错误"
);
private
String
code
;
private
String
message
;
...
...
gic-store-api/src/main/java/com/gic/store/service/StoreGroupApiService.java
View file @
dbce60d6
...
...
@@ -18,13 +18,20 @@ public interface StoreGroupApiService {
int
save
(
StoreGroupDTO
storeGroupDTO
);
/**
* 更新分组数据
:名称、
* 更新分组数据
* @param storeGroupDTO
* @return
*/
int
update
(
StoreGroupDTO
storeGroupDTO
);
/**
* 编辑名称
* @param storeGroupDTO
* @return
*/
int
updateStoreGroupName
(
StoreGroupDTO
storeGroupDTO
);
/**
* 分组上移下移排序
* @param storeGroupDTO
* @param isUp 是否是上移
...
...
gic-store-service/src/main/java/com/gic/store/dao/mapper/TabStoreGroupMapper.java
View file @
dbce60d6
...
...
@@ -114,4 +114,6 @@ public interface TabStoreGroupMapper {
* @return
*/
int
countByParentId
(
@Param
(
"parentId"
)
Integer
parentId
);
int
isRepeatName
(
@Param
(
"storeGroupName"
)
String
storeGroupName
,
@Param
(
"storeGroupId"
)
Integer
storeGroupId
,
@Param
(
"enterpriseId"
)
Integer
enterpriseId
);
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/service/outer/StoreGroupApiServiceImpl.java
View file @
dbce60d6
...
...
@@ -8,6 +8,8 @@ import com.gic.store.dto.StoreGroupDTO;
import
com.gic.store.entity.TabStoreGroup
;
import
com.gic.store.exception.StoreGroupException
;
import
com.gic.store.service.StoreGroupApiService
;
import
com.gic.store.service.StoreService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -32,8 +34,14 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
@Autowired
private
TabStoreGroupMapper
tabStoreGroupMapper
;
@Autowired
private
StoreService
storeService
;
@Override
public
int
save
(
StoreGroupDTO
storeGroupDTO
)
{
if
(
tabStoreGroupMapper
.
isRepeatName
(
storeGroupDTO
.
getStoreGroupName
(),
null
,
storeGroupDTO
.
getEnterpriseId
())
>
0
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
Error
.
getCode
(),
"名称不能重复"
);
}
int
groupLevel
=
storeGroupDTO
.
getGroupLevel
().
intValue
();
if
(
groupLevel
<
StoreGroupConstant
.
ALL_STORE_LEVEL
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
GroupLevelError
.
getCode
(),
StoreGroupErrorEnum
.
GroupLevelError
.
getMessage
());
...
...
@@ -67,9 +75,11 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
}
//排序值
storeGroupDTO
.
setSort
(
selectStoreGroupMaxSort
(
storeGroupDTO
.
getEnterpriseId
(),
storeGroupDTO
.
getGroupLevel
())
+
1
);
int
storeGroupId
=
tabStoreGroupMapper
.
insert
(
EntityUtil
.
changeEntityNew
(
TabStoreGroup
.
class
,
storeGroupDTO
));
TabStoreGroup
record
=
EntityUtil
.
changeEntityNew
(
TabStoreGroup
.
class
,
storeGroupDTO
);
tabStoreGroupMapper
.
insert
(
record
);
int
storeGroupId
=
record
.
getStoreGroupId
();
//update 分组链
//update 分组链
TabStoreGroup
storeGroupChain
=
new
TabStoreGroup
();
storeGroupChain
.
setUpdateTime
(
new
Date
());
storeGroupChain
.
setStoreGroupId
(
storeGroupId
);
...
...
@@ -77,7 +87,8 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
tabStoreGroupMapper
.
updateByPrimaryKeySelective
(
storeGroupChain
);
if
(
isNeedTransferStore
(
storeGroupDTO
))
{
//todo 调用门店接口
//转移门店
storeService
.
updateGroupId
(
storeGroupDTO
.
getParentStoreGroupId
(),
storeGroupId
);
}
if
(
groupLevel
==
StoreGroupConstant
.
ALL_STORE_LEVEL
)
{
...
...
@@ -94,6 +105,9 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
@Override
public
int
update
(
StoreGroupDTO
storeGroupDTO
)
{
if
(
storeGroupDTO
.
getStoreGroupId
()
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
ParamError
.
getCode
(),
"主键不能为空"
);
}
int
storeGroupId
=
storeGroupDTO
.
getStoreGroupId
();
TabStoreGroup
oldStoreGroup
=
validIsDefault
(
storeGroupId
);
if
(
storeGroupDTO
.
getGroupLevel
()
!=
StoreGroupConstant
.
FIRST_STORE_GROUP_LEVEL
)
{
...
...
@@ -108,6 +122,13 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
//如果修改了上级分组,则该分组下的所有子级分组都需要修改分组链数据
tabStoreGroupMapper
.
updateStoreGroupChainByStoreGroupId
(
storeGroupId
,
oldStoreGroupParentId
,
storeGroupParentId
);
//修改父级ID
TabStoreGroup
tabStoreGroup
=
new
TabStoreGroup
();
tabStoreGroup
.
setStoreGroupId
(
storeGroupDTO
.
getStoreGroupId
());
tabStoreGroup
.
setParentStoreGroupId
(
storeGroupParentId
);
tabStoreGroup
.
setUpdateTime
(
new
Date
());
tabStoreGroupMapper
.
updateByPrimaryKeySelective
(
tabStoreGroup
);
//如果上级分组有门店,则新建一个未分组数据,然后把所有门店放进去
if
(
isNeedTransferStore
(
storeGroupDTO
))
{
StoreGroupDTO
noStoreGroup
=
new
StoreGroupDTO
();
...
...
@@ -116,10 +137,26 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
noStoreGroup
.
setStoreGroupName
(
"未分组门店"
);
noStoreGroup
.
setParentStoreGroupId
(
storeGroupParentId
);
int
noStoreGroupId
=
save
(
noStoreGroup
);
//todo 调用门店接口
//转移门店
storeService
.
updateGroupId
(
storeGroupParentId
,
noStoreGroupId
);
}
}
}
return
SUCCESS
;
}
@Override
public
int
updateStoreGroupName
(
StoreGroupDTO
storeGroupDTO
)
{
if
(
storeGroupDTO
.
getStoreGroupId
()
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
ParamError
.
getCode
(),
"主键不能为空"
);
}
if
(
StringUtils
.
isBlank
(
storeGroupDTO
.
getStoreGroupName
()))
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
ParamError
.
getCode
(),
"名称不能为空"
);
}
validIsDefault
(
storeGroupDTO
.
getStoreGroupId
());
if
(
tabStoreGroupMapper
.
isRepeatName
(
storeGroupDTO
.
getStoreGroupName
(),
storeGroupDTO
.
getStoreGroupId
(),
storeGroupDTO
.
getEnterpriseId
())
>
0
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
Error
.
getCode
(),
"名称不能重复"
);
}
//修改名称
TabStoreGroup
tabStoreGroup
=
new
TabStoreGroup
();
tabStoreGroup
.
setStoreGroupName
(
storeGroupDTO
.
getStoreGroupName
());
...
...
@@ -183,8 +220,9 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
@Override
public
int
remove
(
int
storeGroupId
)
{
//todo 判断该分组是否有门店,如果有,不能删除
if
(
isContainStore
(
storeGroupId
))
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
DeleteError
.
getCode
(),
StoreGroupErrorEnum
.
DeleteError
.
getMessage
());
}
TabStoreGroup
tabStoreGroup
=
new
TabStoreGroup
();
tabStoreGroup
.
setStoreGroupId
(
storeGroupId
);
tabStoreGroup
.
setStatus
(
0
);
...
...
@@ -211,7 +249,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
//所有门店的父级ID是0
groupIds
.
push
(
StoreGroupConstant
.
ALL_STORE_LEVEL
);
//首个字符为下划线_
StringBuilder
resultId
=
new
StringBuilder
(
"
-
"
);
StringBuilder
resultId
=
new
StringBuilder
(
"
_
"
);
while
(!
groupIds
.
empty
())
{
resultId
.
append
(
groupIds
.
pop
());
resultId
.
append
(
"_"
);
...
...
@@ -243,13 +281,21 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
*/
private
boolean
isNeedTransferStore
(
StoreGroupDTO
storeGroupDTO
)
{
int
count
=
tabStoreGroupMapper
.
countByParentId
(
storeGroupDTO
.
getParentStoreGroupId
());
if
(
count
<
1
)
{
if
(
count
<
1
&&
isContainStore
(
storeGroupDTO
.
getStoreGroupId
())
)
{
return
true
;
}
else
{
return
false
;
}
}
private
boolean
isContainStore
(
int
storeGroupId
)
{
Integer
result
=
storeService
.
countByGroupId
(
storeGroupId
);
if
(
result
==
null
||
result
<
1
)
{
return
false
;
}
return
true
;
}
private
List
<
TabStoreGroup
>
listStoreGroupAndChildren
(
int
storeGroupId
,
int
enterpriseId
)
{
TabStoreGroup
param
=
new
TabStoreGroup
();
param
.
setStoreGroupId
(
storeGroupId
);
...
...
gic-store-service/src/main/resources/mapper/TabStoreGroupMapper.xml
View file @
dbce60d6
...
...
@@ -191,7 +191,7 @@
<update
id=
"updateStoreGroupChainByStoreGroupId"
>
UPDATE
tab_store_group
SET store_group_chain = replace(store_group_chain, concat('_', #{fromStoreGroupId}
)
, '_'), concat('_', #{toStoreGroupId}, '_'))
SET store_group_chain = replace(store_group_chain, concat('_', #{fromStoreGroupId}, '_'), concat('_', #{toStoreGroupId}, '_'))
where status = 1 and store_group_chain like concat('%_', #{storeGroupId}, '_%')
</update>
...
...
@@ -228,4 +228,17 @@
from
tab_store_group where status = 1 and parent_store_group_id = #{parentId}
</select>
<select
id=
"isRepeatName"
resultType=
"int"
>
select
count(1)
from
tab_store_group where status = 1
<if
test=
"storeGroupId != null and storeGroupId != '' "
>
and store_group_id
<>
#{storeGroupId}
</if>
and store_group_name = #{storeGroupName}
and enterprise_id = #{enterpriseId}
</select>
</mapper>
\ No newline at end of file
gic-store-web/src/main/java/com/gic/store/web/controller/StoreGroupController.java
View file @
dbce60d6
...
...
@@ -43,8 +43,13 @@ public class StoreGroupController {
return
RestResponse
.
success
(
storeGroupApiService
.
save
(
transferQoToDTO
(
storeGroupQO
)));
}
@RequestMapping
(
"/edit"
)
public
RestResponse
edit
(
@Validated
({
StoreGroupQO
.
SaveValidView
.
class
,
StoreGroupQO
.
RemoveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
@RequestMapping
(
"/edit-store-group-name"
)
public
RestResponse
editName
(
@Validated
({
StoreGroupQO
.
EditNameValidView
.
class
,
StoreGroupQO
.
RemoveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
return
RestResponse
.
success
(
storeGroupApiService
.
updateStoreGroupName
(
transferQoToDTO
(
storeGroupQO
)));
}
@RequestMapping
(
"/edit-parent-store-group-id"
)
public
RestResponse
edit
(
@Validated
({
StoreGroupQO
.
EditParentIdValidView
.
class
,
StoreGroupQO
.
RemoveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
return
RestResponse
.
success
(
storeGroupApiService
.
update
(
transferQoToDTO
(
storeGroupQO
)));
}
...
...
gic-store-web/src/main/java/com/gic/store/web/qo/storegroup/StoreGroupQO.java
View file @
dbce60d6
...
...
@@ -23,6 +23,14 @@ public class StoreGroupQO implements Serializable{
public
interface
RemoveValidView
{
}
public
interface
EditNameValidView
{
}
public
interface
EditParentIdValidView
{
}
/**
*
...
...
@@ -34,7 +42,7 @@ public class StoreGroupQO implements Serializable{
/**
* 分组名称
*/
@NotBlank
(
message
=
"名称不能为空"
,
groups
=
{
SaveValidView
.
class
})
@NotBlank
(
message
=
"名称不能为空"
,
groups
=
{
SaveValidView
.
class
,
EditNameValidView
.
class
})
private
String
storeGroupName
;
/**
...
...
@@ -50,7 +58,7 @@ public class StoreGroupQO implements Serializable{
/**
* 分组层级
*/
@NotNull
(
message
=
"层级不能为空"
,
groups
=
{
SaveValidView
.
class
})
@NotNull
(
message
=
"层级不能为空"
,
groups
=
{
SaveValidView
.
class
,
EditParentIdValidView
.
class
})
private
Integer
groupLevel
;
/**
...
...
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