| | |
| | | // @Tags ServiceContract |
| | | // @Summary 删除服务合同 |
| | | // @Produce application/json |
| | | // @Param object body request.DeleteserviceContract true "查询参数" |
| | | // @Param object body request.DeleteServiceContract true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContract/delete [delete] |
| | | func (s *ServiceContractApi) Delete(c *gin.Context) { |
| | | var params request.DeleteserviceContract |
| | | var params request.DeleteServiceContract |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | |
| | | |
| | | // check params |
| | | func checkServiceContractParams(serviceContract request.ServiceContract) (errCode int, result model.ServiceContract) { |
| | | //if serviceContract.SignTime == "" { |
| | | // return ecode.InvalidParams, result |
| | | //} |
| | | // |
| | | //if serviceContract.Number == "" { |
| | | // return ecode.InvalidParams, result |
| | | //} |
| | | // |
| | | //if serviceContract.MemberId <= 0 { |
| | | // return ecode.InvalidParams, result |
| | | //} |
| | | |
| | | t, err := checkTimeFormat(serviceContract.SignTime) |
| | | if err != nil { |
| | | return ecode.InvalidParams, result |
| | | } |
| | | |
| | | result.SignTime = t |
| | | |
| | | t, err = checkTimeFormat(serviceContract.StartTime) |
| | | if err != nil { |
| | | return ecode.InvalidParams, result |
| | | } |
| | | |
| | | result.StartTime = t |
| | | |
| | | t, err = checkTimeFormat(serviceContract.EndTime) |
| | | if err != nil { |
| | | return ecode.InvalidParams, result |
| | | } |
| | | |
| | | result.EndTime = t |
| | | |
| | | result.Number = serviceContract.Number |
| | | result.MemberId = serviceContract.MemberId |
| | | result.Remark = serviceContract.Remark |
| | | result.ClientId = serviceContract.ClientId |
| | | result.ContactId = serviceContract.ContactId |
| | | result.SalesDetailsId = serviceContract.SalesDetailsId |
| | | result.SaleChanceId = serviceContract.SaleChanceId |
| | | result.QuotationId = serviceContract.QuotationId |
| | | result.ServiceContractTypeId = serviceContract.TypeId |
| | |
| | | result.ServiceTimes = serviceContract.ServiceTimes |
| | | result.Terms = serviceContract.Terms |
| | | result.Products = serviceContract.Products |
| | | result.SignTime = serviceContract.SignTime |
| | | result.StartTime = serviceContract.StartTime |
| | | result.EndTime = serviceContract.EndTime |
| | | |
| | | return ecode.OK, result |
| | | } |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeleteserviceContract" |
| | | "$ref": "#/definitions/request.DeleteServiceContract" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | | "contractId": { |
| | | "type": "integer" |
| | | }, |
| | | "endTime": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "type": "string" |
| | | }, |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetailsId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteServiceFeeManage": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "userId": { |
| | | "description": "用户ID", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteserviceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | | "contractId": { |
| | | "type": "integer" |
| | | }, |
| | | "endTime": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetailsId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.DeleteserviceContract" |
| | | "$ref": "#/definitions/request.DeleteServiceContract" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | | "contractId": { |
| | | "type": "integer" |
| | | }, |
| | | "endTime": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "type": "string" |
| | | }, |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetailsId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteServiceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteServiceFeeManage": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | "userId": { |
| | | "description": "用户ID", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.DeleteserviceContract": { |
| | | "type": "object", |
| | | "properties": { |
| | | "ids": { |
| | | "type": "array", |
| | | "items": { |
| | | "type": "integer" |
| | | } |
| | | } |
| | | } |
| | | }, |
| | |
| | | "contactId": { |
| | | "type": "integer" |
| | | }, |
| | | "contractId": { |
| | | "type": "integer" |
| | | }, |
| | | "endTime": { |
| | | "type": "string" |
| | | }, |
| | |
| | | "saleChanceId": { |
| | | "type": "integer" |
| | | }, |
| | | "salesDetailsId": { |
| | | "type": "integer" |
| | | }, |
| | | "serviceTimes": { |
| | | "type": "integer" |
| | | }, |
| | |
| | | type: integer |
| | | contactId: |
| | | type: integer |
| | | contractId: |
| | | type: integer |
| | | endTime: |
| | | type: string |
| | | memberId: |
| | |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | | type: integer |
| | | salesDetailsId: |
| | | type: integer |
| | | serviceTimes: |
| | | type: integer |
| | |
| | | type: integer |
| | | type: array |
| | | type: object |
| | | request.DeleteServiceContract: |
| | | properties: |
| | | ids: |
| | | items: |
| | | type: integer |
| | | type: array |
| | | type: object |
| | | request.DeleteServiceFeeManage: |
| | | properties: |
| | | ids: |
| | |
| | | userId: |
| | | description: 用户ID |
| | | type: string |
| | | type: object |
| | | request.DeleteserviceContract: |
| | | properties: |
| | | ids: |
| | | items: |
| | | type: integer |
| | | type: array |
| | | type: object |
| | | request.DownloadFile: |
| | | properties: |
| | |
| | | type: integer |
| | | contactId: |
| | | type: integer |
| | | contractId: |
| | | type: integer |
| | | endTime: |
| | | type: string |
| | | id: |
| | |
| | | remark: |
| | | type: string |
| | | saleChanceId: |
| | | type: integer |
| | | salesDetailsId: |
| | | type: integer |
| | | serviceTimes: |
| | | type: integer |
| | |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.DeleteserviceContract' |
| | | $ref: '#/definitions/request.DeleteServiceContract' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | package request
|
| | |
|
| | | import (
|
| | | "aps_crm/constvar"
|
| | | "aps_crm/model"
|
| | | )
|
| | |
|
| | | type AddServiceContract struct {
|
| | | ServiceContract
|
| | | }
|
| | |
|
| | | type ServiceContract struct {
|
| | | ClientId int `json:"clientId"`
|
| | | Number string `json:"number"`
|
| | | MemberId int `json:"memberId"`
|
| | | ContactId int `json:"contactId"`
|
| | | SaleChanceId int `json:"saleChanceId"`
|
| | | ContractId int `json:"contractId"`
|
| | | QuotationId int `json:"quotationId"`
|
| | | TypeId int `json:"typeId"`
|
| | | SignTime string `json:"signTime"`
|
| | | StartTime string `json:"startTime"`
|
| | | EndTime string `json:"endTime"`
|
| | | StatusId int `json:"statusId"`
|
| | | ServiceTimes int `json:"serviceTimes"`
|
| | | Terms string `json:"terms"`
|
| | | Remark string `json:"remark"`
|
| | | Products []model.Product `json:"products"`
|
| | | }
|
| | |
|
| | | type UpdateServiceContract struct {
|
| | | Id int `json:"id"`
|
| | | ServiceContract
|
| | | }
|
| | |
|
| | | type GetServiceContractList struct {
|
| | | PageInfo
|
| | | QueryClass constvar.ServiceContractQueryClass `json:"queryClass"`
|
| | | KeywordType constvar.ServiceContractKeywordType `json:"keywordType"`
|
| | | Keyword string `json:"keyword"`
|
| | | }
|
| | |
|
| | | type DeleteserviceContract struct {
|
| | | Ids []int `json:"ids"`
|
| | | }
|
| | | package request |
| | | |
| | | import ( |
| | | "aps_crm/constvar" |
| | | "aps_crm/model" |
| | | ) |
| | | |
| | | type AddServiceContract struct { |
| | | ServiceContract |
| | | } |
| | | |
| | | type ServiceContract struct { |
| | | ClientId int `json:"clientId"` |
| | | Number string `json:"number"` |
| | | MemberId int `json:"memberId"` |
| | | ContactId int `json:"contactId"` |
| | | SaleChanceId int `json:"saleChanceId"` |
| | | SalesDetailsId int `json:"salesDetailsId"` |
| | | QuotationId int `json:"quotationId"` |
| | | TypeId int `json:"typeId"` |
| | | SignTime string `json:"signTime" binding:"datetime=2006-01-02"` |
| | | StartTime string `json:"startTime" binding:"datetime=2006-01-02"` |
| | | EndTime string `json:"endTime" binding:"datetime=2006-01-02"` |
| | | StatusId int `json:"statusId"` |
| | | ServiceTimes int `json:"serviceTimes"` |
| | | Terms string `json:"terms"` |
| | | Remark string `json:"remark"` |
| | | Products []model.Product `json:"products"` |
| | | } |
| | | |
| | | type UpdateServiceContract struct { |
| | | Id int `json:"id"` |
| | | ServiceContract |
| | | } |
| | | |
| | | type GetServiceContractList struct { |
| | | PageInfo |
| | | QueryClass constvar.ServiceContractQueryClass `json:"queryClass"` |
| | | KeywordType constvar.ServiceContractKeywordType `json:"keywordType"` |
| | | Keyword string `json:"keyword"` |
| | | } |
| | | |
| | | type DeleteServiceContract struct { |
| | | Ids []int `json:"ids"` |
| | | } |
| | |
| | | Quotation Quotation `json:"quotation" gorm:"foreignKey:QuotationId"` |
| | | ServiceContractTypeId int `json:"serviceContractTypeId" gorm:"column:service_contract_type_id;type:int;comment:合同类型id"` |
| | | ServiceContractType ServiceContractType `json:"serviceContractType" gorm:"foreignKey:ServiceContractTypeId"` |
| | | SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"` |
| | | StartTime time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` |
| | | EndTime time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` |
| | | SignTime string `json:"signTime" gorm:"column:sign_time;type:datetime;comment:签约时间"` |
| | | StartTime string `json:"startTime" gorm:"column:start_time;type:datetime;comment:开始时间"` |
| | | EndTime string `json:"endTime" gorm:"column:end_time;type:datetime;comment:结束时间"` |
| | | ServiceContractStatusId int `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:合同状态id"` |
| | | ServiceContractStatus ServiceContractStatus `json:"serviceContractStatus" gorm:"foreignKey:ServiceContractStatusId"` |
| | | ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:服务次数"` |
| | |
| | | package contextx
|
| | |
|
| | | import (
|
| | | "aps_crm/pkg/ecode"
|
| | | "aps_crm/pkg/logx"
|
| | | "github.com/gin-gonic/gin"
|
| | | "net/http"
|
| | | )
|
| | |
|
| | | type (
|
| | | Context struct {
|
| | | ctx *gin.Context
|
| | | paramsMap map[string]interface{}
|
| | | }
|
| | |
|
| | | Response struct {
|
| | | Code int `json:"code"`
|
| | | Data interface{} `json:"data"`
|
| | | Msg string `json:"msg"`
|
| | | }
|
| | | )
|
| | |
|
| | | func NewContext(ctx *gin.Context, params interface{}) (r *Context, isAllow bool) {
|
| | | r = &Context{
|
| | | ctx: ctx,
|
| | | }
|
| | | if r.ctx.Request.Method == "OPTIONS" {
|
| | | r.ctx.String(http.StatusOK, "")
|
| | | return
|
| | | }
|
| | |
|
| | | defer func() {
|
| | | query := r.ctx.Request.URL.RawQuery
|
| | | if query != "" {
|
| | | query = "?" + query
|
| | | }
|
| | | urlPath := r.ctx.Request.URL.Path
|
| | | logx.Infof("%s | %s %s | uid: %s | %+v", ctx.ClientIP(), r.ctx.Request.Method, urlPath+query, r.GetUserId(), params)
|
| | | }()
|
| | |
|
| | | // validate params
|
| | | if params != nil {
|
| | | if err := r.ctx.ShouldBind(params); err != nil {
|
| | | r.Fail(ecode.ParamsErr)
|
| | | return
|
| | | }
|
| | | }
|
| | | isAllow = true
|
| | | return
|
| | | }
|
| | |
|
| | | func (slf *Context) GetRequestPath() (r string) {
|
| | | r = slf.ctx.Request.URL.Path
|
| | | return
|
| | | }
|
| | |
|
| | | func (slf *Context) GetUserId() (r string) {
|
| | | v := slf.paramsMap["userId"]
|
| | | switch v.(type) {
|
| | | case string:
|
| | | r = v.(string)
|
| | | }
|
| | | return
|
| | | }
|
| | |
|
| | | func (slf *Context) Result(code int, data interface{}, msg string) {
|
| | | slf.ctx.JSON(http.StatusOK, Response{
|
| | | Code: code,
|
| | | Data: data,
|
| | | Msg: msg,
|
| | | })
|
| | | }
|
| | |
|
| | | func (slf *Context) Ok() {
|
| | | slf.Result(ecode.OK, map[string]interface{}{}, "")
|
| | | }
|
| | |
|
| | | func (slf *Context) OkWithDetailed(data interface{}) {
|
| | | slf.Result(ecode.OK, data, "")
|
| | | }
|
| | |
|
| | | func (slf *Context) Fail(errCode int) {
|
| | | slf.Result(errCode, map[string]interface{}{}, ecode.GetMsg(errCode))
|
| | | }
|
| | |
|
| | | func (slf *Context) FailWithMsg(errCode int, msg string) {
|
| | | slf.Result(errCode, map[string]interface{}{}, msg)
|
| | | }
|
| | |
|
| | | func (slf *Context) FailWithDetailed(errCode int, data interface{}) {
|
| | | slf.Result(errCode, data, ecode.GetMsg(errCode))
|
| | | }
|
| | |
|
| | | func (slf *Context) GetCtx() *gin.Context {
|
| | | return slf.ctx
|
| | | }
|
| | |
|
| | | func (slf *Context) SetCtx(c *gin.Context) *Context {
|
| | | slf.ctx = c
|
| | | return slf
|
| | | }
|
| | | package contextx |
| | | |
| | | import ( |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/pkg/logx" |
| | | "github.com/gin-gonic/gin" |
| | | "net/http" |
| | | ) |
| | | |
| | | type ( |
| | | Context struct { |
| | | ctx *gin.Context |
| | | paramsMap map[string]interface{} |
| | | } |
| | | |
| | | Response struct { |
| | | Code int `json:"code"` |
| | | Data interface{} `json:"data"` |
| | | Msg string `json:"msg"` |
| | | } |
| | | ) |
| | | |
| | | func NewContext(ctx *gin.Context, params interface{}) (r *Context, isAllow bool) { |
| | | r = &Context{ |
| | | ctx: ctx, |
| | | } |
| | | if r.ctx.Request.Method == "OPTIONS" { |
| | | r.ctx.String(http.StatusOK, "") |
| | | return |
| | | } |
| | | |
| | | defer func() { |
| | | query := r.ctx.Request.URL.RawQuery |
| | | if query != "" { |
| | | query = "?" + query |
| | | } |
| | | urlPath := r.ctx.Request.URL.Path |
| | | logx.Infof("%s | %s %s | uid: %s | %+v", ctx.ClientIP(), r.ctx.Request.Method, urlPath+query, r.GetUserId(), params) |
| | | }() |
| | | |
| | | // validate params |
| | | if params != nil { |
| | | if err := r.ctx.ShouldBind(params); err != nil { |
| | | logx.Errorf("bind param error: %v", err.Error()) |
| | | r.Fail(ecode.ParamsErr) |
| | | return |
| | | } |
| | | } |
| | | isAllow = true |
| | | return |
| | | } |
| | | |
| | | func (slf *Context) GetRequestPath() (r string) { |
| | | r = slf.ctx.Request.URL.Path |
| | | return |
| | | } |
| | | |
| | | func (slf *Context) GetUserId() (r string) { |
| | | v := slf.paramsMap["userId"] |
| | | switch v.(type) { |
| | | case string: |
| | | r = v.(string) |
| | | } |
| | | return |
| | | } |
| | | |
| | | func (slf *Context) Result(code int, data interface{}, msg string) { |
| | | slf.ctx.JSON(http.StatusOK, Response{ |
| | | Code: code, |
| | | Data: data, |
| | | Msg: msg, |
| | | }) |
| | | } |
| | | |
| | | func (slf *Context) Ok() { |
| | | slf.Result(ecode.OK, map[string]interface{}{}, "") |
| | | } |
| | | |
| | | func (slf *Context) OkWithDetailed(data interface{}) { |
| | | slf.Result(ecode.OK, data, "") |
| | | } |
| | | |
| | | func (slf *Context) Fail(errCode int) { |
| | | slf.Result(errCode, map[string]interface{}{}, ecode.GetMsg(errCode)) |
| | | } |
| | | |
| | | func (slf *Context) FailWithMsg(errCode int, msg string) { |
| | | slf.Result(errCode, map[string]interface{}{}, msg) |
| | | } |
| | | |
| | | func (slf *Context) FailWithDetailed(errCode int, data interface{}) { |
| | | slf.Result(errCode, data, ecode.GetMsg(errCode)) |
| | | } |
| | | |
| | | func (slf *Context) GetCtx() *gin.Context { |
| | | return slf.ctx |
| | | } |
| | | |
| | | func (slf *Context) SetCtx(c *gin.Context) *Context { |
| | | slf.ctx = c |
| | | return slf |
| | | } |