From 63b531279a8ab1d609910e7db53add83bbc0b97a Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 17 十月 2023 20:21:01 +0800
Subject: [PATCH] 添加默认数据
---
api/v1/followRecord.go | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/api/v1/followRecord.go b/api/v1/followRecord.go
index e015177..d64b85a 100644
--- a/api/v1/followRecord.go
+++ b/api/v1/followRecord.go
@@ -1,11 +1,14 @@
package v1
import (
+ "aps_crm/constvar"
"aps_crm/model"
"aps_crm/model/request"
"aps_crm/model/response"
"aps_crm/pkg/contextx"
"aps_crm/pkg/ecode"
+ "aps_crm/utils"
+ "errors"
"github.com/gin-gonic/gin"
"time"
)
@@ -33,10 +36,24 @@
return
}
+ if followRecord.MemberId == 0 {
+ userInfo := utils.GetUserInfo(c)
+ if userInfo.UserType == constvar.UserTypeSub {
+ followRecord.MemberId = userInfo.CrmUserId
+ }
+ }
+
errCode = followRecordService.AddFollowRecord(followRecord)
if errCode != ecode.OK {
ctx.Fail(errCode)
return
+ }
+ if params.FollowRecord.CodeRule.Method == 1 {
+ autoCode := model.GetAutoCode(followRecord.Id, ¶ms.FollowRecord.CodeRule)
+ m := map[string]interface{}{
+ "number": autoCode,
+ }
+ _ = model.NewFollowRecordSearch().SetId(followRecord.Id).UpdateMap(m)
}
ctx.Ok()
@@ -166,33 +183,44 @@
followRecordModel.Purpose = followRecord.Purpose
followRecordModel.Content = followRecord.Content
followRecordModel.Record = followRecord.Record
+ followRecordModel.CodeStandID = followRecord.CodeStandID
return ecode.OK, &followRecordModel
}
// checkTimeFormat
// 妫�鏌ユ椂闂存牸寮�
-func checkTimeFormat(t string) (time.Time, error) {
+func checkTimeFormat(t string) (*model.CustomTime, error) {
if t == "" {
- t = "1900-01-01T00:00:00+08:00"
+ return nil, nil
}
location, err := time.LoadLocation("Asia/Shanghai")
if err != nil {
- return time.Time{}, err
+ return nil, err
}
- tt, err := time.Parse("2006-01-02T15:04:05.000Z", t)
+ tt, err := time.Parse("2006-01-02", t)
if err == nil {
- return tt.In(location), nil
+ ret := tt.In(location)
+ tmp := model.CustomTime(ret)
+ return &tmp, nil
}
- tt, err = time.Parse("2006-01-02T15:04:05-07:00", t)
+ tt, err = time.Parse("2006-01-02 15:04:05", t)
if err == nil {
- return tt.In(location), nil
+ ret := tt.In(location)
+ tmp := model.CustomTime(ret)
+ return &tmp, nil
}
- return time.Time{}, err
+ //tt, err = time.Parse("2006-01-02T15:04:05-07:00", t)
+ //if err == nil {
+ // ret := tt.In(location)
+ // return &ret, nil
+ //}
+
+ return nil, errors.New("invalid time format")
}
// List
@@ -210,6 +238,14 @@
return
}
+ userInfo := utils.GetUserInfo(c)
+ if userInfo.UserType == constvar.UserTypeSub {
+ if params.SearchMap == nil {
+ params.SearchMap = make(map[string]interface{}, 0)
+ }
+ params.SearchMap["member_id"] = userInfo.CrmUserId
+ }
+
followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.SearchMap)
if errCode != ecode.OK {
ctx.Fail(errCode)
--
Gitblit v1.8.0