Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2b88eced
authored
Apr 26, 2021
by
YaoYuHang
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
社群运营 - 问题反馈21、22、40 BUG修复
1 parent
3029df2a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
61 deletions
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCommunityKeywordGroupController.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeKeywordGroupTask.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCommunityKeywordToGroupService.java
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCommunityKeywordToGroupServiceImpl.java
linkwe-admin/src/main/java/com/linkwechat/web/controller/wecom/WeCommunityKeywordGroupController.java
View file @
2b88ece
...
@@ -76,19 +76,7 @@ public class WeCommunityKeywordGroupController extends BaseController {
...
@@ -76,19 +76,7 @@ public class WeCommunityKeywordGroupController extends BaseController {
// @PreAuthorize("@ss.hasPermi('wecom:communityKeyword:add')")
// @PreAuthorize("@ss.hasPermi('wecom:communityKeyword:add')")
@PostMapping
(
path
=
"/"
)
@PostMapping
(
path
=
"/"
)
public
AjaxResult
addTask
(
@RequestBody
@Validated
WeKeywordGroupTaskDto
keywordToGroupDto
)
{
public
AjaxResult
addTask
(
@RequestBody
@Validated
WeKeywordGroupTaskDto
keywordToGroupDto
)
{
// 群活码必须存在
return
toAjax
(
keywordToGroupService
.
addTask
(
keywordToGroupDto
));
if
(
null
==
groupCodeService
.
selectWeGroupCodeById
(
keywordToGroupDto
.
getGroupCodeId
()))
{
return
AjaxResult
.
error
(
HttpStatus
.
NOT_FOUND
,
"群活码不存在"
);
}
// 任务名称必须唯一
if
(!
keywordToGroupService
.
taskNameIsUnique
(
keywordToGroupDto
.
getTaskName
()))
{
return
AjaxResult
.
error
(
HttpStatus
.
BAD_REQUEST
,
"任务名称已存在"
);
}
WeKeywordGroupTask
task
=
new
WeKeywordGroupTask
();
BeanUtils
.
copyProperties
(
keywordToGroupDto
,
task
);
task
.
setCreateBy
(
SecurityUtils
.
getUsername
());
String
[]
keywords
=
keywordToGroupDto
.
getKeywords
().
split
(
","
);
return
toAjax
(
keywordToGroupService
.
addTask
(
task
,
keywords
));
}
}
/**
/**
...
@@ -101,22 +89,7 @@ public class WeCommunityKeywordGroupController extends BaseController {
...
@@ -101,22 +89,7 @@ public class WeCommunityKeywordGroupController extends BaseController {
// @PreAuthorize("@ss.hasPermi('wecom:communityKeyword:edit')")
// @PreAuthorize("@ss.hasPermi('wecom:communityKeyword:edit')")
@PutMapping
(
path
=
"/{taskId}"
)
@PutMapping
(
path
=
"/{taskId}"
)
public
AjaxResult
updateTask
(
@PathVariable
(
"taskId"
)
Long
taskId
,
@RequestBody
@Validated
WeKeywordGroupTaskDto
keywordToGroupDto
)
{
public
AjaxResult
updateTask
(
@PathVariable
(
"taskId"
)
Long
taskId
,
@RequestBody
@Validated
WeKeywordGroupTaskDto
keywordToGroupDto
)
{
// 群活码必须存在
return
toAjax
(
keywordToGroupService
.
updateTask
(
taskId
,
keywordToGroupDto
));
if
(
null
==
groupCodeService
.
selectWeGroupCodeById
(
keywordToGroupDto
.
getGroupCodeId
()))
{
return
AjaxResult
.
error
(
HttpStatus
.
NOT_FOUND
,
"群活码不存在"
);
}
// 若名称发生更改,则必须唯一
String
inputTaskName
=
keywordToGroupDto
.
getTaskName
();
String
originalName
=
keywordToGroupService
.
getTaskById
(
taskId
).
getTaskName
();
if
(!
originalName
.
equals
(
inputTaskName
)
&&
!
keywordToGroupService
.
taskNameIsUnique
(
inputTaskName
))
{
return
AjaxResult
.
error
(
HttpStatus
.
BAD_REQUEST
,
"任务名称已存在"
);
}
WeKeywordGroupTask
task
=
new
WeKeywordGroupTask
();
BeanUtils
.
copyProperties
(
keywordToGroupDto
,
task
);
task
.
setTaskId
(
taskId
);
task
.
setUpdateBy
(
SecurityUtils
.
getUsername
());
String
[]
keywords
=
keywordToGroupDto
.
getKeywords
().
split
(
","
);
return
toAjax
(
keywordToGroupService
.
updateTask
(
task
,
keywords
));
}
}
/**
/**
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/domain/WeKeywordGroupTask.java
View file @
2b88ece
...
@@ -3,6 +3,8 @@ package com.linkwechat.wecom.domain;
...
@@ -3,6 +3,8 @@ package com.linkwechat.wecom.domain;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.core.domain.BaseEntity
;
import
com.linkwechat.common.utils.SnowFlakeUtil
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
...
@@ -10,6 +12,7 @@ import lombok.EqualsAndHashCode;
...
@@ -10,6 +12,7 @@ import lombok.EqualsAndHashCode;
* 社区运营 - 关键词拉群任务实体
* 社区运营 - 关键词拉群任务实体
*/
*/
@Data
@Data
@Builder
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@TableName
(
"we_keyword_group"
)
@TableName
(
"we_keyword_group"
)
public
class
WeKeywordGroupTask
extends
BaseEntity
{
public
class
WeKeywordGroupTask
extends
BaseEntity
{
...
@@ -18,7 +21,7 @@ public class WeKeywordGroupTask extends BaseEntity {
...
@@ -18,7 +21,7 @@ public class WeKeywordGroupTask extends BaseEntity {
* 主键id
* 主键id
*/
*/
@TableId
@TableId
private
Long
taskId
;
private
Long
taskId
=
SnowFlakeUtil
.
nextId
()
;
/**
/**
* 任务名称
* 任务名称
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/IWeCommunityKeywordToGroupService.java
View file @
2b88ece
package
com
.
linkwechat
.
wecom
.
service
;
package
com
.
linkwechat
.
wecom
.
service
;
import
com.linkwechat.wecom.domain.
WeKeywordGroupTask
;
import
com.linkwechat.wecom.domain.
dto.WeKeywordGroupTaskDto
;
import
com.linkwechat.wecom.domain.vo.WeKeywordGroupTaskVo
;
import
com.linkwechat.wecom.domain.vo.WeKeywordGroupTaskVo
;
import
java.util.List
;
import
java.util.List
;
...
@@ -33,20 +33,18 @@ public interface IWeCommunityKeywordToGroupService {
...
@@ -33,20 +33,18 @@ public interface IWeCommunityKeywordToGroupService {
/**
/**
* 创建新任务
* 创建新任务
*
*
* @param task 待存储的对象
* @param taskDto 任务信息
* @param keywords 关键词
* @return 结果
* @return 结果
*/
*/
int
addTask
(
WeKeywordGroupTask
task
,
String
[]
keywords
);
int
addTask
(
WeKeywordGroupTask
Dto
taskDto
);
/**
/**
* 对指定任务进行更新
* 对指定任务进行更新
*
* @param taskId 待更新任务的id
* @param task 待更新对象
* @param taskDto 任务信息
* @param keywords 关键词
* @return 结果
* @return 结果
*/
*/
int
updateTask
(
WeKeywordGroupTask
task
,
String
[]
keywords
);
int
updateTask
(
Long
taskId
,
WeKeywordGroupTaskDto
taskDto
);
/**
/**
* 根据id列表批量删除任务
* 根据id列表批量删除任务
...
...
linkwe-wecom/src/main/java/com/linkwechat/wecom/service/impl/WeCommunityKeywordToGroupServiceImpl.java
View file @
2b88ece
...
@@ -2,10 +2,13 @@ package com.linkwechat.wecom.service.impl;
...
@@ -2,10 +2,13 @@ package com.linkwechat.wecom.service.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.linkwechat.common.constant.HttpStatus
;
import
com.linkwechat.common.exception.CustomException
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.common.utils.StringUtils
;
import
com.linkwechat.wecom.domain.WeGroupCode
;
import
com.linkwechat.wecom.domain.WeGroupCode
;
import
com.linkwechat.wecom.domain.WeKeywordGroupTaskKeyword
;
import
com.linkwechat.wecom.domain.WeKeywordGroupTaskKeyword
;
import
com.linkwechat.wecom.domain.WeKeywordGroupTask
;
import
com.linkwechat.wecom.domain.WeKeywordGroupTask
;
import
com.linkwechat.wecom.domain.dto.WeKeywordGroupTaskDto
;
import
com.linkwechat.wecom.domain.vo.WeGroupCodeVo
;
import
com.linkwechat.wecom.domain.vo.WeGroupCodeVo
;
import
com.linkwechat.wecom.domain.vo.WeKeywordGroupTaskVo
;
import
com.linkwechat.wecom.domain.vo.WeKeywordGroupTaskVo
;
import
com.linkwechat.wecom.mapper.WeGroupCodeMapper
;
import
com.linkwechat.wecom.mapper.WeGroupCodeMapper
;
...
@@ -17,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -17,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -95,18 +95,24 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
...
@@ -95,18 +95,24 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
/**
/**
* 创建新任务
* 创建新任务
*
*
* @param task 待存储的对象
* @param taskDto 任务信息
* @param keywords 关键词
* @return 结果
* @return 结果
*/
*/
@Override
@Override
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
addTask
(
WeKeywordGroupTask
task
,
String
[]
keywords
)
{
public
int
addTask
(
WeKeywordGroupTaskDto
taskDto
)
{
validation
(
taskDto
,
true
);
WeKeywordGroupTask
task
=
WeKeywordGroupTask
.
builder
()
.
groupCodeId
(
taskDto
.
getGroupCodeId
())
.
taskName
(
taskDto
.
getTaskName
())
.
welcomeMsg
(
taskDto
.
getWelcomeMsg
())
.
build
();
if
(
this
.
save
(
task
))
{
if
(
this
.
save
(
task
))
{
// 构建关键词对象并存储
// 构建关键词对象并存储
,需要先校验关键词长度
List
<
WeKeywordGroupTaskKeyword
>
taskKeywordList
=
Arrays
List
<
WeKeywordGroupTaskKeyword
>
taskKeywordList
=
parseLongKeywordsString
(
taskDto
.
getKeywords
())
.
stream
(
keywords
)
.
stream
()
.
map
(
word
->
new
WeKeywordGroupTaskKeyword
(
task
.
getTaskId
(),
word
))
.
map
(
keyword
->
new
WeKeywordGroupTaskKeyword
(
task
.
getTaskId
(),
key
word
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotEmpty
(
taskKeywordList
))
{
if
(
StringUtils
.
isNotEmpty
(
taskKeywordList
))
{
taskKwMapper
.
batchBindsTaskKeyword
(
taskKeywordList
);
taskKwMapper
.
batchBindsTaskKeyword
(
taskKeywordList
);
...
@@ -118,23 +124,30 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
...
@@ -118,23 +124,30 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
/**
/**
* 对指定任务进行更新
* 对指定任务进行更新
*
* @param taskId 待更新任务的id
* @param task 待更新对象
* @param taskDto 任务信息
* @param keywords 关键词
* @return 结果
* @return 结果
*/
*/
@Override
@Override
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
updateTask
(
WeKeywordGroupTask
task
,
String
[]
keywords
)
{
public
int
updateTask
(
Long
taskId
,
WeKeywordGroupTaskDto
taskDto
)
{
validation
(
taskDto
,
false
);
WeKeywordGroupTask
task
=
WeKeywordGroupTask
.
builder
()
.
groupCodeId
(
taskDto
.
getGroupCodeId
())
.
taskName
(
taskDto
.
getTaskName
())
.
welcomeMsg
(
taskDto
.
getWelcomeMsg
())
.
taskId
(
taskId
)
.
build
();
if
(
taskMapper
.
updateById
(
task
)
==
1
)
{
if
(
taskMapper
.
updateById
(
task
)
==
1
)
{
// 删除原有的关键词
// 删除原有的关键词
LambdaQueryWrapper
<
WeKeywordGroupTaskKeyword
>
keywordWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
WeKeywordGroupTaskKeyword
>
keywordWrapper
=
new
LambdaQueryWrapper
<>();
keywordWrapper
.
eq
(
WeKeywordGroupTaskKeyword:
:
getTaskId
,
task
.
getTaskId
());
keywordWrapper
.
eq
(
WeKeywordGroupTaskKeyword:
:
getTaskId
,
task
.
getTaskId
());
taskKwMapper
.
delete
(
keywordWrapper
);
taskKwMapper
.
delete
(
keywordWrapper
);
// 再重新插入新的关键词
// 再重新插入新的关键词
List
<
WeKeywordGroupTaskKeyword
>
taskKeywordList
=
Arrays
List
<
WeKeywordGroupTaskKeyword
>
taskKeywordList
=
parseLongKeywordsString
(
taskDto
.
getKeywords
())
.
stream
(
keywords
)
.
stream
()
.
map
(
word
->
new
WeKeywordGroupTaskKeyword
(
task
.
getTaskId
(),
word
))
.
map
(
keyword
->
new
WeKeywordGroupTaskKeyword
(
task
.
getTaskId
(),
key
word
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
if
(
StringUtils
.
isNotEmpty
(
taskKeywordList
))
{
if
(
StringUtils
.
isNotEmpty
(
taskKeywordList
))
{
taskKwMapper
.
batchBindsTaskKeyword
(
taskKeywordList
);
taskKwMapper
.
batchBindsTaskKeyword
(
taskKeywordList
);
...
@@ -151,7 +164,7 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
...
@@ -151,7 +164,7 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
* @return 删除行数
* @return 删除行数
*/
*/
@Override
@Override
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
batchRemoveTaskByIds
(
Long
[]
ids
)
{
public
int
batchRemoveTaskByIds
(
Long
[]
ids
)
{
// 移除其所有关键词对象
// 移除其所有关键词对象
LambdaQueryWrapper
<
WeKeywordGroupTaskKeyword
>
keywordWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
WeKeywordGroupTaskKeyword
>
keywordWrapper
=
new
LambdaQueryWrapper
<>();
...
@@ -162,9 +175,7 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
...
@@ -162,9 +175,7 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
taskWrapper
.
in
(
WeKeywordGroupTask:
:
getTaskId
,
Arrays
.
asList
(
ids
));
taskWrapper
.
in
(
WeKeywordGroupTask:
:
getTaskId
,
Arrays
.
asList
(
ids
));
return
taskMapper
.
delete
(
taskWrapper
);
return
taskMapper
.
delete
(
taskWrapper
);
}
}
/*
*/
/**
/**
* 检测任务名是否唯一
* 检测任务名是否唯一
*
*
...
@@ -223,4 +234,49 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
...
@@ -223,4 +234,49 @@ public class WeCommunityKeywordToGroupServiceImpl extends ServiceImpl<WeKeywordG
taskVo
.
setGroupCodeInfo
(
groupCodeVo
);
taskVo
.
setGroupCodeInfo
(
groupCodeVo
);
});
});
}
}
/**
* 校验数据
* @param taskDto 待校验数据
* @param addMode 是否是新增模式(更新时不需要检测任务名)
*/
private
void
validation
(
WeKeywordGroupTaskDto
taskDto
,
boolean
addMode
)
{
final
int
MAX_NAME_LENGTH
=
30
;
final
int
MAX_MSG_LENGTH
=
220
;
// 群活码必须存在
if
(
null
==
groupCodeMapper
.
selectWeGroupCodeById
(
taskDto
.
getGroupCodeId
()))
{
throw
new
CustomException
(
"群活码不存在"
,
HttpStatus
.
BAD_REQUEST
);
}
// 任务名称必须唯一
if
(!
taskNameIsUnique
(
taskDto
.
getTaskName
())
&&
addMode
)
{
throw
new
CustomException
(
"任务名称已存在"
,
HttpStatus
.
BAD_REQUEST
);
}
// 名称不可超长
if
(
taskDto
.
getTaskName
().
length
()
>
MAX_NAME_LENGTH
)
{
throw
new
CustomException
(
"活码名称长度超长,请重新输入"
,
HttpStatus
.
BAD_REQUEST
);
}
// 引导语不可超长
if
(
taskDto
.
getWelcomeMsg
().
length
()
>
MAX_MSG_LENGTH
)
{
throw
new
CustomException
(
"引导语长度超长,请重新输入"
,
HttpStatus
.
BAD_REQUEST
);
}
}
/**
* 对关键词长字符串进行校验,获取关键词列表
* @param longKeywordsString 关键词长字符串
* @return 关键词列表
*/
private
List
<
String
>
parseLongKeywordsString
(
String
longKeywordsString
)
{
String
[]
keywords
=
longKeywordsString
.
split
(
","
);
final
int
MAX_KEYWORD_LENGTH
=
10
;
List
<
String
>
resultList
=
new
ArrayList
<>();
for
(
String
keyword
:
keywords
)
{
if
(
keyword
.
length
()
>
MAX_KEYWORD_LENGTH
)
{
throw
new
CustomException
(
String
.
format
(
"关键字 %s 长度过长,请重新输入。"
,
keyword
),
HttpStatus
.
BAD_REQUEST
);
}
resultList
.
add
(
keyword
);
}
return
resultList
;
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment