Skip to content

Commit

Permalink
feat(crm): add register code for beta systemn running
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Nov 14, 2023
1 parent e20033e commit 9dc32c9
Show file tree
Hide file tree
Showing 33 changed files with 1,280 additions and 50 deletions.
1 change: 1 addition & 0 deletions api/admin.crm.api
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "admin/crm/customerdomain/lead.api"
import "admin/crm/customerdomain/customer.api"
import "admin/crm/customerdomain/registercode.api"
import "admin/crm/market/media.api"
import "admin/crm/market/store.api"
import "admin/crm/market/mgm.api"
Expand Down
153 changes: 153 additions & 0 deletions api/admin/crm/customerdomain/registercode.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
syntax = "v1"

info(
title: "注册码管理"
desc: "注册码管理"
author: "MichaelHu"
email: "[email protected]"
version: "v1"
)

@server(
group: admin/crm/customerdomain/registercode
prefix: /api/v1/admin/customerdomain
middleware: EmployeeJWTAuth
)

service PowerX {
@doc "查询注册码"
@handler GetRegisterCode
get /register-codes/:id (GetRegisterCodeReqeuest) returns (GetRegisterCodeReply)

@doc "获取注册码分页列表"
@handler ListRegisterCodesPage
get /register-codes/page-list (ListRegisterCodesPageRequest) returns (ListRegisterCodesPageReply)

@doc "创建注册码"
@handler CreateRegisterCode
post /register-codes (CreateRegisterCodeRequest) returns (CreateRegisterCodeReply)

@doc "批量创建注册码"
@handler GenerateRegisterCode
post /register-codes/generate (GenerateRegisterCodeRequest) returns (GenerateRegisterCodeReply)

@doc "全量注册码"
@handler PutRegisterCode
put /register-codes/:id (PutRegisterCodeRequest) returns (PutRegisterCodeReply)

@doc "增量注册码"
@handler PatchRegisterCode
patch /register-codes/:id (PatchRegisterCodeRequest) returns (PatchRegisterCodeReply)

@doc "删除注册码"
@handler DeleteRegisterCode
delete /register-codes/:id (DeleteRegisterCodeRequest) returns (DeleteRegisterCodeReply)

}


type (
RegisterCode {
Id int64 `json:"id,optional"`
Code string `json:"code,optional"`
RegisterCustomerID int64 `json:"registerCustomerID,optional"`
ExpiredAt string `json:"expiredAt,optional"`
CreatedAt string `json:"createdAt,optional"`
}
)

type (
GetRegisterCodeReqeuest {
Id int64 `path:"id"`
}

GetRegisterCodeReply {
RegisterCode *RegisterCode `json:"customer"`
}
)

type (
ListRegisterCodesPageRequest {
LikeName string `form:"likeName,optional"`
LikeMobile string `form:"likeMobile,optional"`
Sources []int `form:"sources,optional"`
Statuses []int `form:"statuses,optional"`
OrderBy string `form:"orderBy,optional"`
PageIndex int `form:"pageIndex,optional"`
PageSize int `form:"pageSize,optional"`
}

ListRegisterCodesPageReply {
List []RegisterCode `json:"list,optional"`
PageIndex int `json:"pageIndex,optional"`
PageSize int `json:"pageSize,optional"`
Total int64 `json:"total,optional"`
}
)

type (
CreateRegisterCodeRequest {
RegisterCode
}

CreateRegisterCodeReply {
RegisterCodeId int64 `json:"id"`
}
)

type (
GenerateRegisterCodeRequest {
BatchCount int `json:"batchCount"`
}

GenerateRegisterCodeReply {
result bool `json:"result"`
}
)

type PutRegisterCodeRequest {
RegisterCodeId int64 `path:"id"`
RegisterCode
}

type PutRegisterCodeReply {
*RegisterCode
}


type (
PatchRegisterCodeRequest {
RegisterCodeId int64 `path:"id"`
Name string `json:"name,optional"`
Email string `json:"email,optional"`
InviterId int64 `json:"inviterId,optional"`
Source int `json:"source,optional"`
Type int `json:"type,optional"`
IsActivated bool `json:"isActivated,optional,omitempty"`
}

PatchRegisterCodeReply {
*RegisterCode
}
)

type (
DeleteRegisterCodeRequest {
Id int64 `path:"id"`
}

DeleteRegisterCodeReply {
RegisterCodeId int64 `json:"id"`
}
)

