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
3159cce8
Commit
3159cce8
authored
Jul 03, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据名称和企业ID,查询分组数据
parent
de636529
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
222 additions
and
6 deletions
+222
-6
StoreGroupService.java
...rc/main/java/com/gic/store/service/StoreGroupService.java
+16
-0
StoreGroupServiceImpl.java
...ava/com/gic/store/service/impl/StoreGroupServiceImpl.java
+50
-0
StoreFieldApiServiceImpl.java
...com/gic/store/service/outer/StoreFieldApiServiceImpl.java
+13
-0
StoreGroupApiServiceImpl.java
...com/gic/store/service/outer/StoreGroupApiServiceImpl.java
+18
-0
TabStoreFieldMapper.xml
...service/src/main/resources/mapper/TabStoreFieldMapper.xml
+0
-4
StoreFieldController.java
...va/com/gic/store/web/controller/StoreFieldController.java
+14
-0
StoreGroupController.java
...va/com/gic/store/web/controller/StoreGroupController.java
+11
-0
GlobalExceptionHandler.java
...a/com/gic/store/web/exception/GlobalExceptionHandler.java
+2
-1
StoreGroupQO.java
...in/java/com/gic/store/web/qo/storegroup/StoreGroupQO.java
+22
-1
StoreFieldRegionVO.java
...a/com/gic/store/web/vo/storefield/StoreFieldRegionVO.java
+76
-0
No files found.
gic-store-service/src/main/java/com/gic/store/service/StoreGroupService.java
View file @
3159cce8
...
...
@@ -15,4 +15,20 @@ public interface StoreGroupService {
* @return
*/
TabStoreGroup
getStoreGroupByName
(
String
storeGroupName
,
Integer
enterpriseId
);
/**
* 拖拽排序
* @param storeGroup
* @param toSortValue 要排序的值
*/
void
dragSort
(
TabStoreGroup
storeGroup
,
Integer
toSortValue
);
TabStoreGroup
getStoreGroupById
(
Integer
storeGroupId
);
/**
* 更新排序值
* @param sort
* @param storeGroupId
*/
void
updateSort
(
Integer
sort
,
Integer
storeGroupId
);
}
gic-store-service/src/main/java/com/gic/store/service/impl/StoreGroupServiceImpl.java
View file @
3159cce8
...
...
@@ -6,6 +6,8 @@ import com.gic.store.service.StoreGroupService;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author guojx
* @date 2019/7/3 2:18 PM
...
...
@@ -19,4 +21,52 @@ public class StoreGroupServiceImpl implements StoreGroupService{
public
TabStoreGroup
getStoreGroupByName
(
String
storeGroupName
,
Integer
enterpriseId
)
{
return
tabStoreGroupMapper
.
getStoreGroupByName
(
storeGroupName
,
enterpriseId
);
}
@Override
public
void
dragSort
(
TabStoreGroup
storeGroup
,
Integer
toSortValue
)
{
Integer
enterpriseId
=
storeGroup
.
getEnterpriseId
();
Integer
groupLevel
=
storeGroup
.
getGroupLevel
();
Integer
fromSortValue
=
storeGroup
.
getSort
();
Integer
storeGroupId
=
storeGroup
.
getStoreGroupId
();
TabStoreGroup
record
=
new
TabStoreGroup
();
record
.
setEnterpriseId
(
enterpriseId
);
record
.
setGroupLevel
(
groupLevel
);
List
<
TabStoreGroup
>
tabStoreGroupList
=
tabStoreGroupMapper
.
listStoreGroup
(
record
);
if
(
fromSortValue
>
toSortValue
)
{
//如果是向上拖拽
for
(
int
i
=
0
,
length
=
tabStoreGroupList
.
size
();
i
<
length
;
i
++)
{
TabStoreGroup
tabStoreGroup
=
tabStoreGroupList
.
get
(
i
);
//如果大于setSortValue,都需要降低排序值,往后推
boolean
isNeedDown
=
tabStoreGroup
.
getSort
()
>=
toSortValue
&&
tabStoreGroup
.
getSort
()
<
fromSortValue
;
if
(
isNeedDown
)
{
updateSort
(
tabStoreGroupList
.
get
(
i
+
1
).
getSort
(),
tabStoreGroup
.
getStoreGroupId
());
}
}
}
else
if
(
fromSortValue
<
toSortValue
)
{
//向下拖拽
for
(
int
i
=
0
,
length
=
tabStoreGroupList
.
size
();
i
<
length
;
i
++)
{
TabStoreGroup
tabStoreGroup
=
tabStoreGroupList
.
get
(
i
);
boolean
isNeedUp
=
tabStoreGroup
.
getSort
()
<=
toSortValue
&&
tabStoreGroup
.
getSort
()
>
fromSortValue
;
if
(
isNeedUp
)
{
updateSort
(
tabStoreGroupList
.
get
(
i
-
1
).
getSort
(),
tabStoreGroup
.
getStoreGroupId
());
}
}
}
updateSort
(
toSortValue
,
storeGroupId
);
}
@Override
public
TabStoreGroup
getStoreGroupById
(
Integer
storeGroupId
)
{
return
tabStoreGroupMapper
.
selectByPrimaryKey
(
storeGroupId
);
}
@Override
public
void
updateSort
(
Integer
sort
,
Integer
storeGroupId
)
{
TabStoreGroup
record
=
new
TabStoreGroup
();
record
.
setStoreGroupId
(
storeGroupId
);
record
.
setSort
(
sort
);
tabStoreGroupMapper
.
updateByPrimaryKeySelective
(
record
);
}
}
gic-store-service/src/main/java/com/gic/store/service/outer/StoreFieldApiServiceImpl.java
View file @
3159cce8
...
...
@@ -14,6 +14,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -174,4 +175,16 @@ public class StoreFieldApiServiceImpl implements StoreFieldApiService{
storeFieldService
.
sortTopping
(
storeField
.
getEnterpriseId
(),
storeFieldId
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
List
<
StoreFieldDTO
>>
listStoreFieldByRegionId
(
Integer
regionId
)
{
List
<
TabStoreField
>
tabStoreFieldList
=
storeFieldService
.
listStoreFieldByRegionId
(
regionId
);
if
(
tabStoreFieldList
==
null
)
{
return
ServiceResponse
.
success
(
new
ArrayList
<
StoreFieldDTO
>());
}
else
{
List
<
StoreFieldDTO
>
dtoList
=
EntityUtil
.
changeEntityListNew
(
StoreFieldDTO
.
class
,
tabStoreFieldList
);
return
ServiceResponse
.
success
(
dtoList
);
}
}
}
gic-store-service/src/main/java/com/gic/store/service/outer/StoreGroupApiServiceImpl.java
View file @
3159cce8
package
com
.
gic
.
store
.
service
.
outer
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.store.constant.StoreGroupConstant
;
import
com.gic.store.constant.StoreGroupErrorEnum
;
...
...
@@ -8,7 +9,9 @@ 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.StoreGroupService
;
import
com.gic.store.service.StoreService
;
import
com.gic.store.utils.ErrorCode
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -36,6 +39,8 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
@Autowired
private
StoreService
storeService
;
@Autowired
private
StoreGroupService
storeGroupService
;
@Override
public
int
save
(
StoreGroupDTO
storeGroupDTO
)
{
...
...
@@ -249,6 +254,19 @@ public class StoreGroupApiServiceImpl implements StoreGroupApiService{
return
save
(
noStoreGroup
);
}
@Override
public
ServiceResponse
<
Integer
>
dragSort
(
Integer
storeGroupId
,
Integer
setSortValue
)
{
TabStoreGroup
tabStoreGroup
=
storeGroupService
.
getStoreGroupById
(
storeGroupId
);
if
(
tabStoreGroup
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"主键错误,查询不到数据"
);
}
if
(
setSortValue
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"拖拽排序值不能为空过"
);
}
storeGroupService
.
dragSort
(
tabStoreGroup
,
setSortValue
);
return
ServiceResponse
.
success
();
}
private
int
selectStoreGroupMaxSort
(
Integer
enterpriseId
,
Integer
groupLevel
)
{
return
tabStoreGroupMapper
.
selectStoreGroupMaxSort
(
enterpriseId
,
groupLevel
);
}
...
...
gic-store-service/src/main/resources/mapper/TabStoreFieldMapper.xml
View file @
3159cce8
...
...
@@ -281,9 +281,6 @@
<if
test=
"regionId != null "
>
and store_region_id like concat('%_', #{regionId}, '_%')
</if>
<if
test=
"search != null and search != '' "
>
and ( store_field_name like concat('%', #{search}, '%') or store_field_code like concat('%', #{search}, '%') )
</if>
order by sort
</select>
</mapper>
\ No newline at end of file
gic-store-web/src/main/java/com/gic/store/web/controller/StoreFieldController.java
View file @
3159cce8
...
...
@@ -19,6 +19,7 @@ import com.gic.store.web.qo.PageQO;
import
com.gic.store.web.qo.storefield.StoreFieldQO
;
import
com.gic.store.web.qo.storefield.StoreFieldSelectQO
;
import
com.gic.store.web.vo.storefield.StoreFieldEditVO
;
import
com.gic.store.web.vo.storefield.StoreFieldRegionVO
;
import
com.gic.store.web.vo.storefield.StoreFieldVO
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -140,6 +141,19 @@ public class StoreFieldController {
}
}
@RequestMapping
(
"/list-store-field-by-region-id"
)
public
RestResponse
listStoreFieldByRegionId
(
Integer
regionId
)
{
if
(
regionId
==
null
)
{
RestResponse
.
failure
(
ErrorCode
.
ERR_5
.
getCode
(),
"域ID不能为空"
);
}
ServiceResponse
<
List
<
StoreFieldDTO
>>
result
=
storeFieldApiService
.
listStoreFieldByRegionId
(
regionId
);
if
(
result
.
isSuccess
())
{
return
RestResponse
.
success
(
EntityUtil
.
changeEntityListNew
(
StoreFieldRegionVO
.
class
,
result
.
getResult
()));
}
else
{
return
RestResponse
.
failure
(
result
.
getCode
(),
result
.
getMessage
());
}
}
@RequestMapping
(
"/remove-store-field-batch"
)
public
RestResponse
removeStoreFieldBatch
(
boolean
isDeleteAll
,
String
storeFieldIds
)
{
if
(
isDeleteAll
)
{
...
...
gic-store-web/src/main/java/com/gic/store/web/controller/StoreGroupController.java
View file @
3159cce8
package
com
.
gic
.
store
.
web
.
controller
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.store.constant.StoreGroupConstant
;
...
...
@@ -53,6 +54,16 @@ public class StoreGroupController {
return
RestResponse
.
success
(
storeGroupApiService
.
update
(
transferQoToDTO
(
storeGroupQO
)));
}
@RequestMapping
(
"/drag-sort"
)
public
RestResponse
dragSort
(
@Validated
({
StoreGroupQO
.
RemoveValidView
.
class
,
StoreGroupQO
.
SetSortValueValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
ServiceResponse
result
=
storeGroupApiService
.
dragSort
(
storeGroupQO
.
getStoreGroupId
(),
storeGroupQO
.
getSortValue
());
if
(
result
.
isSuccess
())
{
return
RestResponse
.
success
();
}
else
{
return
RestResponse
.
failure
(
result
.
getCode
(),
result
.
getMessage
());
}
}
@RequestMapping
(
"/sort"
)
public
RestResponse
sort
(
@Validated
({
StoreGroupQO
.
SortValidView
.
class
})
StoreGroupQO
storeGroupQO
)
{
return
RestResponse
.
success
(
storeGroupApiService
.
sort
(
transferQoToDTO
(
storeGroupQO
),
storeGroupQO
.
isUp
()));
...
...
gic-store-web/src/main/java/com/gic/store/web/exception/GlobalExceptionHandler.java
View file @
3159cce8
...
...
@@ -3,6 +3,7 @@ package com.gic.store.web.exception;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.store.constant.StoreGroupErrorEnum
;
import
com.gic.store.exception.StoreGroupException
;
import
com.gic.store.utils.ErrorCode
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.validation.BindException
;
...
...
@@ -29,7 +30,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
Exception
.
class
)
public
RestResponse
controllerException
(
HttpServletResponse
response
,
Exception
ex
)
{
logger
.
error
(
"err"
,
ex
);
RestResponse
failureResponse
=
getRestResponse
(
StoreGroupErrorEnum
.
Error
.
getCode
(),
StoreGroupErrorEnum
.
Error
.
getMessage
());
RestResponse
failureResponse
=
getRestResponse
(
ErrorCode
.
ERR_9999
.
getCode
(),
StoreGroupErrorEnum
.
Error
.
getMessage
());
StringBuilder
sb
=
new
StringBuilder
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
(
PrintWriter
printWriter
=
new
PrintWriter
(
baos
))
{
...
...
gic-store-web/src/main/java/com/gic/store/web/qo/storegroup/StoreGroupQO.java
View file @
3159cce8
...
...
@@ -2,7 +2,10 @@ package com.gic.store.web.qo.storegroup;
import
com.gic.store.constant.StoreGroupConstant
;
import
javax.validation.constraints.*
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.util.Date
;
...
...
@@ -29,6 +32,10 @@ public class StoreGroupQO implements Serializable{
public
interface
EditParentIdValidView
{
}
public
interface
SetSortValueValidView
{
}
...
...
@@ -98,6 +105,12 @@ public class StoreGroupQO implements Serializable{
@Max
(
value
=
StoreGroupConstant
.
SORT_DOWN
,
message
=
"移动标志参数值错误,大于2"
,
groups
=
{
SortValidView
.
class
})
private
Integer
upOrDown
;
/**
* 想要排序的值
*/
@NotNull
(
message
=
"排序值不能为空"
,
groups
=
{
SetSortValueValidView
.
class
})
private
Integer
sortValue
;
private
boolean
isUp
;
public
Integer
getStoreGroupId
()
{
...
...
@@ -203,4 +216,12 @@ public class StoreGroupQO implements Serializable{
return
false
;
}
}
public
Integer
getSortValue
()
{
return
sortValue
;
}
public
void
setSortValue
(
Integer
sortValue
)
{
this
.
sortValue
=
sortValue
;
}
}
gic-store-web/src/main/java/com/gic/store/web/vo/storefield/StoreFieldRegionVO.java
0 → 100644
View file @
3159cce8
package
com
.
gic
.
store
.
web
.
vo
.
storefield
;
import
java.io.Serializable
;
/**
* @author guojx
* @date 2019/7/3 4:13 PM
*/
public
class
StoreFieldRegionVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
6082513310725549988L
;
/**
*
*/
private
Integer
storeFieldId
;
/**
* 属性名称
*/
private
String
storeFieldName
;
/**
* 字段类型;1文本 2单选 3多选 4实数 5时间
*/
private
Integer
storeFieldType
;
/**
* 字段详细配置
*/
private
String
storeFieldDetail
;
/**
* 排序字段
*/
private
Double
sort
;
public
Integer
getStoreFieldId
()
{
return
storeFieldId
;
}
public
void
setStoreFieldId
(
Integer
storeFieldId
)
{
this
.
storeFieldId
=
storeFieldId
;
}
public
String
getStoreFieldName
()
{
return
storeFieldName
;
}
public
void
setStoreFieldName
(
String
storeFieldName
)
{
this
.
storeFieldName
=
storeFieldName
;
}
public
Integer
getStoreFieldType
()
{
return
storeFieldType
;
}
public
void
setStoreFieldType
(
Integer
storeFieldType
)
{
this
.
storeFieldType
=
storeFieldType
;
}
public
String
getStoreFieldDetail
()
{
return
storeFieldDetail
;
}
public
void
setStoreFieldDetail
(
String
storeFieldDetail
)
{
this
.
storeFieldDetail
=
storeFieldDetail
;
}
public
Double
getSort
()
{
return
sort
;
}
public
void
setSort
(
Double
sort
)
{
this
.
sort
=
sort
;
}
}
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