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
373d4388
Commit
373d4388
authored
Jun 28, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店分组
parent
86a59c3e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
16 deletions
+34
-16
StoreGroupErrorEnum.java
...main/java/com/gic/store/constant/StoreGroupErrorEnum.java
+2
-1
StoreGroupApiServiceImpl.java
...com/gic/store/service/outer/StoreGroupApiServiceImpl.java
+28
-10
TabStoreGroupMapper.xml
...service/src/main/resources/mapper/TabStoreGroupMapper.xml
+2
-2
StoreGroupController.java
...va/com/gic/store/web/controller/StoreGroupController.java
+0
-1
StoreGroupQO.java
...in/java/com/gic/store/web/qo/storegroup/StoreGroupQO.java
+2
-2
No files found.
gic-store-api/src/main/java/com/gic/store/constant/StoreGroupErrorEnum.java
View file @
373d4388
...
...
@@ -11,7 +11,8 @@ public enum StoreGroupErrorEnum {
AllStoreGroupError
(
"3000"
,
"所有门店已存在"
),
ParentStoreGroupParamError
(
"4000"
,
"父级ID参数错误"
),
EditDefaultStoreGroupError
(
"5000"
,
"默认分组:未分组门店,不可编辑"
),
StoreGroupNotExist
(
"6000"
,
"门店分组主键错误,数据未查到"
);
StoreGroupNotExist
(
"6000"
,
"门店分组主键错误,数据未查到"
),
SortError
(
"7000"
,
"排序错误!"
);
private
String
code
;
private
String
message
;
...
...
gic-store-service/src/main/java/com/gic/store/service/outer/StoreGroupApiServiceImpl.java
View file @
373d4388
...
...
@@ -45,8 +45,7 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
AllStoreGroupError
.
getCode
(),
StoreGroupErrorEnum
.
AllStoreGroupError
.
getMessage
());
}
storeGroupDTO
.
setParentStoreGroupId
(
StoreGroupConstant
.
ALL_STORE_LEVEL
);
}
if
(
groupLevel
==
StoreGroupConstant
.
FIRST_STORE_GROUP_LEVEL
)
{
}
else
if
(
groupLevel
==
StoreGroupConstant
.
FIRST_STORE_GROUP_LEVEL
)
{
//如果是第一级,则父级ID取所有门店,所有门店在初始化品牌的时候创建
TabStoreGroup
allStoreGroup
=
tabStoreGroupMapper
.
selectAllStoreGroup
(
storeGroupDTO
.
getEnterpriseId
(),
StoreGroupConstant
.
ALL_STORE_LEVEL
);
storeGroupDTO
.
setParentStoreGroupId
(
allStoreGroup
.
getStoreGroupId
());
...
...
@@ -54,11 +53,15 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
if
(
storeGroupDTO
.
getParentStoreGroupId
()
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
ParentStoreGroupParamError
.
getCode
(),
StoreGroupErrorEnum
.
ParentStoreGroupParamError
.
getMessage
());
}
validIsDefault
(
storeGroupDTO
.
getParentStoreGroupId
());
}
storeGroupDTO
.
setCreateTime
(
new
Date
());
storeGroupDTO
.
setUpdateTime
(
new
Date
());
storeGroupDTO
.
setStatus
(
1
);
if
(
storeGroupDTO
.
getIsDefault
()
==
null
)
{
storeGroupDTO
.
setIsDefault
(
0
);
}
//排序值
storeGroupDTO
.
setSort
(
selectStoreGroupMaxSort
(
storeGroupDTO
.
getEnterpriseId
(),
storeGroupDTO
.
getGroupLevel
())
+
1
);
int
storeGroupId
=
tabStoreGroupMapper
.
insert
(
EntityUtil
.
changeEntityNew
(
TabStoreGroup
.
class
,
storeGroupDTO
));
...
...
@@ -89,14 +92,7 @@ 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
());
}
TabStoreGroup
oldStoreGroup
=
validIsDefault
(
storeGroupId
);
if
(
storeGroupDTO
.
getGroupLevel
()
!=
StoreGroupConstant
.
FIRST_STORE_GROUP_LEVEL
)
{
//如果不是第一级,则可能有上级分组修改
if
(
storeGroupDTO
.
getParentStoreGroupId
()
==
null
)
{
...
...
@@ -140,8 +136,14 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
TabStoreGroup
needUpdateSortStoreGroup
;
if
(
isUp
)
{
needUpdateSortStoreGroup
=
tabStoreGroupMapper
.
getStoreGroupWhenMaxSort
(
enterpriseId
,
groupLevel
,
sort
);
if
(
needUpdateSortStoreGroup
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
SortError
.
getCode
(),
"已经是第一条,不能上移"
);
}
}
else
{
needUpdateSortStoreGroup
=
tabStoreGroupMapper
.
getStoreGroupWhenMinSort
(
enterpriseId
,
groupLevel
,
sort
);
if
(
needUpdateSortStoreGroup
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
SortError
.
getCode
(),
"已经是最后一条,不能下移"
);
}
}
updateSort
(
needUpdateSortStoreGroup
.
getStoreGroupId
(),
sort
);
updateSort
(
storeGroupDTO
.
getStoreGroupId
(),
needUpdateSortStoreGroup
.
getSort
());
...
...
@@ -271,4 +273,20 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
List
<
TabStoreGroup
>
tabStoreGroupList
=
tabStoreGroupMapper
.
listStoreGroup
(
param
);
return
tabStoreGroupList
;
}
/**
* 如果是默认门店,不可编辑
* @param storeGroupId
*/
private
TabStoreGroup
validIsDefault
(
int
storeGroupId
)
{
TabStoreGroup
storeGroup
=
tabStoreGroupMapper
.
selectByPrimaryKey
(
storeGroupId
);
if
(
storeGroup
==
null
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
StoreGroupNotExist
.
getCode
(),
StoreGroupErrorEnum
.
StoreGroupNotExist
.
getMessage
());
}
boolean
isDefault
=
storeGroup
.
getIsDefault
()
==
StoreGroupConstant
.
IS_DEFAULT
;
if
(
isDefault
)
{
throw
new
StoreGroupException
(
StoreGroupErrorEnum
.
EditDefaultStoreGroupError
.
getCode
(),
StoreGroupErrorEnum
.
EditDefaultStoreGroupError
.
getMessage
());
}
return
storeGroup
;
}
}
gic-store-service/src/main/resources/mapper/TabStoreGroupMapper.xml
View file @
373d4388
...
...
@@ -199,7 +199,7 @@
select
<include
refid=
"Base_Column_List"
/>
from
tab_store_group where status = 1 and enterprise_id = #{enterpriseId} and group_level = #{groupLevel} and sort > #{sort}
tab_store_group where status = 1 and enterprise_id = #{enterpriseId} and group_level = #{groupLevel} and sort > #{sort}
and is_default = 0
order by sort
limit 1
</select>
...
...
@@ -209,7 +209,7 @@
select
<include
refid=
"Base_Column_List"
/>
from
tab_store_group where status = 1 and enterprise_id = #{enterpriseId} and group_level = #{groupLevel} and sort
<
#{sort}
tab_store_group where status = 1 and enterprise_id = #{enterpriseId} and group_level = #{groupLevel} and sort
<
#{sort}
and is_default = 0
order by sort desc
limit 1
</select>
...
...
gic-store-web/src/main/java/com/gic/store/web/controller/StoreGroupController.java
View file @
373d4388
...
...
@@ -40,7 +40,6 @@ public class StoreGroupController {
@RequestMapping
(
"/save"
)
public
RestResponse
save
(
@Validated
({
StoreGroupQO
.
SaveValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
storeGroupQO
.
setIsDefault
(
0
);
return
RestResponse
.
success
(
storeGroupApiService
.
save
(
transferQoToDTO
(
storeGroupQO
)));
}
...
...
gic-store-web/src/main/java/com/gic/store/web/qo/storegroup/StoreGroupQO.java
View file @
373d4388
...
...
@@ -28,13 +28,13 @@ public class StoreGroupQO implements Serializable{
*
*
*/
@NotNull
(
message
=
"门店分组ID不能为空"
,
groups
=
{
RemoveValidView
.
class
})
@NotNull
(
message
=
"门店分组ID不能为空"
,
groups
=
{
RemoveValidView
.
class
,
SortValidView
.
class
})
private
Integer
storeGroupId
;
/**
* 分组名称
*/
@NotBlank
(
message
=
"名称不能为空"
,
groups
=
{
SaveValidView
.
class
,
SortValidView
.
class
})
@NotBlank
(
message
=
"名称不能为空"
,
groups
=
{
SaveValidView
.
class
})
private
String
storeGroupName
;
/**
...
...
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