This commit is contained in:
richboo111
2024-01-19 17:58:45 +08:00
parent 7b9a4fe7ae
commit 2e533c6c58
3 changed files with 43 additions and 31 deletions

View File

@@ -547,6 +547,7 @@ func CheckAndReply(req *JXMsg, elmAppID string) (err error) {
} else {
temp.MsgContent = AutoReplyByAppID[mt.AppID]
}
temp.MsgSource = mtwmapi.MsgSourceStore
temp.Cts = int(time.Now().Unix())
temp.MsgID = RandTimeNumber()
@@ -611,28 +612,18 @@ func GetCustomTemplate(appID, vendorStoreID string) (storeTemplate string) {
return storeTemplate
}
// AddOrGetCustomReply 增加以及获取门店自定义回复模板
func AddOrGetCustomReply(appID, vendorStoreID, replyTemplate string, opType int) (storeTemplate string, err error) {
if len(appID) == 0 || len(vendorStoreID) == 0 {
// AddCustomReply 增加门店自定义回复模板
func AddCustomReply(appID, vendorStoreID, replyTemplate string) (storeTemplate string, err error) {
if len(appID) == 0 || len(vendorStoreID) == 0 || len(replyTemplate) == 0 {
return "", errors.New("参数错误请检查!")
}
key := GenCustomReplyID(appID, vendorStoreID)
switch opType {
case OpTypeAdd: //新增或修改
if len(replyTemplate) == 0 {
return "", errors.New("新增或修改门店自定义回复模板,不允许为空")
}
err = rdb.Del(key)
if err == nil {
err = rdb.Set(key, replyTemplate, 0)
}
return "", err
case OpTypeGet:
storeTemplate = GetCustomTemplate(appID, vendorStoreID)
return storeTemplate, nil
err = rdb.Del(key)
if err == nil {
err = rdb.Set(key, replyTemplate, 0)
}
return "", nil
return "", err
}

View File

@@ -145,19 +145,33 @@ func (c *IMController) GetElmMedia() {
})
}
// @Title 增加以及获取门店自定义回复模板
// @Description 增加以及获取门店自定义回复模板
// @Title 增加门店自定义回复模板
// @Description 增加门店自定义回复模板
// @Param token header string true "认证token"
// @Param appID query string true "京西门店id"
// @Param vendorStoreID query string true "美团门店id"
// @Param replyTemplate query string true "新增或修改自定义模板"
// @Param opType query int true "操作 1-新增 2-获取"
// @Param appID formData string true "应用id"
// @Param vendorStoreID formData string true "美团门店id"
// @Param replyTemplate formData string true "新增或修改自定义模板"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AddOrGetCustomReply [get]
func (c *IMController) AddOrGetCustomReply() {
c.callAddOrGetCustomReply(func(params *tImAddOrGetCustomReplyParams) (interface{}, string, error) {
retVal, err := im.AddOrGetCustomReply(params.AppID, params.VendorStoreID, params.ReplyTemplate, params.OpType)
// @router /AddCustomReply [post]
func (c *IMController) AddCustomReply() {
c.callAddCustomReply(func(params *tImAddCustomReplyParams) (interface{}, string, error) {
retVal, err := im.AddCustomReply(params.AppID, params.VendorStoreID, params.ReplyTemplate)
return retVal, "", err
})
}
// @Title 获取门店自定义回复模板
// @Description 获取门店自定义回复模板
// @Param token header string true "认证token"
// @Param appID query string true "应用id"
// @Param vendorStoreID query string true "美团门店id"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /GetCustomReply [get]
func (c *IMController) GetCustomReply() {
c.callGetCustomReply(func(params *tImGetCustomReplyParams) (interface{}, string, error) {
retVal := im.GetCustomTemplate(params.AppID, params.VendorStoreID)
return retVal, "", nil
})
}

View File

@@ -4544,13 +4544,20 @@ func init() {
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
web.ControllerComments{
Method: "AddOrGetCustomReply",
Router: `/AddOrGetCustomReply`,
Method: "AddCustomReply",
Router: `/AddCustomReply`,
AllowHTTPMethods: []string{"post"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:IMController"],
web.ControllerComments{
Method: "GetCustomReply",
Router: `/GetCustomReply`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})
//web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FnController"] = append(web.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:FnController"],
// web.ControllerComments{
// Method: "FnStore",