Merge pull request 'feat-20231228-001-Robin' (#36) from feat-20231228-001-Robin into main

Reviewed-on: #36
This commit is contained in:
chenhao 2024-01-02 22:41:44 +08:00
commit b1b4fed922
12 changed files with 157 additions and 60 deletions

View File

@ -65,3 +65,12 @@ const (
TextAudit_Failed = 9 //回退失败
TextAudit_ServiceFailed = 10 //批次任务失败
)
// 意见反馈表的status审批状态
const (
Feedback_Created = 0 //待处理
Feedback_Handling = 1 //跟进中
Feedback_Handled = 2 //已处理
Feedback_Invalid = 3 //无效
Feedback_RelatedToIteration = 4 //迭代相关
)

View File

@ -5,62 +5,16 @@ import (
"service/dbstruct"
)
// op 创建
type OpCreateReq struct {
// api 创建
type ApiCreateReq struct {
base.BaseRequest
*dbstruct.Feedback
}
type OpCreateData struct {
type ApiCreateData struct {
}
type OpCreateResp struct {
type ApiCreateResp struct {
base.BaseResponse
Data *OpCreateData `json:"data"`
}
// op 删除
type OpDeleteReq struct {
base.BaseRequest
Id int64 `json:"id"`
}
type OpDeleteData struct {
}
type OpDeleteResp struct {
base.BaseResponse
Data *OpDeleteData `json:"data"`
}
// op 更新
type OpUpdateReq struct {
base.BaseRequest
*dbstruct.Feedback
}
type OpUpdateData struct {
}
type OpUpdateResp struct {
base.BaseResponse
Data *OpUpdateData `json:"data"`
}
// op 列表
type OpListReq struct {
base.BaseRequest
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type OpListData struct {
List []*dbstruct.Feedback `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type OpListResp struct {
base.BaseResponse
Data *OpListData `json:"data"`
Data *ApiCreateData `json:"data"`
}

View File

@ -5,16 +5,63 @@ import (
"service/dbstruct"
)
// api 创建
type ApiCreateReq struct {
// op 创建
type OpCreateReq struct {
base.BaseRequest
*dbstruct.Feedback
}
type ApiCreateData struct {
type OpCreateData struct {
}
type ApiCreateResp struct {
type OpCreateResp struct {
base.BaseResponse
Data *ApiCreateData `json:"data"`
Data *OpCreateData `json:"data"`
}
// op 删除
type OpDeleteReq struct {
base.BaseRequest
Id int64 `json:"id"`
}
type OpDeleteData struct {
}
type OpDeleteResp struct {
base.BaseResponse
Data *OpDeleteData `json:"data"`
}
// op 更新
type OpUpdateReq struct {
base.BaseRequest
*dbstruct.Feedback
}
type OpUpdateData struct {
}
type OpUpdateResp struct {
base.BaseResponse
Data *OpUpdateData `json:"data"`
}
// op 列表
type OpListReq struct {
base.BaseRequest
Status *int64 `json:"status"`
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type OpListData struct {
List []*dbstruct.Feedback `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type OpListResp struct {
base.BaseResponse
Data *OpListData `json:"data"`
}

View File

@ -0,0 +1,13 @@
package proto
import "service/library/validator"
// api 创建
func (p *ApiCreateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewInt64PtrParam("请填写反馈用户MID", p.Feedback.Mid))
params = append(params, validator.NewStringPtrParam("请填写问题描述!", p.Discription))
return
}

View File

@ -0,0 +1,14 @@
package proto
import "service/library/validator"
// api 创建
func (p *OpUpdateReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewInt64PtrParam("请提供Id", p.Feedback.Id))
params = append(params, validator.NewInt64PtrParam("请更新反馈状态!", p.Feedback.Status))
params = append(params, validator.NewStringPtrParam("请提供更新备注!", p.Feedback.Remarks))
return
}

View File

@ -7,6 +7,7 @@ import (
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"service/library/mediafiller"
"github.com/gin-gonic/gin"
)
@ -62,6 +63,14 @@ func OpGetFeedbackList(ctx *gin.Context) {
return
}
//填充媒体切片
objectMediaNum := 1 // 单个反馈总共1个媒体类
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
for i, feedback := range list {
mediaFillableList[objectMediaNum*i+0] = feedback.Credentials
}
mediafiller.FillList(ctx, mediaFillableList)
data := &feedbackproto.OpListData{
List: list,
Offset: req.Offset + len(list),

View File

@ -1792,6 +1792,9 @@ func (m *Mongo) GetFeedbackList(ctx *gin.Context, req *feedbackproto.OpListReq)
query := qmgo.M{
"del_flag": 0,
}
if req.Status != nil {
query["status"] = util.DerefInt64(req.Status)
}
err := col.Find(ctx, query).Sort("-ct").Skip(int64(req.Offset)).Limit(int64(req.Limit)).All(&list)
if err == qmgo.ErrNoSuchDocuments {
err = nil

View File

@ -42,6 +42,9 @@ const (
DBContactCustomerServiceSessionIdSeq = "contact_customer_service_session_id_seq"
COLContactCustomerServiceSessionIdSeq = "contact_customer_service_session_id_seq"
DBFeedbackIdSeq = "feedback_id_seq"
COLFeedbackIdSeq = "feedback_id_seq"
)
// UserIdSeq序列表
@ -99,6 +102,11 @@ func (m *Mongo) getColContactCustomerServiceSessionIdSeq() *qmgo.Collection {
return m.clientMix.Database(DBContactCustomerServiceSessionIdSeq).Collection(COLContactCustomerServiceIdSeq)
}
// FeedbackIdSeq序列表
func (m *Mongo) getColFeedbackIdSeq() *qmgo.Collection {
return m.clientMix.Database(DBFeedbackIdSeq).Collection(COLFeedbackIdSeq)
}
// account_id发号器
func (m *Mongo) GetAndUpdateAccountIdSeq(ctx *gin.Context) (accountIdSeq *dbstruct.AccountIdSeq, err error) {
col := m.getColAccountIdSeq()
@ -300,6 +308,25 @@ func (m *Mongo) GetAndUpdateContactCustomerServiceSessionIdSeq(ctx *gin.Context)
return &contactCustomerServiceSessionIdSeqInstance, err
}
// feedback_id发号器
func (m *Mongo) GetAndUpdateFeedbackIdSeq(ctx *gin.Context) (feedbackIdSeq *dbstruct.FeedbackIdSeq, err error) {
col := m.getColFeedbackIdSeq()
change := qmgo.Change{
Update: qmgo.M{"$inc": qmgo.M{"seq": 1}},
Upsert: true,
ReturnNew: false,
}
feedbackIdSeqInstance := dbstruct.FeedbackIdSeq{}
if err = col.Find(ctx, qmgo.M{"_id": "feedback_id_seq_id"}).Apply(change, &feedbackIdSeqInstance); err != nil {
logger.Error("change error : %v", err)
return
}
return &feedbackIdSeqInstance, err
}
// media_id发号器
func (m *Mongo) GetAndUpdateMediaSeq(ctx *gin.Context) (mediaIdSeq *dbstruct.MediaIdSeq, err error) {
col := m.getColMomentIdSeq()

View File

@ -5,7 +5,6 @@ import (
feedbackproto "service/api/proto/feedback/proto"
"service/app/mix/dao"
"service/dbstruct"
"service/library/idgenerator"
"service/library/logger"
"time"
@ -25,11 +24,20 @@ func NewFeedback(store *dao.Store) (a *Feedback) {
}
func (p *Feedback) OpCreate(ctx *gin.Context, req *feedbackproto.OpCreateReq) error {
req.Feedback.Id = goproto.Int64(idgenerator.GenFeedbackId())
//产生id
feedbackIdSeq, err := p.store.GetAndUpdateFeedbackIdSeq(ctx)
if err != nil {
logger.Error("GetAndUpdateFeedbackIdSeq failed : %v", err)
return err
}
req.Feedback.Id = goproto.Int64(feedbackIdSeq.Seq)
req.Feedback.Ct = goproto.Int64(time.Now().Unix())
req.Feedback.Ut = goproto.Int64(time.Now().Unix())
req.Feedback.DelFlag = goproto.Int64(consts.Exist)
err := p.store.CreateFeedback(ctx, req.Feedback)
req.Feedback.Status = goproto.Int64(consts.Feedback_Created)
err = p.store.CreateFeedback(ctx, req.Feedback)
if err != nil {
logger.Error("CreateFeedback fail, err: %v", err)
return err

View File

@ -1775,7 +1775,14 @@ func (s *Service) OpUpdateFeedback(ctx *gin.Context, req *feedbackproto.OpUpdate
return
}
err := _DefaultFeedback.OpUpdate(ctx, req)
err := _DefaultFeedback.OpUpdate(ctx, &feedbackproto.OpUpdateReq{
BaseRequest: req.BaseRequest,
Feedback: &dbstruct.Feedback{
Id: req.Id,
Status: req.Status,
Remarks: req.Remarks,
},
})
if err == qmgo.ErrNoSuchDocuments {
ec = errcode.ErrCodeFeedbackNotExist
err = nil

View File

@ -5,6 +5,8 @@ type Feedback struct {
Mid *int64 `json:"mid" bson:"mid"` // 反馈用户mid
Discription *string `json:"discription" bson:"discription"` // 问题描述
Credentials *MediaComponent `json:"credentials" bson:"credentials"` // 问题凭证
Status *int64 `json:"status" bson:"status"` // 问题状态
Remarks *string `json:"remarks" bson:"remarks"` // 备注
Ct *int64 `json:"ct" bson:"ct"` // 创建时间
Ut *int64 `json:"ut" bson:"ut"` // 更新时间
DelFlag *int64 `json:"del_flag" bson:"del_flag"` // 删除标记

View File

@ -45,6 +45,10 @@ type ContactCustomerServiceSessionIdSeq struct {
Seq int64 //联系客服对话ID序列号
}
type FeedbackIdSeq struct {
Seq int64 //动态Id序列号
}
type MediaIdSeq struct {
Seq int64 `json:"seq" bson:"seq"`
}