fix: wecom types agent
CI / changes (push) Successful in 12s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / bff (push) Successful in 3s
CI / chore (push) Successful in 0s
CI / express (push) Successful in 0s
CI / product (push) Successful in 1s
CI / sale (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 31s

This commit is contained in:
zzw
2026-08-31 14:22:46 +08:00
parent 90a195c9ca
commit 1d41d7ca7e
15 changed files with 349 additions and 48 deletions
+19
View File
@@ -0,0 +1,19 @@
package dao
import "lone-services/pkg/utils"
// WecomAgent 企业微信应用
type WecomAgent struct {
Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
Name string `gorm:"column:name" json:"name"`
AgentId int64 `gorm:"column:agent_id" json:"agent_id"`
CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"`
}
// AgentListItem 应用列表项
type AgentListItem struct {
Id int64 `json:"id"`
Name string `json:"name"`
AgentId int64 `json:"agent_id"`
CreatedAt string `json:"created_at"`
}
+6
View File
@@ -39,3 +39,9 @@ type UserListItem struct {
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// UserTypeOption 用户类型选项(前端下拉)
type UserTypeOption struct {
Value uint8 `json:"value"`
Label string `json:"label"`
}
+7
View File
@@ -31,6 +31,13 @@ func typeText(t uint8) string {
}
}
func userTypeOptions() []dao.UserTypeOption {
return []dao.UserTypeOption{
{Value: dao.UserTypeAdmin, Label: "管理员"},
{Value: dao.UserTypeSale, Label: "销售"},
}
}
func resolveStatus(reqStatus uint32, current uint8) uint8 {
if reqStatus == uint32(dao.StatusEnabled) || reqStatus == uint32(dao.StatusDisabled) {
return uint8(reqStatus)
@@ -0,0 +1,49 @@
package logic
import (
"context"
"lone-services/pkg/modelbase"
"lone-services/pkg/utils"
wecom "lone-services/rpc/wecom/pb"
"lone-services/services/wecom/internal/dao"
"lone-services/services/wecom/internal/model"
"lone-services/services/wecom/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type ItemsAgentsLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewItemsAgentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemsAgentsLogic {
return &ItemsAgentsLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// ItemsAgents 企业微信应用列表
func (l *ItemsAgentsLogic) ItemsAgents(_ *wecom.EmptyReq) (*wecom.Response, error) {
var rows []dao.WecomAgent
m := model.AgentModel{}.Init()
if err := m.Items(modelbase.Params{Order: "id desc"}, &rows); err != nil {
l.Errorf("wecom items agents: %v", err)
return failResponse(utils.Fail), nil
}
items := make([]dao.AgentListItem, 0, len(rows))
for _, row := range rows {
items = append(items, dao.AgentListItem{
Id: row.Id,
Name: row.Name,
AgentId: row.AgentId,
CreatedAt: row.CreatedAt.Format(),
})
}
return okResponse(items), nil
}
@@ -57,7 +57,7 @@ func (l *ItemsUsersLogic) ItemsUsers(in *wecom.ItemsUserReq) (*wecom.Response, e
if req.Type > utils.NumberZero {
w.Eq["type"] = strconv.FormatUint(uint64(req.Type), utils.NumberTen)
}
w.Eq["status"] = strconv.FormatUint(uint64(dao.StatusEnabled), utils.NumberTen)
// w.Eq["status"] = strconv.FormatUint(uint64(dao.StatusEnabled), utils.NumberTen)
if req.Name != utils.StringEmpty {
w.Like["name LIKE ?"] = "%" + req.Name + "%"
}
@@ -0,0 +1,29 @@
package logic
import (
"context"
wecom "lone-services/rpc/wecom/pb"
"lone-services/services/wecom/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type TypesLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewTypesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TypesLogic {
return &TypesLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// Types 用户类型选项(管理员 / 销售)
func (l *TypesLogic) Types(_ *wecom.EmptyReq) (*wecom.Response, error) {
return okResponse(userTypeOptions()), nil
}
+18
View File
@@ -0,0 +1,18 @@
package model
import (
"lone-services/pkg/modelbase"
)
type AgentModel struct {
modelbase.Base
}
func (m AgentModel) TableName() string {
return modelbase.Prefix() + "agents"
}
func (m AgentModel) Init() AgentModel {
m.Table = m.TableName()
return m
}
@@ -47,3 +47,13 @@ func (s *WecomServer) DeleteUser(ctx context.Context, in *wecom.DeleteUserReq) (
l := logic.NewDeleteUserLogic(ctx, s.svcCtx)
return l.DeleteUser(in)
}
func (s *WecomServer) ItemsAgents(ctx context.Context, in *wecom.EmptyReq) (*wecom.Response, error) {
l := logic.NewItemsAgentsLogic(ctx, s.svcCtx)
return l.ItemsAgents(in)
}
func (s *WecomServer) Types(ctx context.Context, in *wecom.EmptyReq) (*wecom.Response, error) {
l := logic.NewTypesLogic(ctx, s.svcCtx)
return l.Types(in)
}