type (
AssignRegisterCodeToEmployeeRequest {
Id string `path:"id"`
EmployeeId int64 `json:"employeeId"`
}

AssignRegisterCodeToEmployeeReply {
RegisterCodeId int64 `json:"customerId"`
}
)
22 changes: 20 additions & 2 deletions api/web/customerdomain/auth.api
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ service PowerX {
@handler RegisterCustomerByPhone
post /registerByPhone (CustomerRegisterByPhoneRequest) returns (CustomerRegisterByPhoneReply)

@doc "客户手机注册,邀请码机制"
@handler RegisterCustomerByPhoneInInviteCode
post /registerByPhone/invite/:code (CustomerRegisterByPhoneInInviteCodeRequest) returns (CustomerRegisterByPhoneReply)

@doc "客户手机注册,注册码机制"
@handler RegisterCustomerByPhoneInRegisterCode
post /registerByPhone/register/:code (CustomerRegisterByPhoneInRegisterCodeRequest) returns (CustomerRegisterByPhoneReply)

}


Expand All @@ -49,8 +57,18 @@ type (
CustomerRegisterByPhoneRequest {
Phone string `json:"phone"`
Password string `json:"password"`
VerifyCode string `json:"verifyCode"`
InviteCode string `json:"inviteCode,optional"`
VerifyCode string `json:"verifyCode,optional"`
}

CustomerRegisterByPhoneInInviteCodeRequest{
*CustomerRegisterByPhoneRequest
InviteCode string `path:"code,optional"`

}
CustomerRegisterByPhoneInRegisterCodeRequest{
*CustomerRegisterByPhoneRequest
RegisterCode string `path:"code,optional"`

}

CustomerRegisterByPhoneReply {
Expand Down
5 changes: 4 additions & 1 deletion cmd/ctl/database/migrate/powerx.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ func (m *PowerMigrator) AutoMigrate() {
_ = m.db.AutoMigrate(&infoorganizatoin.PivotCategoryToObject{})

// customer domain
_ = m.db.AutoMigrate(&customerdomain.Lead{}, &customerdomain.Contact{}, &customerdomain.Customer{}, &membership.Membership{})
_ = m.db.AutoMigrate(
&customerdomain.Lead{}, &customerdomain.Contact{}, customerdomain.RegisterCode{},
&customerdomain.Customer{}, &membership.Membership{},
)
_ = m.db.AutoMigrate(&wechat.WechatOACustomer{}, &wechat.WechatMPCustomer{}, &wechat.WeWorkExternalContact{})
_ = m.db.AutoMigrate(
&product.PivotProductToProductCategory{},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package registercode

import (
"net/http"

"PowerX/internal/logic/admin/crm/customerdomain/registercode"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func CreateRegisterCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateRegisterCodeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := registercode.NewCreateRegisterCodeLogic(r.Context(), svcCtx)
resp, err := l.CreateRegisterCode(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package registercode

import (
"net/http"

"PowerX/internal/logic/admin/crm/customerdomain/registercode"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func DeleteRegisterCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteRegisterCodeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := registercode.NewDeleteRegisterCodeLogic(r.Context(), svcCtx)
resp, err := l.DeleteRegisterCode(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package registercode

import (
"net/http"

"PowerX/internal/logic/admin/crm/customerdomain/registercode"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func GenerateRegisterCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GenerateRegisterCodeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := registercode.NewGenerateRegisterCodeLogic(r.Context(), svcCtx)
resp, err := l.GenerateRegisterCode(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package registercode

import (
"net/http"

"PowerX/internal/logic/admin/crm/customerdomain/registercode"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func GetRegisterCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetRegisterCodeReqeuest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := registercode.NewGetRegisterCodeLogic(r.Context(), svcCtx)
resp, err := l.GetRegisterCode(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package registercode

import (
"net/http"

"PowerX/internal/logic/admin/crm/customerdomain/registercode"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func ListRegisterCodesPageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ListRegisterCodesPageRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := registercode.NewListRegisterCodesPageLogic(r.Context(), svcCtx)
resp, err := l.ListRegisterCodesPage(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package registercode

import (
"net/http"

"PowerX/internal/logic/admin/crm/customerdomain/registercode"
"PowerX/internal/svc"
"PowerX/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)

func PatchRegisterCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.PatchRegisterCodeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := registercode.NewPatchRegisterCodeLogic(r.Context(), svcCtx)
resp, err := l.PatchRegisterCode(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
Loading

0 comments on commit 9dc32c9

Please sign in to comment.