Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-enterprise
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-platform-enterprise
Commits
52a80973
Commit
52a80973
authored
Aug 19, 2020
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
公众号菜单保存调整:全部一起保存
parent
1870494a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
215 additions
and
4 deletions
+215
-4
AppletWechatMenuDTO.java
...main/java/com/gic/enterprise/dto/AppletWechatMenuDTO.java
+24
-0
AppletWechatMenuApiService.java
...om/gic/enterprise/service/AppletWechatMenuApiService.java
+16
-0
TabAppletWechatMenuMapper.java
.../gic/enterprise/dao/mapper/TabAppletWechatMenuMapper.java
+3
-0
AppletWechatMenuService.java
...a/com/gic/enterprise/service/AppletWechatMenuService.java
+2
-0
AppletWechatMenuServiceImpl.java
.../enterprise/service/impl/AppletWechatMenuServiceImpl.java
+5
-0
AppletWechatMenuApiServiceImpl.java
...se/service/outer/impl/AppletWechatMenuApiServiceImpl.java
+12
-0
TabAppletWechatMenuMapper.xml
...e/src/main/resources/mapper/TabAppletWechatMenuMapper.xml
+8
-0
WechatMenuController.java
...m/gic/enterprise/web/controller/WechatMenuController.java
+145
-4
No files found.
gic-platform-enterprise-api/src/main/java/com/gic/enterprise/dto/AppletWechatMenuDTO.java
View file @
52a80973
...
...
@@ -2,6 +2,7 @@ package com.gic.enterprise.dto;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* 自定义菜单
...
...
@@ -82,6 +83,11 @@ public class AppletWechatMenuDTO implements Serializable{
*/
private
Date
updateTime
;
/***********************/
private
List
<
AppletWechatMenuDTO
>
secondMenuList
;
private
boolean
isFirstLevel
;
public
Integer
getMenuId
()
{
return
menuId
;
}
...
...
@@ -193,4 +199,22 @@ public class AppletWechatMenuDTO implements Serializable{
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
List
<
AppletWechatMenuDTO
>
getSecondMenuList
()
{
return
secondMenuList
;
}
public
AppletWechatMenuDTO
setSecondMenuList
(
List
<
AppletWechatMenuDTO
>
secondMenuList
)
{
this
.
secondMenuList
=
secondMenuList
;
return
this
;
}
public
boolean
isFirstLevel
()
{
return
isFirstLevel
;
}
public
AppletWechatMenuDTO
setFirstLevel
(
boolean
firstLevel
)
{
isFirstLevel
=
firstLevel
;
return
this
;
}
}
gic-platform-enterprise-api/src/main/java/com/gic/enterprise/service/AppletWechatMenuApiService.java
View file @
52a80973
...
...
@@ -23,9 +23,22 @@ public interface AppletWechatMenuApiService {
* @param dto
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
*/
@Deprecated
ServiceResponse
<
Integer
>
save
(
AppletWechatMenuDTO
dto
)
throws
Exception
;
/**
* 新增(校验参数之后)
* @Title: saveOfHasValid
* @Description:
* @author guojuxing
* @param dto
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Integer>
*/
ServiceResponse
<
Integer
>
saveOfHasValid
(
AppletWechatMenuDTO
dto
);
ServiceResponse
<
Void
>
deleteWechatMenu
(
Integer
enterpriseId
,
String
appKey
);
/**
* 编辑
* @Title: edit
* @Description:
...
...
@@ -34,6 +47,7 @@ public interface AppletWechatMenuApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
* @throws
*/
@Deprecated
ServiceResponse
<
String
>
edit
(
AppletWechatMenuDTO
dto
)
throws
Exception
;
/**
...
...
@@ -44,6 +58,7 @@ public interface AppletWechatMenuApiService {
* @param menuId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
*/
@Deprecated
ServiceResponse
<
String
>
deleteByMenuId
(
Integer
menuId
);
/**
...
...
@@ -55,6 +70,7 @@ public interface AppletWechatMenuApiService {
* @param sort
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
*/
@Deprecated
ServiceResponse
<
String
>
sort
(
Integer
menuId
,
Integer
sort
);
/**
...
...
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/dao/mapper/TabAppletWechatMenuMapper.java
View file @
52a80973
...
...
@@ -90,4 +90,6 @@ public interface TabAppletWechatMenuMapper {
* @return java.util.List<com.gic.enterprise.entity.TabAppletWechatMenu>
*/
List
<
TabAppletWechatMenu
>
listAll
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"appKey"
)
String
appKey
);
void
deleteWechatMenu
(
@Param
(
"enterpriseId"
)
Integer
enterpriseId
,
@Param
(
"appKey"
)
String
appKey
);
}
\ No newline at end of file
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/AppletWechatMenuService.java
View file @
52a80973
...
...
@@ -82,4 +82,6 @@ public interface AppletWechatMenuService {
* @return java.util.List<com.gic.enterprise.entity.TabAppletWechatMenu>
*/
List
<
TabAppletWechatMenu
>
listAll
(
Integer
enterpriseId
,
String
appKey
);
void
deleteWechatMenu
(
Integer
enterpriseId
,
String
appKey
);
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/impl/AppletWechatMenuServiceImpl.java
View file @
52a80973
...
...
@@ -73,4 +73,9 @@ public class AppletWechatMenuServiceImpl implements AppletWechatMenuService{
public
List
<
TabAppletWechatMenu
>
listAll
(
Integer
enterpriseId
,
String
appKey
)
{
return
tabAppletWechatMenuMapper
.
listAll
(
enterpriseId
,
appKey
);
}
@Override
public
void
deleteWechatMenu
(
Integer
enterpriseId
,
String
appKey
)
{
tabAppletWechatMenuMapper
.
deleteWechatMenu
(
enterpriseId
,
appKey
);
}
}
gic-platform-enterprise-service/src/main/java/com/gic/enterprise/service/outer/impl/AppletWechatMenuApiServiceImpl.java
View file @
52a80973
...
...
@@ -110,6 +110,18 @@ public class AppletWechatMenuApiServiceImpl implements AppletWechatMenuApiServic
}
@Override
public
ServiceResponse
<
Integer
>
saveOfHasValid
(
AppletWechatMenuDTO
dto
){
Integer
menuId
=
appletWechatMenuService
.
save
(
dto
);
return
ServiceResponse
.
success
(
menuId
);
}
@Override
public
ServiceResponse
<
Void
>
deleteWechatMenu
(
Integer
enterpriseId
,
String
appKey
)
{
appletWechatMenuService
.
deleteWechatMenu
(
enterpriseId
,
appKey
);
return
ServiceResponse
.
success
();
}
@Override
public
ServiceResponse
<
String
>
edit
(
AppletWechatMenuDTO
dto
)
throws
Exception
{
//参数校验
TabAppletWechatMenu
record
=
appletWechatMenuService
.
getById
(
dto
.
getMenuId
());
...
...
gic-platform-enterprise-service/src/main/resources/mapper/TabAppletWechatMenuMapper.xml
View file @
52a80973
...
...
@@ -229,4 +229,11 @@
order by sort
</select>
<update
id=
"deleteWechatMenu"
>
update tab_applet_wechat_menu set status = 0
where status = 1
and enterprise_id = #{enterpriseId}
and app_key = #{appKey}
</update>
</mapper>
\ No newline at end of file
gic-platform-enterprise-web/src/main/java/com/gic/enterprise/web/controller/WechatMenuController.java
View file @
52a80973
package
com
.
gic
.
enterprise
.
web
.
controller
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.download.utils.log.LogUtils
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.service.EnterpriseInitApiService
;
import
com.gic.enterprise.utils.ResultControllerUtils
;
import
com.gic.wechat.business.api.service.fwh.WeixinMenuFunService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -40,6 +39,7 @@ public class WechatMenuController {
@Autowired
private
EnterpriseInitApiService
enterpriseInitApiService
;
@Deprecated
@RequestMapping
(
"/save"
)
public
RestResponse
saveMenu
(
AppletWechatMenuDTO
dto
)
throws
Exception
{
dto
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
...
...
@@ -47,12 +47,101 @@ public class WechatMenuController {
OperationResultUtils
.
LOG_NEW
+
"自定义菜单"
,
dto
.
getMenuName
());
}
@RequestMapping
(
"/save-all"
)
public
RestResponse
saveAllMenu
(
String
jsonArr
)
throws
Exception
{
LOGGER
.
info
(
"公众号菜单保存参数:{}"
,
jsonArr
);
Integer
enterpriseId
=
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
();
if
(
StringUtils
.
isBlank
(
jsonArr
))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"参数不能为空"
);
}
List
<
AppletWechatMenuDTO
>
list
=
JSON
.
parseArray
(
jsonArr
,
AppletWechatMenuDTO
.
class
);
List
<
AppletWechatMenuDTO
>
listOfHasValid
=
new
ArrayList
<>(
list
.
size
());
//主菜单不能超过3个
if
(
list
.
size
()
>=
3
)
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"主菜单不能超过3个"
);
}
//菜单名称重复
Set
<
String
>
menuNameSet
=
new
HashSet
<>();
int
saveItemCount
=
list
.
size
();
//校验
for
(
AppletWechatMenuDTO
first
:
list
)
{
first
.
setEnterpriseId
(
enterpriseId
);
first
.
setFirstLevel
(
true
);
RestResponse
response
=
validParams
(
first
);
if
(!
"0000"
.
equals
(
response
.
getCode
()))
{
return
RestResponse
.
failure
(
response
.
getCode
(),
response
.
getMessage
());
}
//校验填充后可以保存的实体类
AppletWechatMenuDTO
hasValidOfFirst
=
(
AppletWechatMenuDTO
)
response
.
getResult
();
List
<
AppletWechatMenuDTO
>
secondList
=
first
.
getSecondMenuList
();
if
(
CollectionUtils
.
isNotEmpty
(
secondList
))
{
saveItemCount
+=
secondList
.
size
();
List
<
AppletWechatMenuDTO
>
listSecondOfHasValid
=
new
ArrayList
<>(
secondList
.
size
());
//子菜单不超过5个
if
(
secondList
.
size
()
>=
5
)
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"子菜单不能超过5个"
);
}
for
(
AppletWechatMenuDTO
second
:
secondList
)
{
second
.
setFirstLevel
(
false
);
second
.
setEnterpriseId
(
enterpriseId
);
RestResponse
responseOfSecond
=
validParams
(
second
);
if
(!
"0000"
.
equals
(
responseOfSecond
.
getCode
()))
{
return
RestResponse
.
failure
(
responseOfSecond
.
getCode
(),
responseOfSecond
.
getMessage
());
}
//校验填充后可以保存的实体类
listSecondOfHasValid
.
add
((
AppletWechatMenuDTO
)
responseOfSecond
.
getResult
());
}
hasValidOfFirst
.
setSecondMenuList
(
listSecondOfHasValid
);
}
listOfHasValid
.
add
(
hasValidOfFirst
);
}
if
(
saveItemCount
!=
menuNameSet
.
size
())
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"菜单名称重复"
);
}
//校验通过,批量新增
//先删除
String
appKey
=
listOfHasValid
.
get
(
0
).
getAppKey
();
appletWechatMenuApiService
.
deleteWechatMenu
(
enterpriseId
,
appKey
);
for
(
int
i
=
0
,
len
=
listOfHasValid
.
size
();
i
<
len
;
i
++)
{
AppletWechatMenuDTO
temp
=
listOfHasValid
.
get
(
i
);
temp
.
setSort
(
i
+
1
);
ServiceResponse
<
Integer
>
response
=
appletWechatMenuApiService
.
saveOfHasValid
(
temp
);
Integer
parentId
=
response
.
getResult
();
List
<
AppletWechatMenuDTO
>
tempSecond
=
temp
.
getSecondMenuList
();
if
(
CollectionUtils
.
isNotEmpty
(
tempSecond
))
{
for
(
int
j
=
0
,
length
=
tempSecond
.
size
();
j
<
length
;
j
++)
{
AppletWechatMenuDTO
tempOfSecond
=
tempSecond
.
get
(
j
);
tempOfSecond
.
setParentMenuId
(
parentId
);
tempOfSecond
.
setSort
(
j
+
1
);
appletWechatMenuApiService
.
saveOfHasValid
(
tempOfSecond
);
}
}
}
LogUtils
.
createLog
(
OperationResultUtils
.
LOG_NEW
+
"自定义菜单"
,
appKey
);
return
RestResponse
.
success
();
}
@Deprecated
@RequestMapping
(
"/edit"
)
public
RestResponse
edit
(
AppletWechatMenuDTO
dto
)
throws
Exception
{
return
OperationResultUtils
.
operationResult
(
appletWechatMenuApiService
.
edit
(
dto
),
OperationResultUtils
.
LOG_EDIT
+
"自定义菜单"
,
dto
.
getMenuName
());
}
@Deprecated
@RequestMapping
(
"/delete"
)
public
RestResponse
delete
(
Integer
menuId
)
throws
Exception
{
ServiceResponse
<
String
>
result
=
appletWechatMenuApiService
.
deleteByMenuId
(
menuId
);
...
...
@@ -60,6 +149,7 @@ public class WechatMenuController {
OperationResultUtils
.
getOperationObject
(
result
));
}
@Deprecated
@RequestMapping
(
"/sort"
)
public
RestResponse
sort
(
Integer
menuId
,
Integer
sort
)
throws
Exception
{
ServiceResponse
<
String
>
result
=
appletWechatMenuApiService
.
sort
(
menuId
,
sort
);
...
...
@@ -143,4 +233,55 @@ public class WechatMenuController {
}
return
result
;
}
private
RestResponse
validParams
(
AppletWechatMenuDTO
dto
)
throws
Exception
{
//参数校验
if
(
dto
.
getEnterpriseId
()
==
null
)
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户ID不能为空"
);
}
//是否是主菜单
boolean
isMainMenu
=
dto
.
isFirstLevel
();
String
menuName
=
dto
.
getMenuName
();
boolean
isNotRightMenuName
;
//菜单标题,不超过16个字节,子菜单不超过60个字节
if
(
isMainMenu
)
{
isNotRightMenuName
=
StringUtils
.
isBlank
(
menuName
)
||
menuName
.
getBytes
(
"UTF-8"
).
length
>
16
;
}
else
{
isNotRightMenuName
=
StringUtils
.
isBlank
(
menuName
)
||
menuName
.
getBytes
(
"UTF-8"
).
length
>
60
;
}
if
(
isNotRightMenuName
)
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"菜单名称为空或者过长"
);
}
if
(!
WeChatMenuTypeEnum
.
isRightCode
(
dto
.
getMenuType
()))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"菜单内容错误"
);
}
if
(
WeChatMenuTypeEnum
.
isNeedMenuCode
(
dto
.
getMenuType
())
&&
StringUtils
.
isBlank
(
dto
.
getMenuCode
()))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"链接配置不能为空"
);
}
if
(
WeChatMenuTypeEnum
.
OUT_LINK
.
getCode
()
==
dto
.
getMenuType
().
intValue
())
{
if
(
StringUtils
.
isBlank
(
dto
.
getMenuUrl
()))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"外链网址不能为空"
);
}
}
if
(
WeChatMenuTypeEnum
.
APPLET_LINK
.
getCode
()
==
dto
.
getMenuType
().
intValue
()
&&
StringUtils
.
isBlank
(
dto
.
getMenuUrlPara
()))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"小程序appId不能为空"
);
}
//todo edit
//暂时只能外链和小程序
if
(
dto
.
getMenuType
().
intValue
()
!=
WeChatMenuTypeEnum
.
OUT_LINK
.
getCode
()
&&
dto
.
getMenuType
().
intValue
()
!=
WeChatMenuTypeEnum
.
APPLET_LINK
.
getCode
())
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"一期只能选择"
+
WeChatMenuTypeEnum
.
OUT_LINK
.
getMessage
()
+
"和"
+
WeChatMenuTypeEnum
.
APPLET_LINK
.
getMessage
());
}
if
(
StringUtils
.
isBlank
(
dto
.
getAppKey
()))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"公众号key不能为空"
);
}
//填充字段值
if
(
isMainMenu
)
{
//主菜单父级ID统一0
dto
.
setParentMenuId
(
0
);
}
return
RestResponse
.
success
(
dto
);
}
}
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