fix
add batch delete function to salesLeads, followRecord module
| | |
| | | package v1
|
| | |
|
| | | import (
|
| | | "aps_crm/model"
|
| | | "aps_crm/model/request"
|
| | | "aps_crm/model/response"
|
| | | "aps_crm/pkg/contextx"
|
| | | "aps_crm/pkg/ecode"
|
| | | "github.com/gin-gonic/gin"
|
| | | "strconv"
|
| | | "time"
|
| | | )
|
| | |
|
| | | type FollowRecordApi struct{}
|
| | |
|
| | | // Add
|
| | | //
|
| | | // @Tags FollowRecord
|
| | | // @Summary 添加跟进记录
|
| | | // @Produce application/json
|
| | | // @Param object body request.AddFollowRecord true "查询参数"
|
| | | // @Success 200 {object} contextx.Response{}
|
| | | // @Router /api/followRecord/add [post]
|
| | | func (fr *FollowRecordApi) Add(c *gin.Context) {
|
| | | var params request.AddFollowRecord
|
| | | ctx, ok := contextx.NewContext(c, ¶ms)
|
| | | if !ok {
|
| | | return
|
| | | }
|
| | |
|
| | | errCode, followRecord := checkFollowRecordParams(params.FollowRecord)
|
| | | if errCode != ecode.OK {
|
| | | ctx.Fail(errCode)
|
| | | return
|
| | | }
|
| | |
|
| | | errCode = followRecordService.AddFollowRecord(followRecord)
|
| | | if errCode != ecode.OK {
|
| | | ctx.Fail(errCode)
|
| | | return
|
| | | }
|
| | |
|
| | | ctx.Ok()
|
| | | }
|
| | |
|
| | | // Delete
|
| | | //
|
| | | // @Tags FollowRecord
|
| | | // @Summary 删除跟进记录
|
| | | // @Produce application/json
|
| | | // @Param id path string true "跟进记录id"
|
| | | // @Success 200 {object} contextx.Response{}
|
| | | // @Router /api/followRecord/delete/{id} [delete]
|
| | | func (fr *FollowRecordApi) Delete(c *gin.Context) {
|
| | | ctx, ok := contextx.NewContext(c, nil)
|
| | | if !ok {
|
| | | return
|
| | | }
|
| | |
|
| | | id, _ := strconv.Atoi(c.Param("id"))
|
| | | errCode := followRecordService.DeleteFollowRecord(id)
|
| | | if errCode != ecode.OK {
|
| | | ctx.Fail(errCode)
|
| | | return
|
| | | }
|
| | |
|
| | | ctx.Ok()
|
| | | }
|
| | |
|
| | | // Update
|
| | | //
|
| | | // @Tags FollowRecord
|
| | | // @Summary 更新跟进记录
|
| | | // @Produce application/json
|
| | | // @Param object body request.UpdateFollowRecord true "查询参数"
|
| | | // @Success 200 {object} contextx.Response{}
|
| | | // @Router /api/followRecord/update [put]
|
| | | func (fr *FollowRecordApi) Update(c *gin.Context) {
|
| | | var params request.UpdateFollowRecord
|
| | | ctx, ok := contextx.NewContext(c, ¶ms)
|
| | | if !ok {
|
| | | return
|
| | | }
|
| | |
|
| | | errCode, followRecord := checkFollowRecordParams(params.FollowRecord)
|
| | | if errCode != ecode.OK {
|
| | | ctx.Fail(errCode)
|
| | | return
|
| | | }
|
| | |
|
| | | followRecord.Id = params.Id
|
| | | errCode = followRecordService.UpdateFollowRecord(followRecord)
|
| | | if errCode != ecode.OK {
|
| | | ctx.Fail(errCode)
|
| | | return
|
| | | }
|
| | |
|
| | | ctx.Ok()
|
| | | }
|
| | |
|
| | | // checkFollowRecordParams
|
| | | // 检查跟进记录参数
|
| | | func checkFollowRecordParams(followRecord request.FollowRecord) (int, *model.FollowRecord) {
|
| | | var followRecordModel model.FollowRecord
|
| | |
|
| | | //if followRecord.ClientId != 0 {
|
| | | // // check client exist
|
| | | // if service.CheckClientExist(followRecord.ClientId) != ecode.OK {
|
| | | // return ecode.ClientNotExist, &followRecordModel
|
| | | // }
|
| | | //}
|
| | | //
|
| | | //if followRecord.ContactId != 0 {
|
| | | // // check contact exist
|
| | | // if service.CheckContactExist(followRecord.ContactId) != ecode.OK {
|
| | | // return ecode.ContactNotExist, &followRecordModel
|
| | | // }
|
| | | //}
|
| | | //
|
| | | //if followRecord.SalesLeadsId != 0 {
|
| | | // // check sales leads exist
|
| | | // if service.CheckSalesLeadsExist(followRecord.SalesLeadsId) != ecode.OK {
|
| | | // return ecode.SalesLeadsNotExist, &followRecordModel
|
| | | // }
|
| | | //}
|
| | | //
|
| | | //// check member id
|
| | | //if followRecord.MemberId == 0 {
|
| | | // // todo check member exist
|
| | | // return ecode.InvalidParams, &followRecordModel
|
| | | //}
|
| | | //
|
| | | //// check number
|
| | | //if followRecord.Number == "" {
|
| | | // return ecode.InvalidParams, &followRecordModel
|
| | | //}
|
| | | //
|
| | | //// check follow content
|
| | | //if followRecord.Content == "" {
|
| | | // return ecode.InvalidParams, &followRecordModel
|
| | | //}
|
| | |
|
| | | // check follow time
|
| | | t, err := checkTimeFormat(followRecord.FollowTime)
|
| | | if err != nil {
|
| | | return ecode.InvalidParams, &followRecordModel
|
| | | }
|
| | |
|
| | | followRecordModel.FollowTime = t
|
| | |
|
| | | t, err = checkTimeFormat(followRecord.NextFollowTime)
|
| | | if err != nil {
|
| | | return ecode.InvalidParams, &followRecordModel
|
| | | }
|
| | | followRecordModel.NextFollowTime = t
|
| | |
|
| | | followRecordModel.ClientId = followRecord.ClientId
|
| | | followRecordModel.Content = followRecord.Content
|
| | | followRecordModel.MemberId = followRecord.MemberId
|
| | | followRecordModel.Number = followRecord.Number
|
| | | followRecordModel.ClientStatusId = followRecord.ClientStatusId
|
| | | followRecordModel.ContactId = followRecord.ContactId
|
| | | followRecordModel.Topic = followRecord.Topic
|
| | | followRecordModel.SalesLeadsId = followRecord.SalesLeadsId
|
| | | followRecordModel.SaleChanceId = followRecord.SaleChanceId
|
| | | followRecordModel.ContactInformationId = followRecord.ContactInformationId
|
| | | followRecordModel.Purpose = followRecord.Purpose
|
| | | followRecordModel.Content = followRecord.Content
|
| | | followRecordModel.Record = followRecord.Record
|
| | |
|
| | | return ecode.OK, &followRecordModel
|
| | | }
|
| | |
|
| | | // checkTimeFormat
|
| | | // 检查时间格式
|
| | | func checkTimeFormat(t string) (time.Time, error) {
|
| | | if t == "" {
|
| | | t = "1900-01-01T00:00:00+08:00"
|
| | | }
|
| | |
|
| | | location, err := time.LoadLocation("Asia/Shanghai")
|
| | | if err != nil {
|
| | | return time.Time{}, err
|
| | | }
|
| | |
|
| | | tt, err := time.Parse("2006-01-02T15:04:05.000Z", t)
|
| | | if err == nil {
|
| | | return tt.In(location), nil
|
| | | }
|
| | |
|
| | | tt, err = time.Parse("2006-01-02T15:04:05-07:00", t)
|
| | | if err == nil {
|
| | | return tt.In(location), nil
|
| | | }
|
| | |
|
| | | return time.Time{}, err
|
| | | }
|
| | |
|
| | | // List
|
| | | //
|
| | | // @Tags FollowRecord
|
| | | // @Summary 回访记录列表
|
| | | // @Produce application/json
|
| | | // @Param object body request.GetFollowRecordList true "参数"
|
| | | // @Success 200 {object} contextx.Response{data=response.FollowRecordResponse}
|
| | | // @Router /api/followRecord/list [post]
|
| | | func (fr *FollowRecordApi) List(c *gin.Context) {
|
| | | var params request.GetFollowRecordList
|
| | | ctx, ok := contextx.NewContext(c, ¶ms)
|
| | | if !ok {
|
| | | return
|
| | | }
|
| | |
|
| | | followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword)
|
| | | if errCode != ecode.OK {
|
| | | ctx.Fail(errCode)
|
| | | return
|
| | | }
|
| | |
|
| | | ctx.OkWithDetailed(response.FollowRecordResponse{
|
| | | List: followRecords,
|
| | | Count: int(total),
|
| | | })
|
| | | } |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/gin-gonic/gin" |
| | | "time" |
| | | ) |
| | | |
| | | type FollowRecordApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags FollowRecord |
| | | // @Summary 添加跟进记录 |
| | | // @Produce application/json |
| | | // @Param object body request.AddFollowRecord true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/followRecord/add [post] |
| | | func (fr *FollowRecordApi) Add(c *gin.Context) { |
| | | var params request.AddFollowRecord |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, followRecord := checkFollowRecordParams(params.FollowRecord) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | errCode = followRecordService.AddFollowRecord(followRecord) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags FollowRecord |
| | | // @Summary 删除跟进记录 |
| | | // @Produce application/json |
| | | // @Param object body request.DeleteFollowRecord true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/followRecord/delete [delete] |
| | | func (fr *FollowRecordApi) Delete(c *gin.Context) { |
| | | var params request.DeleteFollowRecord |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode := followRecordService.DeleteFollowRecord(params.Ids) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags FollowRecord |
| | | // @Summary 更新跟进记录 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateFollowRecord true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/followRecord/update [put] |
| | | func (fr *FollowRecordApi) Update(c *gin.Context) { |
| | | var params request.UpdateFollowRecord |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | errCode, followRecord := checkFollowRecordParams(params.FollowRecord) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | followRecord.Id = params.Id |
| | | errCode = followRecordService.UpdateFollowRecord(followRecord) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // checkFollowRecordParams |
| | | // 检查跟进记录参数 |
| | | func checkFollowRecordParams(followRecord request.FollowRecord) (int, *model.FollowRecord) { |
| | | var followRecordModel model.FollowRecord |
| | | |
| | | //if followRecord.ClientId != 0 { |
| | | // // check client exist |
| | | // if service.CheckClientExist(followRecord.ClientId) != ecode.OK { |
| | | // return ecode.ClientNotExist, &followRecordModel |
| | | // } |
| | | //} |
| | | // |
| | | //if followRecord.ContactId != 0 { |
| | | // // check contact exist |
| | | // if service.CheckContactExist(followRecord.ContactId) != ecode.OK { |
| | | // return ecode.ContactNotExist, &followRecordModel |
| | | // } |
| | | //} |
| | | // |
| | | //if followRecord.SalesLeadsId != 0 { |
| | | // // check sales leads exist |
| | | // if service.CheckSalesLeadsExist(followRecord.SalesLeadsId) != ecode.OK { |
| | | // return ecode.SalesLeadsNotExist, &followRecordModel |
| | | // } |
| | | //} |
| | | // |
| | | //// check member id |
| | | //if followRecord.MemberId == 0 { |
| | | // // todo check member exist |
| | | // return ecode.InvalidParams, &followRecordModel |
| | | //} |
| | | // |
| | | //// check number |
| | | //if followRecord.Number == "" { |
| | | // return ecode.InvalidParams, &followRecordModel |
| | | //} |
| | | // |
| | | //// check follow content |
| | | //if followRecord.Content == "" { |
| | | // return ecode.InvalidParams, &followRecordModel |
| | | //} |
| | | |
| | | // check follow time |
| | | t, err := checkTimeFormat(followRecord.FollowTime) |
| | | if err != nil { |
| | | return ecode.InvalidParams, &followRecordModel |
| | | } |
| | | |
| | | followRecordModel.FollowTime = t |
| | | |
| | | t, err = checkTimeFormat(followRecord.NextFollowTime) |
| | | if err != nil { |
| | | return ecode.InvalidParams, &followRecordModel |
| | | } |
| | | followRecordModel.NextFollowTime = t |
| | | |
| | | followRecordModel.ClientId = followRecord.ClientId |
| | | followRecordModel.Content = followRecord.Content |
| | | followRecordModel.MemberId = followRecord.MemberId |
| | | followRecordModel.Number = followRecord.Number |
| | | followRecordModel.ClientStatusId = followRecord.ClientStatusId |
| | | followRecordModel.ContactId = followRecord.ContactId |
| | | followRecordModel.Topic = followRecord.Topic |
| | | followRecordModel.SalesLeadsId = followRecord.SalesLeadsId |
| | | followRecordModel.SaleChanceId = followRecord.SaleChanceId |
| | | followRecordModel.ContactInformationId = followRecord.ContactInformationId |
| | | followRecordModel.Purpose = followRecord.Purpose |
| | | followRecordModel.Content = followRecord.Content |
| | | followRecordModel.Record = followRecord.Record |
| | | |
| | | return ecode.OK, &followRecordModel |
| | | } |
| | | |
| | | // checkTimeFormat |
| | | // 检查时间格式 |
| | | func checkTimeFormat(t string) (time.Time, error) { |
| | | if t == "" { |
| | | t = "1900-01-01T00:00:00+08:00" |
| | | } |
| | | |
| | | location, err := time.LoadLocation("Asia/Shanghai") |
| | | if err != nil { |
| | | return time.Time{}, err |
| | | } |
| | | |
| | | tt, err := time.Parse("2006-01-02T15:04:05.000Z", t) |
| | | if err == nil { |
| | | return tt.In(location), nil |
| | | } |
| | | |
| | | tt, err = time.Parse("2006-01-02T15:04:05-07:00", t) |
| | | if err == nil { |
| | | return tt.In(location), nil |
| | | } |
| | | |
| | | return time.Time{}, err |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags FollowRecord |
| | | // @Summary 回访记录列表 |
| | | // @Produce application/json |
| | | // @Param object body request.GetFollowRecordList true "参数" |
| | | // @Success 200 {object} contextx.Response{data=response.FollowRecordResponse} |
| | | // @Router /api/followRecord/list [post] |
| | | func (fr *FollowRecordApi) List(c *gin.Context) { |
| | | var params request.GetFollowRecordList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | followRecords, total, errCode := followRecordService.GetFollowRecordList(params.Page, params.PageSize, params.Keyword) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.FollowRecordResponse{ |
| | | List: followRecords, |
| | | Count: int(total), |
| | | }) |
| | | } |
| | |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | | |
| | | type SalesLeadsApi struct{} |
| | |
| | | // @Tags SalesLeads |
| | | // @Summary 删除销售线索 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Param object body request.DeleteSalesLeads true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/salesLeads/delete/{id} [delete] |
| | | // @Router /api/salesLeads/delete [delete] |
| | | func (s *SalesLeadsApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | var params request.DeleteSalesLeads |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := salesLeadsService.DeleteSalesLeads(id) |
| | | errCode := salesLeadsService.DeleteSalesLeads(params.Ids) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/followRecord/delete/{id}": { |
| | | "/api/followRecord/delete": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "summary": "删除跟进记录", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "跟进记录id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeleteFollowRecord" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/delete/{id}": { |
| | | "/api/salesLeads/delete": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "summary": "删除销售线索", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeleteSalesLeads" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteFollowRecord": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteUserReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/followRecord/delete/{id}": { |
| | | "/api/followRecord/delete": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "summary": "删除跟进记录", |
| | | "parameters": [ |
| | | { |
| | | "type": "string", |
| | | "description": "跟进记录id", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | "description": "查询参数", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeleteFollowRecord" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api/salesLeads/delete/{id}": { |
| | | "/api/salesLeads/delete": { |
| | | "delete": { |
| | | "produces": [ |
| | | "application/json" |
| | |
| | | "summary": "删除销售线索", |
| | | "parameters": [ |
| | | { |
| | | "type": "integer", |
| | | "description": "查询参数", |
| | | "name": "id", |
| | | "in": "path", |
| | | "required": true |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeleteSalesLeads" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteFollowRecord": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteSalesLeads": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteUserReq": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | description: 国家ID |
| | | type: integer |
| | | type: object |
| | | request.DeleteFollowRecord: |
| | | properties: |
| | | ids: |
| | | items: |
| | | type: integer |
| | | type: array |
| | | type: object |
| | | request.DeleteSalesLeads: |
| | | properties: |
| | | ids: |
| | | items: |
| | | type: integer |
| | | type: array |
| | | type: object |
| | | request.DeleteUserReq: |
| | | properties: |
| | | userId: |
| | |
| | | summary: 添加跟进记录 |
| | | tags: |
| | | - FollowRecord |
| | | /api/followRecord/delete/{id}: |
| | | /api/followRecord/delete: |
| | | delete: |
| | | parameters: |
| | | - description: 跟进记录id |
| | | in: path |
| | | name: id |
| | | - description: 查询参数 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | type: string |
| | | schema: |
| | | $ref: '#/definitions/request.DeleteFollowRecord' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | summary: 添加销售线索 |
| | | tags: |
| | | - SalesLeads |
| | | /api/salesLeads/delete/{id}: |
| | | /api/salesLeads/delete: |
| | | delete: |
| | | parameters: |
| | | - description: 查询参数 |
| | | in: path |
| | | name: id |
| | | in: body |
| | | name: object |
| | | required: true |
| | | type: integer |
| | | schema: |
| | | $ref: '#/definitions/request.DeleteSalesLeads' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | package model
|
| | |
|
| | | import (
|
| | | "aps_crm/pkg/mysqlx"
|
| | | "gorm.io/gorm"
|
| | | "time"
|
| | | )
|
| | |
|
| | | type (
|
| | | FollowRecord struct {
|
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
|
| | | ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户id"`
|
| | | ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态id"`
|
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:跟进人id"`
|
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:跟进编号"`
|
| | | ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人id"`
|
| | | Topic string `json:"topic" gorm:"column:topic;type:varchar(255);comment:跟进主题"`
|
| | | Record string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:跟进记录"`
|
| | | SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"`
|
| | | SalesLeadsId int `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:销售线索id"`
|
| | | ContactInformationId int `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:联系方式id"`
|
| | | FollowTime time.Time `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:跟进时间"`
|
| | | NextFollowTime time.Time `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"`
|
| | | Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"`
|
| | | Content string `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:跟进内容"`
|
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"`
|
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId"`
|
| | | gorm.Model `json:"-"`
|
| | | }
|
| | |
|
| | | FollowRecordSearch struct {
|
| | | FollowRecord
|
| | |
|
| | | Orm *gorm.DB
|
| | | Keyword string
|
| | | OrderBy string
|
| | | PageNum int
|
| | | PageSize int
|
| | | }
|
| | | )
|
| | |
|
| | | func (FollowRecord) TableName() string {
|
| | | return "follow_records"
|
| | | }
|
| | |
|
| | | func NewFollowRecordSearch() *FollowRecordSearch {
|
| | | return &FollowRecordSearch{
|
| | | Orm: mysqlx.GetDB(),
|
| | | }
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) build() *gorm.DB {
|
| | | var db = slf.Orm.Model(&FollowRecord{})
|
| | | if slf.Keyword != "" {
|
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%")
|
| | | }
|
| | | if slf.Keyword != "" {
|
| | | db = db.Where("topic LIKE ?", "%"+slf.Keyword+"%")
|
| | | }
|
| | | if slf.Id != 0 {
|
| | | db = db.Where("id = ?", slf.Id)
|
| | | }
|
| | | if slf.ClientId != 0 {
|
| | | db = db.Where("client_id = ?", slf.ClientId)
|
| | | }
|
| | | if slf.ClientStatusId != 0 {
|
| | | db = db.Where("client_status_id = ?", slf.ClientStatusId)
|
| | | }
|
| | | if slf.MemberId != 0 {
|
| | | db = db.Where("member_id = ?", slf.MemberId)
|
| | | }
|
| | | if slf.Number != "" {
|
| | | db = db.Where("number = ?", slf.Number)
|
| | | }
|
| | | if slf.ContactId != 0 {
|
| | | db = db.Where("contact_id = ?", slf.ContactId)
|
| | | }
|
| | | if slf.Topic != "" {
|
| | | db = db.Where("topic = ?", slf.Topic)
|
| | | }
|
| | | if slf.Record != "" {
|
| | | db = db.Where("record = ?", slf.Record)
|
| | | }
|
| | | if slf.SaleChanceId != 0 {
|
| | | db = db.Where("sale_chance_id = ?", slf.SaleChanceId)
|
| | | }
|
| | | if slf.SalesLeadsId != 0 {
|
| | | db = db.Where("sales_leads_id = ?", slf.SalesLeadsId)
|
| | | }
|
| | | if slf.ContactInformationId != 0 {
|
| | | db = db.Where("contact_information_id = ?", slf.ContactInformationId)
|
| | | }
|
| | | if !slf.FollowTime.IsZero() {
|
| | | db = db.Where("follow_time = ?", slf.FollowTime)
|
| | | }
|
| | | if !slf.NextFollowTime.IsZero() {
|
| | | db = db.Where("next_follow_time = ?", slf.NextFollowTime)
|
| | | }
|
| | | if slf.Purpose != "" {
|
| | | db = db.Where("purpose = ?", slf.Purpose)
|
| | | }
|
| | | if slf.Content != "" {
|
| | | db = db.Where("content = ?", slf.Content)
|
| | | }
|
| | |
|
| | | return db
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) First() (*FollowRecord, error) {
|
| | | var record = new(FollowRecord)
|
| | | err := slf.build().First(record).Error
|
| | | return record, err
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) FindAll() ([]*FollowRecord, int64, error) {
|
| | | var db = slf.build()
|
| | | var records = make([]*FollowRecord, 0)
|
| | | var total int64
|
| | | if err := db.Count(&total).Error; err != nil {
|
| | | return records, total, err
|
| | | }
|
| | | if slf.PageNum > 0 && slf.PageSize > 0 {
|
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize)
|
| | | }
|
| | |
|
| | | err := db.Preload("Client").Preload("Contact").Find(&records).Error
|
| | | return records, total, err
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) Count() (int64, error) {
|
| | | var count int64
|
| | | err := slf.build().Count(&count).Error
|
| | | return count, err
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) Page(page, pageSize int) ([]*FollowRecord, int64, error) {
|
| | | var records = make([]*FollowRecord, 0)
|
| | | var count int64
|
| | | err := slf.build().Count(&count).Error
|
| | | if err != nil {
|
| | | return records, count, err
|
| | | }
|
| | | err = slf.build().Offset((page - 1) * pageSize).Limit(pageSize).Find(&records).Error
|
| | | return records, count, err
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) Create(record *FollowRecord) error {
|
| | | var db = slf.build()
|
| | | return db.Create(record).Error
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) Update(record *FollowRecord) error {
|
| | | var db = slf.build()
|
| | | return db.Updates(record).Error
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) Delete() error {
|
| | | var db = slf.build()
|
| | | return db.Delete(&slf.FollowRecord).Error
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) SetId(id int) *FollowRecordSearch {
|
| | | slf.Id = id
|
| | | return slf
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) SetClientId(clientId int) *FollowRecordSearch {
|
| | | slf.ClientId = clientId
|
| | | return slf
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) SetKeyword(keyword string) *FollowRecordSearch {
|
| | | slf.Keyword = keyword
|
| | | return slf
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) SetPage(page, size int) *FollowRecordSearch {
|
| | | slf.PageNum, slf.PageSize = page, size
|
| | | return slf
|
| | | }
|
| | |
|
| | | func (slf *FollowRecordSearch) SetOrder(order string) *FollowRecordSearch {
|
| | | slf.OrderBy = order
|
| | | return slf
|
| | | }
|
| | | package model |
| | | |
| | | import ( |
| | | "aps_crm/pkg/mysqlx" |
| | | "gorm.io/gorm" |
| | | "time" |
| | | ) |
| | | |
| | | type ( |
| | | FollowRecord struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户id"` |
| | | ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态id"` |
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:跟进人id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:跟进编号"` |
| | | ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人id"` |
| | | Topic string `json:"topic" gorm:"column:topic;type:varchar(255);comment:跟进主题"` |
| | | Record string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:跟进记录"` |
| | | SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"` |
| | | SalesLeadsId int `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:销售线索id"` |
| | | ContactInformationId int `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:联系方式id"` |
| | | FollowTime time.Time `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:跟进时间"` |
| | | NextFollowTime time.Time `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"` |
| | | Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"` |
| | | Content string `json:"content" gorm:"column:content;type:MEDIUMTEXT;comment:跟进内容"` |
| | | Client Client `json:"client" gorm:"foreignKey:ClientId"` |
| | | Contact Contact `json:"contact" gorm:"foreignKey:ContactId"` |
| | | gorm.Model `json:"-"` |
| | | } |
| | | |
| | | FollowRecordSearch struct { |
| | | FollowRecord |
| | | |
| | | Orm *gorm.DB |
| | | Keyword string |
| | | OrderBy string |
| | | PageNum int |
| | | PageSize int |
| | | } |
| | | ) |
| | | |
| | | func (FollowRecord) TableName() string { |
| | | return "follow_records" |
| | | } |
| | | |
| | | func NewFollowRecordSearch() *FollowRecordSearch { |
| | | return &FollowRecordSearch{ |
| | | Orm: mysqlx.GetDB(), |
| | | } |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) build() *gorm.DB { |
| | | var db = slf.Orm.Model(&FollowRecord{}) |
| | | if slf.Keyword != "" { |
| | | db = db.Where("name LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Keyword != "" { |
| | | db = db.Where("topic LIKE ?", "%"+slf.Keyword+"%") |
| | | } |
| | | if slf.Id != 0 { |
| | | db = db.Where("id = ?", slf.Id) |
| | | } |
| | | if slf.ClientId != 0 { |
| | | db = db.Where("client_id = ?", slf.ClientId) |
| | | } |
| | | if slf.ClientStatusId != 0 { |
| | | db = db.Where("client_status_id = ?", slf.ClientStatusId) |
| | | } |
| | | if slf.MemberId != 0 { |
| | | db = db.Where("member_id = ?", slf.MemberId) |
| | | } |
| | | if slf.Number != "" { |
| | | db = db.Where("number = ?", slf.Number) |
| | | } |
| | | if slf.ContactId != 0 { |
| | | db = db.Where("contact_id = ?", slf.ContactId) |
| | | } |
| | | if slf.Topic != "" { |
| | | db = db.Where("topic = ?", slf.Topic) |
| | | } |
| | | if slf.Record != "" { |
| | | db = db.Where("record = ?", slf.Record) |
| | | } |
| | | if slf.SaleChanceId != 0 { |
| | | db = db.Where("sale_chance_id = ?", slf.SaleChanceId) |
| | | } |
| | | if slf.SalesLeadsId != 0 { |
| | | db = db.Where("sales_leads_id = ?", slf.SalesLeadsId) |
| | | } |
| | | if slf.ContactInformationId != 0 { |
| | | db = db.Where("contact_information_id = ?", slf.ContactInformationId) |
| | | } |
| | | if !slf.FollowTime.IsZero() { |
| | | db = db.Where("follow_time = ?", slf.FollowTime) |
| | | } |
| | | if !slf.NextFollowTime.IsZero() { |
| | | db = db.Where("next_follow_time = ?", slf.NextFollowTime) |
| | | } |
| | | if slf.Purpose != "" { |
| | | db = db.Where("purpose = ?", slf.Purpose) |
| | | } |
| | | if slf.Content != "" { |
| | | db = db.Where("content = ?", slf.Content) |
| | | } |
| | | |
| | | return db |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) First() (*FollowRecord, error) { |
| | | var record = new(FollowRecord) |
| | | err := slf.build().First(record).Error |
| | | return record, err |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) FindAll() ([]*FollowRecord, int64, error) { |
| | | var db = slf.build() |
| | | var records = make([]*FollowRecord, 0) |
| | | var total int64 |
| | | if err := db.Count(&total).Error; err != nil { |
| | | return records, total, err |
| | | } |
| | | if slf.PageNum > 0 && slf.PageSize > 0 { |
| | | db = db.Limit(slf.PageSize).Offset((slf.PageNum - 1) * slf.PageSize) |
| | | } |
| | | |
| | | err := db.Preload("Client").Preload("Contact").Find(&records).Error |
| | | return records, total, err |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) Count() (int64, error) { |
| | | var count int64 |
| | | err := slf.build().Count(&count).Error |
| | | return count, err |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) Page(page, pageSize int) ([]*FollowRecord, int64, error) { |
| | | var records = make([]*FollowRecord, 0) |
| | | var count int64 |
| | | err := slf.build().Count(&count).Error |
| | | if err != nil { |
| | | return records, count, err |
| | | } |
| | | err = slf.build().Offset((page - 1) * pageSize).Limit(pageSize).Find(&records).Error |
| | | return records, count, err |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) Create(record *FollowRecord) error { |
| | | var db = slf.build() |
| | | return db.Create(record).Error |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) Update(record *FollowRecord) error { |
| | | var db = slf.build() |
| | | return db.Updates(record).Error |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) Delete() error { |
| | | var db = slf.build() |
| | | return db.Delete(&slf.FollowRecord).Error |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetId(id int) *FollowRecordSearch { |
| | | slf.Id = id |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetClientId(clientId int) *FollowRecordSearch { |
| | | slf.ClientId = clientId |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetKeyword(keyword string) *FollowRecordSearch { |
| | | slf.Keyword = keyword |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetPage(page, size int) *FollowRecordSearch { |
| | | slf.PageNum, slf.PageSize = page, size |
| | | return slf |
| | | } |
| | | |
| | | func (slf *FollowRecordSearch) SetOrder(order string) *FollowRecordSearch { |
| | | slf.OrderBy = order |
| | | return slf |
| | | } |
| | | func (slf *FollowRecordSearch) SetIds(ids []int) *FollowRecordSearch { |
| | | slf.Orm = slf.Orm.Where("id in (?)", ids) |
| | | return slf |
| | | } |
| | |
| | | package request
|
| | |
|
| | | type AddFollowRecord struct {
|
| | | FollowRecord FollowRecord `json:"follow_record" binding:"required"`
|
| | | }
|
| | |
|
| | | type FollowRecord struct {
|
| | | ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户id"`
|
| | | ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态id"`
|
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:跟进人id"`
|
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:跟进编号"`
|
| | | ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人id"`
|
| | | Topic string `json:"topic" gorm:"column:topic;type:varchar(255);comment:跟进主题"`
|
| | | Record string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:跟进记录"`
|
| | | SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"`
|
| | | SalesLeadsId int `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:销售线索id"`
|
| | | ContactInformationId int `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:联系方式id"`
|
| | | FollowTime string `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:跟进时间"`
|
| | | NextFollowTime string `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"`
|
| | | Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"`
|
| | | Content string `json:"content" gorm:"column:content;type:varchar(255);comment:跟进内容"`
|
| | | }
|
| | |
|
| | | type UpdateFollowRecord struct {
|
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
|
| | | FollowRecord FollowRecord `json:"follow_record" binding:"required"`
|
| | | }
|
| | |
|
| | | type GetFollowRecordList struct {
|
| | | PageInfo
|
| | | Keyword string `json:"keyword"`
|
| | | }
|
| | | package request |
| | | |
| | | type AddFollowRecord struct { |
| | | FollowRecord FollowRecord `json:"follow_record" binding:"required"` |
| | | } |
| | | |
| | | type FollowRecord struct { |
| | | ClientId int `json:"client_id" gorm:"column:client_id;type:int(11);comment:客户id"` |
| | | ClientStatusId int `json:"client_status_id" gorm:"column:client_status_id;type:int(11);comment:客户状态id"` |
| | | MemberId int `json:"member_id" gorm:"column:member_id;type:int(11);comment:跟进人id"` |
| | | Number string `json:"number" gorm:"column:number;type:varchar(255);comment:跟进编号"` |
| | | ContactId int `json:"contact_id" gorm:"column:contact_id;type:int(11);comment:联系人id"` |
| | | Topic string `json:"topic" gorm:"column:topic;type:varchar(255);comment:跟进主题"` |
| | | Record string `json:"record" gorm:"column:record;type:MEDIUMTEXT;comment:跟进记录"` |
| | | SaleChanceId int `json:"sale_chance_id" gorm:"column:sale_chance_id;type:int(11);comment:销售机会id"` |
| | | SalesLeadsId int `json:"sales_leads_id" gorm:"column:sales_leads_id;type:int(11);comment:销售线索id"` |
| | | ContactInformationId int `json:"contact_information_id" gorm:"column:contact_information_id;type:int(11);comment:联系方式id"` |
| | | FollowTime string `json:"follow_time" gorm:"column:follow_time;type:datetime;comment:跟进时间"` |
| | | NextFollowTime string `json:"next_follow_time" gorm:"column:next_follow_time;type:datetime;comment:下次跟进时间"` |
| | | Purpose string `json:"purpose" gorm:"column:purpose;type:varchar(255);comment:跟进目的"` |
| | | Content string `json:"content" gorm:"column:content;type:varchar(255);comment:跟进内容"` |
| | | } |
| | | |
| | | type UpdateFollowRecord struct { |
| | | Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` |
| | | FollowRecord FollowRecord `json:"follow_record" binding:"required"` |
| | | } |
| | | |
| | | type GetFollowRecordList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | | |
| | | type DeleteFollowRecord struct { |
| | | Ids []int `json:"ids"` |
| | | } |
| | |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | | |
| | | type DeleteSalesLeads struct { |
| | | Ids []int `json:"ids"` |
| | | } |
| | |
| | | var db = slf.build() |
| | | return db.Updates(data).Error |
| | | } |
| | | func (slf *SalesLeadsSearch) SetIds(ids []int) *SalesLeadsSearch { |
| | | slf.Orm = slf.Orm.Where("id in (?)", ids) |
| | | return slf |
| | | } |
| | |
| | | followRecordApi := v1.ApiGroup.FollowRecordApi |
| | | { |
| | | followRecordRouter.POST("add", followRecordApi.Add) // 添加跟进记录 |
| | | followRecordRouter.DELETE("delete/:id", followRecordApi.Delete) // 删除跟进记录 |
| | | followRecordRouter.DELETE("delete", followRecordApi.Delete) // 删除跟进记录 |
| | | followRecordRouter.PUT("update", followRecordApi.Update) // 更新跟进记录 |
| | | followRecordRouter.POST("list", followRecordApi.List) // 获取跟进记录列表 |
| | | } |
| | |
| | | salesLeadsApi := v1.ApiGroup.SalesLeadsApi |
| | | { |
| | | salesLeadsRouter.POST("add", salesLeadsApi.Add) // 添加销售线索 |
| | | salesLeadsRouter.DELETE("delete/:id", salesLeadsApi.Delete) // 删除销售线索 |
| | | salesLeadsRouter.DELETE("delete", salesLeadsApi.Delete) // 删除销售线索 |
| | | salesLeadsRouter.PUT("update", salesLeadsApi.Update) // 更新销售线索 |
| | | salesLeadsRouter.POST("list", salesLeadsApi.List) // 获取销售线索列表 |
| | | } |
| | |
| | | package service
|
| | |
|
| | | import (
|
| | | "aps_crm/model"
|
| | | "aps_crm/pkg/ecode"
|
| | | )
|
| | |
|
| | | type FollowRecordService struct{}
|
| | |
|
| | | func (FollowRecordService) AddFollowRecord(followRecord *model.FollowRecord) int {
|
| | | err := model.NewFollowRecordSearch().Create(followRecord)
|
| | | if err != nil {
|
| | | return ecode.FollowRecordExist
|
| | | }
|
| | | return ecode.OK
|
| | | }
|
| | |
|
| | | func (FollowRecordService) DeleteFollowRecord(id int) int {
|
| | | // check followRecord exist
|
| | | _, err := model.NewFollowRecordSearch().SetId(id).First()
|
| | | if err != nil {
|
| | | return ecode.FollowRecordNotExist
|
| | | }
|
| | |
|
| | | // delete followRecord
|
| | | err = model.NewFollowRecordSearch().SetId(id).Delete()
|
| | | if err != nil {
|
| | | return ecode.FollowRecordDeleteErr
|
| | | }
|
| | | return ecode.OK
|
| | | }
|
| | |
|
| | | // check followRecord exist
|
| | | func checkFollowRecordExist(id int) int {
|
| | | _, err := model.NewFollowRecordSearch().SetId(id).First()
|
| | | if err != nil {
|
| | | return ecode.FollowRecordNotExist
|
| | | }
|
| | |
|
| | | return ecode.OK
|
| | | }
|
| | |
|
| | | func (FollowRecordService) UpdateFollowRecord(followRecord *model.FollowRecord) int {
|
| | | // check followRecord exist
|
| | | errCode := checkFollowRecordExist(followRecord.Id)
|
| | | if errCode != ecode.OK {
|
| | | return errCode
|
| | | }
|
| | |
|
| | | // update followRecord
|
| | | err := model.NewFollowRecordSearch().SetId(followRecord.Id).Update(followRecord)
|
| | | if err != nil {
|
| | | return ecode.FollowRecordUpdateErr
|
| | | }
|
| | | return ecode.OK
|
| | | }
|
| | |
|
| | | func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int64, int) {
|
| | | // get contact list
|
| | | contacts, total, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll()
|
| | | if err != nil {
|
| | | return nil, 0, ecode.FollowRecordListErr
|
| | | }
|
| | | return contacts, total, ecode.OK
|
| | | } |
| | | package service |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/pkg/ecode" |
| | | ) |
| | | |
| | | type FollowRecordService struct{} |
| | | |
| | | func (FollowRecordService) AddFollowRecord(followRecord *model.FollowRecord) int { |
| | | err := model.NewFollowRecordSearch().Create(followRecord) |
| | | if err != nil { |
| | | return ecode.FollowRecordExist |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | // check followRecord exist |
| | | func checkFollowRecordExist(id int) int { |
| | | _, err := model.NewFollowRecordSearch().SetId(id).First() |
| | | if err != nil { |
| | | return ecode.FollowRecordNotExist |
| | | } |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (FollowRecordService) UpdateFollowRecord(followRecord *model.FollowRecord) int { |
| | | // check followRecord exist |
| | | errCode := checkFollowRecordExist(followRecord.Id) |
| | | if errCode != ecode.OK { |
| | | return errCode |
| | | } |
| | | |
| | | // update followRecord |
| | | err := model.NewFollowRecordSearch().SetId(followRecord.Id).Update(followRecord) |
| | | if err != nil { |
| | | return ecode.FollowRecordUpdateErr |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (FollowRecordService) GetFollowRecordList(page, pageSize int, keyword string) ([]*model.FollowRecord, int64, int) { |
| | | // get contact list |
| | | contacts, total, err := model.NewFollowRecordSearch().SetKeyword(keyword).SetPage(page, pageSize).FindAll() |
| | | if err != nil { |
| | | return nil, 0, ecode.FollowRecordListErr |
| | | } |
| | | return contacts, total, ecode.OK |
| | | } |
| | | |
| | | func (FollowRecordService) DeleteFollowRecord(ids []int) int { |
| | | // delete client |
| | | err := model.NewFollowRecordSearch().SetIds(ids).Delete() |
| | | if err != nil { |
| | | return ecode.FollowRecordDeleteErr |
| | | } |
| | | return ecode.OK |
| | | } |
| | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesLeadsService) DeleteSalesLeads(id int) int { |
| | | // check salesLeads exist |
| | | _, err := model.NewSalesLeadsSearch().SetId(id).Find() |
| | | if err != nil { |
| | | return ecode.SalesLeadsNotExist |
| | | } |
| | | |
| | | // delete salesLeads |
| | | err = model.NewSalesLeadsSearch().SetId(id).Delete() |
| | | if err != nil { |
| | | return ecode.SalesLeadsDeleteErr |
| | | } |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesLeadsService) UpdateSalesLeads(salesLeads *model.SalesLeads) int { |
| | | // update salesLeads |
| | | err := model.NewSalesLeadsSearch().SetId(salesLeads.Id).Update(salesLeads) |
| | |
| | | |
| | | return ecode.OK |
| | | } |
| | | |
| | | func (SalesLeadsService) DeleteSalesLeads(ids []int) int { |
| | | // delete client |
| | | err := model.NewSalesLeadsSearch().SetIds(ids).Delete() |
| | | if err != nil { |
| | | return ecode.SalesLeadsDeleteErr |
| | | } |
| | | return ecode.OK |
| | | } |