This commit is contained in:
2026-07-24 13:05:57 +08:00
parent fc1e880fcc
commit 23c8a4c1ba
77 changed files with 1987 additions and 1408 deletions
+10 -4
View File
@@ -2,8 +2,10 @@ package controller
import (
"context"
"errors"
"video-factory/common"
"video-factory/shortdrama/middleware"
"video-factory/shortdrama/dao"
"video-factory/shortdrama/model/dto"
"video-factory/shortdrama/service"
@@ -22,9 +24,13 @@ func (c *customer) Create(ctx context.Context, req *dto.CreateCustomerReq) (res
agentId := req.AgentId
if agentId == 0 {
r := g.RequestFromCtx(ctx)
agentId = middleware.GetUserId(r)
agentId = common.GetUserId(r)
}
user, err := service.CustomerService.CreateCustomer(ctx, req.Phone, req.Name, req.Address, agentId)
user, err := dao.User.GetOne(ctx, agentId)
if err != nil || user == nil || user.Role != "agent" {
return nil, errors.New("agent not found")
}
user, err = service.CustomerService.CreateCustomer(ctx, req.Phone, req.Name, req.Address, agentId)
if err != nil {
return nil, err
}
@@ -41,6 +47,6 @@ func (c *customer) Detail(ctx context.Context, req *struct{ Id int64 }) (res *dt
func (c *customer) Update(ctx context.Context, req *dto.UpdateCustomerReq) (res *struct{}, err error) {
r := g.RequestFromCtx(ctx)
agentId := middleware.GetUserId(r)
agentId := common.GetUserId(r)
return nil, service.CustomerService.UpdateCustomer(ctx, agentId, req)
}