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
86a59c3e
Commit
86a59c3e
authored
Jun 27, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店分组
parent
e376c7d7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
23 deletions
+60
-23
StoreGroupConstant.java
.../main/java/com/gic/store/constant/StoreGroupConstant.java
+9
-0
StoreGroupErrorEnum.java
...main/java/com/gic/store/constant/StoreGroupErrorEnum.java
+3
-1
StoreGroupApiService.java
...main/java/com/gic/store/service/StoreGroupApiService.java
+7
-0
TabStoreGroupMapper.java
...in/java/com/gic/store/dao/mapper/TabStoreGroupMapper.java
+3
-2
StoreGroupApiServiceImpl.java
...com/gic/store/service/outer/StoreGroupApiServiceImpl.java
+23
-3
TabStoreGroupMapper.xml
...service/src/main/resources/mapper/TabStoreGroupMapper.xml
+3
-3
StoreGroupController.java
...va/com/gic/store/web/controller/StoreGroupController.java
+12
-14
No files found.
gic-store-api/src/main/java/com/gic/store/constant/StoreGroupConstant.java
View file @
86a59c3e
...
...
@@ -26,6 +26,15 @@ public class StoreGroupConstant {
*/
public
final
static
int
SORT_DOWN
=
2
;
/**
* 是否是默认门店,初始化品牌的时候会建立一条默认门店:未分组门店,不可编辑,1:是 0:否
*/
public
final
static
int
IS_DEFAULT
=
1
;
public
final
static
int
TEST_ENTERPRISE_ID
=
10000
;
...
...
gic-store-api/src/main/java/com/gic/store/constant/StoreGroupErrorEnum.java
View file @
86a59c3e
...
...
@@ -9,7 +9,9 @@ public enum StoreGroupErrorEnum {
DeleteError
(
"1000"
,
"该分组下存在门店,不能删除"
),
GroupLevelError
(
"2000"
,
"分组层级参数数据错误"
),
AllStoreGroupError
(
"3000"
,
"所有门店已存在"
),
ParentStoreGroupParamError
(
"4000"
,
"父级ID参数错误"
);
ParentStoreGroupParamError
(
"4000"
,
"父级ID参数错误"
),
EditDefaultStoreGroupError
(
"5000"
,
"默认分组:未分组门店,不可编辑"
),
StoreGroupNotExist
(
"6000"
,
"门店分组主键错误,数据未查到"
);
private
String
code
;
private
String
message
;
...
...
gic-store-api/src/main/java/com/gic/store/service/StoreGroupApiService.java
View file @
86a59c3e
...
...
@@ -45,4 +45,11 @@ public interface StoreGroupApiService {
* @return
*/
int
remove
(
int
storeGroupId
);
/**
* 初始化品牌调用:新建所有门店
* @param enterpriseId
* @return
*/
int
insertDefaultStoreGroup
(
int
enterpriseId
);
}
gic-store-service/src/main/java/com/gic/store/dao/mapper/TabStoreGroupMapper.java
View file @
86a59c3e
...
...
@@ -106,12 +106,12 @@ public interface TabStoreGroupMapper {
* @param groupLevel
* @return
*/
TabStoreGroup
selectAllStoreGroup
(
Integer
enterpriseId
,
Integer
groupLevel
);
TabStoreGroup
selectAllStoreGroup
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"groupLevel"
)
Integer
groupLevel
);
/**
* 根据父级ID,统计下面是否有子节点
* @param parentId
* @return
*/
int
countByParentId
(
Integer
parentId
);
int
countByParentId
(
@Param
(
"parentId"
)
Integer
parentId
);
}
\ No newline at end of file
gic-store-service/src/main/java/com/gic/store/service/outer/StoreGroupApiServiceImpl.java
View file @
86a59c3e
...
...
@@ -80,6 +80,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
noStoreGroup
.
setEnterpriseId
(
storeGroupDTO
.
getEnterpriseId
());
noStoreGroup
.
setGroupLevel
(
StoreGroupConstant
.
FIRST_STORE_GROUP_LEVEL
);
noStoreGroup
.
setStoreGroupName
(
"未分组门店"
);
noStoreGroup
.
setIsDefault
(
1
);
save
(
noStoreGroup
);
}
return
storeGroupId
;
...
...
@@ -87,14 +88,21 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
@Override
public
int
update
(
StoreGroupDTO
storeGroupDTO
)
{
int
storeGroupId
=
storeGroupDTO
.
getStoreGroupId
();
TabStoreGroup
oldStoreGroup
=
tabStoreGroupMapper
.
selectByPrimaryKey
(
storeGroupId
);
if
(
oldStoreGroup
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
StoreGroupNotExist
.
getCode
(),
StoreGroupErrorEnum
.
StoreGroupNotExist
.
getMessage
());
}
boolean
isDefault
=
oldStoreGroup
.
getIsDefault
()
==
StoreGroupConstant
.
IS_DEFAULT
;
if
(
isDefault
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
EditDefaultStoreGroupError
.
getCode
(),
StoreGroupErrorEnum
.
EditDefaultStoreGroupError
.
getMessage
());
}
if
(
storeGroupDTO
.
getGroupLevel
()
!=
StoreGroupConstant
.
FIRST_STORE_GROUP_LEVEL
)
{
//如果不是第一级,则可能有上级分组修改
if
(
storeGroupDTO
.
getParentStoreGroupId
()
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
ParentStoreGroupParamError
.
getCode
(),
StoreGroupErrorEnum
.
ParentStoreGroupParamError
.
getMessage
());
}
int
storeGroupParentId
=
storeGroupDTO
.
getParentStoreGroupId
();
int
storeGroupId
=
storeGroupDTO
.
getStoreGroupId
();
TabStoreGroup
oldStoreGroup
=
tabStoreGroupMapper
.
selectByPrimaryKey
(
storeGroupId
);
int
oldStoreGroupParentId
=
oldStoreGroup
.
getParentStoreGroupId
();
boolean
hasEditParentId
=
storeGroupParentId
!=
oldStoreGroupParentId
;
if
(
hasEditParentId
)
{
...
...
@@ -160,7 +168,9 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
tabStoreGroupList
.
addAll
(
listStoreGroupByLevelAndName
(
storeGroupDTO
.
getGroupLevel
(),
storeGroupDTO
.
getEnterpriseId
(),
storeGroupDTO
.
getStoreGroupName
()));
}
else
{
//查询全部
tabStoreGroupList
.
addAll
(
tabStoreGroupMapper
.
listStoreGroup
(
new
TabStoreGroup
()));
TabStoreGroup
selectAll
=
new
TabStoreGroup
();
selectAll
.
setEnterpriseId
(
storeGroupDTO
.
getEnterpriseId
());
tabStoreGroupList
.
addAll
(
tabStoreGroupMapper
.
listStoreGroup
(
selectAll
));
}
return
EntityUtil
.
changeEntityListNew
(
StoreGroupDTO
.
class
,
tabStoreGroupList
);
...
...
@@ -176,6 +186,16 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
return
tabStoreGroupMapper
.
updateByPrimaryKeySelective
(
tabStoreGroup
);
}
@Override
public
int
insertDefaultStoreGroup
(
int
enterpriseId
)
{
StoreGroupDTO
noStoreGroup
=
new
StoreGroupDTO
();
noStoreGroup
.
setEnterpriseId
(
enterpriseId
);
noStoreGroup
.
setGroupLevel
(
StoreGroupConstant
.
ALL_STORE_LEVEL
);
noStoreGroup
.
setStoreGroupName
(
"所有门店"
);
noStoreGroup
.
setIsDefault
(
StoreGroupConstant
.
IS_DEFAULT
);
return
save
(
noStoreGroup
);
}
private
int
selectStoreGroupMaxSort
(
Integer
enterpriseId
,
Integer
groupLevel
)
{
return
tabStoreGroupMapper
.
selectStoreGroupMaxSort
(
enterpriseId
,
groupLevel
);
}
...
...
gic-store-service/src/main/resources/mapper/TabStoreGroupMapper.xml
View file @
86a59c3e
...
...
@@ -180,9 +180,9 @@
</select>
<select
id=
"selectStoreGroupMaxSort"
result
Map=
"BaseResultMap
"
>
<select
id=
"selectStoreGroupMaxSort"
result
Type=
"int
"
>
select
ifnull(max
(sort), 0)
IFNULL(MAX
(sort), 0)
from
tab_store_group where status = 1 and enterprise_id = #{enterpriseId} and group_level = #{groupLevel}
</select>
...
...
@@ -222,7 +222,7 @@
limit 1
</select>
<select
id=
"countByParentId"
result
Map=
"BaseResultMap
"
>
<select
id=
"countByParentId"
result
Type=
"int
"
>
select
count(1)
from
...
...
gic-store-web/src/main/java/com/gic/store/web/controller/StoreGroupController.java
View file @
86a59c3e
...
...
@@ -29,37 +29,29 @@ public class StoreGroupController {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
StoreGroupController
.
class
);
private
static
final
int
ENTERPRISE_ID
=
10000
;
@Autowired
private
StoreGroupApiService
storeGroupApiService
;
@RequestMapping
(
"/list"
)
public
RestResponse
listStoreGroup
(
StoreGroupQO
storeGroupQO
)
{
StoreGroupDTO
storeGroupDTO
=
EntityUtil
.
changeEntityNew
(
StoreGroupDTO
.
class
,
storeGroupQO
);
List
<
StoreGroupDTO
>
list
=
storeGroupApiService
.
listStoreGroup
(
storeGroupDTO
);
List
<
StoreGroupDTO
>
list
=
storeGroupApiService
.
listStoreGroup
(
transferQoToDTO
(
storeGroupQO
));
return
RestResponse
.
success
(
changeListToTree
(
StoreGroupConstant
.
ALL_STORE_LEVEL
,
list
));
}
@RequestMapping
(
"/save"
)
public
RestResponse
save
(
@Validated
({
StoreGroupQO
.
SaveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
StoreGroupDTO
storeGroupDTO
=
EntityUtil
.
changeEntityNew
(
StoreGroupDTO
.
class
,
storeGroupQO
);
storeGroupDTO
.
setEnterpriseId
(
ENTERPRISE_ID
);
return
RestResponse
.
success
(
storeGroupApiService
.
save
(
storeGroupDTO
));
storeGroupQO
.
setIsDefault
(
0
);
return
RestResponse
.
success
(
storeGroupApiService
.
save
(
transferQoToDTO
(
storeGroupQO
)));
}
@RequestMapping
(
"/edit"
)
public
RestResponse
edit
(
@Validated
({
StoreGroupQO
.
SaveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
StoreGroupDTO
storeGroupDTO
=
EntityUtil
.
changeEntityNew
(
StoreGroupDTO
.
class
,
storeGroupQO
);
storeGroupDTO
.
setEnterpriseId
(
ENTERPRISE_ID
);
return
RestResponse
.
success
(
storeGroupApiService
.
update
(
storeGroupDTO
));
public
RestResponse
edit
(
@Validated
({
StoreGroupQO
.
SaveValidView
.
class
,
StoreGroupQO
.
RemoveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
return
RestResponse
.
success
(
storeGroupApiService
.
update
(
transferQoToDTO
(
storeGroupQO
)));
}
@RequestMapping
(
"/sort"
)
public
RestResponse
sort
(
@Validated
({
StoreGroupQO
.
SortValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
StoreGroupDTO
storeGroupDTO
=
EntityUtil
.
changeEntityNew
(
StoreGroupDTO
.
class
,
storeGroupQO
);
storeGroupDTO
.
setEnterpriseId
(
ENTERPRISE_ID
);
return
RestResponse
.
success
(
storeGroupApiService
.
sort
(
storeGroupDTO
,
storeGroupQO
.
isUp
()));
return
RestResponse
.
success
(
storeGroupApiService
.
sort
(
transferQoToDTO
(
storeGroupQO
),
storeGroupQO
.
isUp
()));
}
@RequestMapping
(
"/remove"
)
...
...
@@ -87,4 +79,10 @@ public class StoreGroupController {
}
return
result
;
}
private
StoreGroupDTO
transferQoToDTO
(
StoreGroupQO
storeGroupQO
)
{
StoreGroupDTO
storeGroupDTO
=
EntityUtil
.
changeEntityNew
(
StoreGroupDTO
.
class
,
storeGroupQO
);
storeGroupDTO
.
setEnterpriseId
(
StoreGroupConstant
.
TEST_ENTERPRISE_ID
);
return
storeGroupDTO
;
}
}
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