Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
1d91c26e
Commit
1d91c26e
authored
Jul 16, 2022
by
songyinghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 分组名称支持实时去重校验
parent
a1fcec0b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
11 deletions
+85
-11
HmGroupApiService.java
...m/gic/haoban/manage/api/service/hm/HmGroupApiService.java
+10
-0
TabHaobanHmGroupSettingMapper.java
.../service/dao/mapper/hm/TabHaobanHmGroupSettingMapper.java
+8
-0
HmGroupService.java
.../gic/haoban/manage/service/service/hm/HmGroupService.java
+7
-0
HmGroupServiceImpl.java
...an/manage/service/service/hm/impl/HmGroupServiceImpl.java
+11
-0
HmGroupApiServiceImpl.java
...ge/service/service/out/impl/hm/HmGroupApiServiceImpl.java
+18
-11
TabHaobanHmGroupSettingMapper.xml
...ain/resources/mapper/hm/TabHaobanHmGroupSettingMapper.xml
+8
-0
HmPageServiceTest.java
haoban-manage3-service/src/test/java/HmPageServiceTest.java
+6
-0
HmGroupController.java
...ic/haoban/manage/web/controller/hm/HmGroupController.java
+17
-0
No files found.
haoban-manage3-api/src/main/java/com/gic/haoban/manage/api/service/hm/HmGroupApiService.java
View file @
1d91c26e
...
...
@@ -5,6 +5,8 @@ import com.gic.api.base.commons.ServiceResponse;
import
com.gic.haoban.manage.api.dto.hm.HmGroupDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO
;
import
java.util.List
;
/**
* @Author MUSI
* @Date 2022/7/1 2:35 PM
...
...
@@ -52,4 +54,11 @@ public interface HmGroupApiService {
* @return
*/
ServiceResponse
<
HmGroupDTO
>
queryGroupDetail
(
Long
groupId
);
/**
* 根据名称查询groupName
* @param groupName
* @return
*/
ServiceResponse
<
List
<
HmGroupDTO
>>
queryGroupListByName
(
String
groupName
);
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/dao/mapper/hm/TabHaobanHmGroupSettingMapper.java
View file @
1d91c26e
...
...
@@ -34,4 +34,11 @@ public interface TabHaobanHmGroupSettingMapper {
*/
int
updateGroupSettingCount
(
@Param
(
"groupId"
)
Long
groupId
,
@Param
(
"changeCount"
)
Integer
changeCount
);
/**
* 根据名称精确查询
* @param groupName
* @return
*/
List
<
TabHaobanHmGroupSetting
>
queryHmGroupSettingByName
(
@Param
(
"groupName"
)
String
groupName
);
}
\ No newline at end of file
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/hm/HmGroupService.java
View file @
1d91c26e
...
...
@@ -53,4 +53,11 @@ public interface HmGroupService {
*/
Long
saveOrUpdateGroupSetting
(
HmGroupDTO
groupDTO
);
/**
* 根据名称精确查询分组
* @param groupName
* @return
*/
List
<
HmGroupSettingBO
>
queryGroupSettingByName
(
String
groupName
);
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/hm/impl/HmGroupServiceImpl.java
View file @
1d91c26e
...
...
@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.hm.impl;
import
com.gic.api.base.commons.Page
;
import
com.gic.commons.util.UniqueIdUtils
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.PageUtil
;
import
com.gic.haoban.manage.api.dto.hm.HmGroupDTO
;
import
com.gic.haoban.manage.api.enums.hm.HmGroupStatus
;
...
...
@@ -22,6 +23,8 @@ import org.springframework.stereotype.Component;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -132,4 +135,12 @@ public class HmGroupServiceImpl implements HmGroupService {
return
tempGroupSetting
.
getGroupId
();
}
}
public
List
<
HmGroupSettingBO
>
queryGroupSettingByName
(
String
groupName
){
List
<
TabHaobanHmGroupSetting
>
tabHaobanHmGroupSettings
=
haobanHmGroupSettingMapper
.
queryHmGroupSettingByName
(
groupName
);
if
(
CollectionUtils
.
isEmpty
(
tabHaobanHmGroupSettings
)){
return
Collections
.
emptyList
();
}
return
EntityUtil
.
changeEntityListByOrika
(
HmGroupSettingBO
.
class
,
tabHaobanHmGroupSettings
);
}
}
haoban-manage3-service/src/main/java/com/gic/haoban/manage/service/service/out/impl/hm/HmGroupApiServiceImpl.java
View file @
1d91c26e
...
...
@@ -61,27 +61,22 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
if
(
StringUtils
.
equals
(
DEFAULT_GROUP_NAME
,
hmGroupDTO
.
getGroupName
()))
{
return
ServiceResponse
.
failure
(
HaoBanErrCodeCommon
.
ERR_9
.
getCode
()
+
""
,
"分组名称不可使用默认分组名称"
);
}
HmGroupInfoQO
groupInfoQo
=
new
HmGroupInfoQO
();
groupInfoQo
.
setGroupName
(
hmGroupDTO
.
getGroupName
());
groupInfoQo
.
setStatus
(
HmGroupStatus
.
ENABLE
.
getCode
());
groupInfoQo
.
setEnterpriseId
(
hmGroupDTO
.
getEnterpriseId
());
groupInfoQo
.
setWxEnterpriseId
(
groupInfoQo
.
getWxEnterpriseId
());
Page
<
HmGroupSettingBO
>
hmGroupSettingPage
=
groupService
.
queryGroupSettingList
(
groupInfoQo
);
List
<
HmGroupSettingBO
>
groupSettingBos
=
groupService
.
queryGroupSettingByName
(
hmGroupDTO
.
getGroupName
());
if
(
hmGroupDTO
.
getGroupId
()
==
null
)
{
// insert
// check groupName unique
if
(
CollectionUtils
.
isNotEmpty
(
hmGroupSettingPage
.
getResult
()
))
{
if
(
CollectionUtils
.
isNotEmpty
(
groupSettingBos
))
{
return
ServiceResponse
.
failure
(
HaoBanErrCodeCommon
.
ERR_5
.
getCode
()
+
""
,
"该分组名称已存在,请重新输入"
);
}
}
else
{
// update
if
(
CollectionUtils
.
isNotEmpty
(
hmGroupSettingPage
.
getResult
()
)
&&
hmGroupSettingPage
.
getTotalCount
()
>
1
)
{
if
(
CollectionUtils
.
isNotEmpty
(
groupSettingBos
)
&&
groupSettingBos
.
size
()
>
1
)
{
// 名称重复
return
ServiceResponse
.
failure
(
HaoBanErrCodeCommon
.
ERR_5
.
getCode
()
+
""
,
"该分组名称已存在,请重新输入"
);
}
if
(
CollectionUtils
.
isNotEmpty
(
hmGroupSettingPage
.
getResult
()
)
&&
!
hmGroupSettingPage
.
getResult
()
.
get
(
0
).
getGroupId
().
equals
(
hmGroupDTO
.
getGroupId
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
groupSettingBos
)
&&
!
groupSettingBos
.
get
(
0
).
getGroupId
().
equals
(
hmGroupDTO
.
getGroupId
()))
{
// 名称重复
return
ServiceResponse
.
failure
(
HaoBanErrCodeCommon
.
ERR_5
.
getCode
()
+
""
,
"该分组名称已存在,请重新输入"
);
}
...
...
@@ -187,4 +182,16 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
HmGroupDTO
groupDTO
=
EntityUtil
.
changeEntityByOrika
(
HmGroupDTO
.
class
,
groupSettingBO
);
return
ServiceResponse
.
success
(
groupDTO
);
}
/**
* 根据名称查询groupName
*
* @param groupName
* @return
*/
@Override
public
ServiceResponse
<
List
<
HmGroupDTO
>>
queryGroupListByName
(
String
groupName
)
{
List
<
HmGroupSettingBO
>
hmGroupSettingBos
=
groupService
.
queryGroupSettingByName
(
groupName
);
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityListByOrika
(
HmGroupDTO
.
class
,
hmGroupSettingBos
));
}
}
haoban-manage3-service/src/main/resources/mapper/hm/TabHaobanHmGroupSettingMapper.xml
View file @
1d91c26e
...
...
@@ -204,4 +204,11 @@
set refer_num = if(refer_num + #{changeCount} >= 0, refer_num + #{changeCount}, 0)
where group_id = #{groupId,jdbcType=BIGINT}
</update>
<select
id=
"queryHmGroupSettingByName"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from tab_haoban_hm_group_setting
where group_name = #{groupName}
and `status` = 1
</select>
</mapper>
\ No newline at end of file
haoban-manage3-service/src/test/java/HmPageServiceTest.java
View file @
1d91c26e
...
...
@@ -134,4 +134,10 @@ public class HmPageServiceTest {
System
.
out
.
println
(
JSON
.
toJSONString
(
serviceResponse
));
}
@Test
public
void
groupNameCheckTest
(){
ServiceResponse
<
List
<
HmGroupDTO
>>
ms
=
groupService
.
queryGroupListByName
(
"MS"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
ms
));
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/hm/HmGroupController.java
View file @
1d91c26e
...
...
@@ -5,6 +5,7 @@ import com.gic.api.base.commons.ServiceResponse;
import
com.gic.commons.webapi.reponse.RestResponse
;
import
com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.StringUtil
;
import
com.gic.haoban.manage.api.dto.hm.HmGroupDTO
;
import
com.gic.haoban.manage.api.dto.hm.HmGroupQueryDTO
;
import
com.gic.haoban.manage.api.service.hm.HmGroupApiService
;
...
...
@@ -17,12 +18,15 @@ import com.gic.log.record.anno.GicLogRecord;
import
com.gic.log.record.util.GicLogRecordCategoryEnum
;
import
com.gic.log.record.util.GicLogRecordEvaluationContext
;
import
com.gic.log.record.util.GicLogRecordOptTypeEnum
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.validation.Valid
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Optional
;
/**
...
...
@@ -130,4 +134,17 @@ public class HmGroupController extends WebBaseController {
ServiceResponse
<
Integer
>
serviceResponse
=
groupApiService
.
queryGroupTotalReferCount
(
loginUser
.
getEnterpriseId
(),
loginUser
.
getWxEnterpriseId
());
return
RestResponse
.
successResult
(
serviceResponse
.
getResult
());
}
@RequestMapping
(
path
=
"/check/name"
)
public
RestResponse
<?>
checkGroupName
(
HmGroupSettingVO
groupSettingVO
){
if
(
StringUtils
.
isBlank
(
groupSettingVO
.
getGroupName
())){
return
RestResponse
.
successResult
(
Collections
.
emptyList
());
}
ServiceResponse
<
List
<
HmGroupDTO
>>
serviceResponse
=
groupApiService
.
queryGroupListByName
(
groupSettingVO
.
getGroupName
());
if
(
serviceResponse
.
isSuccess
()){
return
RestResponse
.
successResult
(
serviceResponse
.
getResult
());
}
return
RestResponse
.
failure
(
serviceResponse
.
getCode
(),
serviceResponse
.
getMessage
());
}
}
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