调整商户管理表
This commit is contained in:
@ -10,5 +10,5 @@ type MerchantAdminInfoReq struct {
|
|||||||
type MerchantAdminInfoRes struct {
|
type MerchantAdminInfoRes struct {
|
||||||
MerchantId int64 `json:"merchantId"`
|
MerchantId int64 `json:"merchantId"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
StoreId int64 `json:"storeId"` // 下属门店 id
|
Role string `json:"role"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import (
|
|||||||
"server/internal/controller/reward"
|
"server/internal/controller/reward"
|
||||||
"server/internal/controller/rewardType"
|
"server/internal/controller/rewardType"
|
||||||
"server/internal/controller/role"
|
"server/internal/controller/role"
|
||||||
|
"server/internal/controller/store"
|
||||||
"server/internal/controller/task"
|
"server/internal/controller/task"
|
||||||
"server/internal/controller/upload"
|
"server/internal/controller/upload"
|
||||||
"server/internal/controller/user"
|
"server/internal/controller/user"
|
||||||
@ -44,6 +45,7 @@ var (
|
|||||||
admin.NewV1(),
|
admin.NewV1(),
|
||||||
role.NewV1(),
|
role.NewV1(),
|
||||||
merchant.NewV1(),
|
merchant.NewV1(),
|
||||||
|
store.NewV1(),
|
||||||
rewardType.NewV1(),
|
rewardType.NewV1(),
|
||||||
feedback.NewV1(),
|
feedback.NewV1(),
|
||||||
user.NewV1(),
|
user.NewV1(),
|
||||||
|
|||||||
@ -11,9 +11,10 @@ import (
|
|||||||
|
|
||||||
func (c *ControllerV1) MerchantAdminInfo(ctx context.Context, req *v1.MerchantAdminInfoReq) (res *v1.MerchantAdminInfoRes, err error) {
|
func (c *ControllerV1) MerchantAdminInfo(ctx context.Context, req *v1.MerchantAdminInfoReq) (res *v1.MerchantAdminInfoRes, err error) {
|
||||||
merchantAdminId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
merchantAdminId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
|
||||||
|
role := g.RequestFromCtx(ctx).GetCtxVar("role").String()
|
||||||
info, err := service.MerchantAdmin().Info(ctx, &model.MerchantAdminInfoIn{MerchantAdminId: merchantAdminId})
|
info, err := service.MerchantAdmin().Info(ctx, &model.MerchantAdminInfoIn{MerchantAdminId: merchantAdminId})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &v1.MerchantAdminInfoRes{Username: info.Username, MerchantId: info.MerchantId, StoreId: info.StoreId}, nil
|
return &v1.MerchantAdminInfoRes{Username: info.Username, MerchantId: info.MerchantId, Role: role}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ type MerchantAdminsColumns struct {
|
|||||||
RealName string // 真实姓名
|
RealName string // 真实姓名
|
||||||
Phone string // 手机号
|
Phone string // 手机号
|
||||||
Email string // 邮箱
|
Email string // 邮箱
|
||||||
Role string // 角色:1=超级管理员,2=普通管理员
|
|
||||||
Status string // 状态:1=正常,2=禁用
|
Status string // 状态:1=正常,2=禁用
|
||||||
LastLoginAt string // 最后登录时间
|
LastLoginAt string // 最后登录时间
|
||||||
CreatedAt string // 创建时间
|
CreatedAt string // 创建时间
|
||||||
@ -47,7 +46,6 @@ var merchantAdminsColumns = MerchantAdminsColumns{
|
|||||||
RealName: "real_name",
|
RealName: "real_name",
|
||||||
Phone: "phone",
|
Phone: "phone",
|
||||||
Email: "email",
|
Email: "email",
|
||||||
Role: "role",
|
|
||||||
Status: "status",
|
Status: "status",
|
||||||
LastLoginAt: "last_login_at",
|
LastLoginAt: "last_login_at",
|
||||||
CreatedAt: "created_at",
|
CreatedAt: "created_at",
|
||||||
|
|||||||
@ -86,15 +86,11 @@ func (s *sMerchantAdmin) Login(ctx context.Context, in *model.MerchantLoginIn) (
|
|||||||
LastLoginAt: gtime.Now(),
|
LastLoginAt: gtime.Now(),
|
||||||
LastLoginIp: ghttp.RequestFromCtx(ctx).RemoteAddr,
|
LastLoginIp: ghttp.RequestFromCtx(ctx).RemoteAddr,
|
||||||
})
|
})
|
||||||
}(ctx, mAdminId)
|
}(context.Background(), mAdminId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func (s *sMerchantAdmin) Info(ctx context.Context, in *model.MerchantAdminInfoIn) (out *model.MerchantAdminInfoOut, err error) {
|
func (s *sMerchantAdmin) Info(ctx context.Context, in *model.MerchantAdminInfoIn) (out *model.MerchantAdminInfoOut, err error) {
|
||||||
one, err := dao.MerchantAdmins.Ctx(ctx).WherePri(in.MerchantAdminId).
|
one, err := dao.MerchantAdmins.Ctx(ctx).WherePri(in.MerchantAdminId).One()
|
||||||
LeftJoin(
|
|
||||||
dao.Stores.Table(),
|
|
||||||
fmt.Sprintf("%s.%s = %s.%s", dao.Stores.Table(), dao.Stores.Columns().MerchantId, dao.MerchantAdmins.Table(), dao.MerchantAdmins.Columns().MerchantId)).
|
|
||||||
Fields(fmt.Sprintf("%s.*, %s.%s %s", dao.MerchantAdmins.Table(), dao.Stores.Table(), dao.Stores.Columns().Id, "storeId")).One()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ecode.Fail.Sub("查询商户管理员失败")
|
return nil, ecode.Fail.Sub("查询商户管理员失败")
|
||||||
}
|
}
|
||||||
@ -108,7 +104,6 @@ func (s *sMerchantAdmin) Info(ctx context.Context, in *model.MerchantAdminInfoIn
|
|||||||
return &model.MerchantAdminInfoOut{
|
return &model.MerchantAdminInfoOut{
|
||||||
Username: admin.Username,
|
Username: admin.Username,
|
||||||
MerchantId: admin.MerchantId,
|
MerchantId: admin.MerchantId,
|
||||||
StoreId: one["storeId"].Int64(),
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
func (s *sMerchantAdmin) Code(ctx context.Context, in *model.MerchantAdminCodeIn) (out *model.MerchantAdminCodeOut, err error) {
|
func (s *sMerchantAdmin) Code(ctx context.Context, in *model.MerchantAdminCodeIn) (out *model.MerchantAdminCodeOut, err error) {
|
||||||
|
|||||||
@ -23,7 +23,15 @@ func init() {
|
|||||||
}
|
}
|
||||||
func (s *sStore) List(ctx context.Context, in *model.StoreListIn) (out *model.StoreListOut, err error) {
|
func (s *sStore) List(ctx context.Context, in *model.StoreListIn) (out *model.StoreListOut, err error) {
|
||||||
// 1. 初始化返回数据
|
// 1. 初始化返回数据
|
||||||
return
|
list := make([]model.Store, 0)
|
||||||
|
var total int
|
||||||
|
if err = dao.Stores.Ctx(ctx).Page(in.Page, in.Size).ScanAndCount(&list, &total, false); err != nil {
|
||||||
|
return nil, ecode.Fail.Sub("门店列表获取失败")
|
||||||
|
}
|
||||||
|
return &model.StoreListOut{
|
||||||
|
List: list,
|
||||||
|
Total: total,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sStore) Create(ctx context.Context, in *model.StoreCreateIn) (out *model.CreateOut, err error) {
|
func (s *sStore) Create(ctx context.Context, in *model.StoreCreateIn) (out *model.CreateOut, err error) {
|
||||||
|
|||||||
@ -19,7 +19,6 @@ type MerchantAdmins struct {
|
|||||||
RealName interface{} // 真实姓名
|
RealName interface{} // 真实姓名
|
||||||
Phone interface{} // 手机号
|
Phone interface{} // 手机号
|
||||||
Email interface{} // 邮箱
|
Email interface{} // 邮箱
|
||||||
Role interface{} // 角色:1=超级管理员,2=普通管理员
|
|
||||||
Status interface{} // 状态:1=正常,2=禁用
|
Status interface{} // 状态:1=正常,2=禁用
|
||||||
LastLoginAt *gtime.Time // 最后登录时间
|
LastLoginAt *gtime.Time // 最后登录时间
|
||||||
CreatedAt *gtime.Time // 创建时间
|
CreatedAt *gtime.Time // 创建时间
|
||||||
|
|||||||
@ -10,20 +10,19 @@ import (
|
|||||||
|
|
||||||
// MerchantAdmins is the golang structure for table merchant_admins.
|
// MerchantAdmins is the golang structure for table merchant_admins.
|
||||||
type MerchantAdmins struct {
|
type MerchantAdmins struct {
|
||||||
Id int64 `json:"id" orm:"id" description:"商户管理员ID"` // 商户管理员ID
|
Id int64 `json:"id" orm:"id" description:"商户管理员ID"` // 商户管理员ID
|
||||||
MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"所属商户ID"` // 所属商户ID
|
MerchantId int64 `json:"merchantId" orm:"merchant_id" description:"所属商户ID"` // 所属商户ID
|
||||||
Username string `json:"username" orm:"username" description:"用户名"` // 用户名
|
Username string `json:"username" orm:"username" description:"用户名"` // 用户名
|
||||||
PasswordHash string `json:"passwordHash" orm:"password_hash" description:"密码哈希"` // 密码哈希
|
PasswordHash string `json:"passwordHash" orm:"password_hash" description:"密码哈希"` // 密码哈希
|
||||||
RealName string `json:"realName" orm:"real_name" description:"真实姓名"` // 真实姓名
|
RealName string `json:"realName" orm:"real_name" description:"真实姓名"` // 真实姓名
|
||||||
Phone string `json:"phone" orm:"phone" description:"手机号"` // 手机号
|
Phone string `json:"phone" orm:"phone" description:"手机号"` // 手机号
|
||||||
Email string `json:"email" orm:"email" description:"邮箱"` // 邮箱
|
Email string `json:"email" orm:"email" description:"邮箱"` // 邮箱
|
||||||
Role int `json:"role" orm:"role" description:"角色:1=超级管理员,2=普通管理员"` // 角色:1=超级管理员,2=普通管理员
|
Status int `json:"status" orm:"status" description:"状态:1=正常,2=禁用"` // 状态:1=正常,2=禁用
|
||||||
Status int `json:"status" orm:"status" description:"状态:1=正常,2=禁用"` // 状态:1=正常,2=禁用
|
LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at" description:"最后登录时间"` // 最后登录时间
|
||||||
LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at" description:"最后登录时间"` // 最后登录时间
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间戳"` // 软删除时间戳
|
IsPrimary bool `json:"isPrimary" orm:"is_primary" description:"是否主账号:0=否,1=是"` // 是否主账号:0=否,1=是
|
||||||
IsPrimary bool `json:"isPrimary" orm:"is_primary" description:"是否主账号:0=否,1=是"` // 是否主账号:0=否,1=是
|
LastLoginIp string `json:"lastLoginIp" orm:"last_login_ip" description:"最后登录IP"` // 最后登录IP
|
||||||
LastLoginIp string `json:"lastLoginIp" orm:"last_login_ip" description:"最后登录IP"` // 最后登录IP
|
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
|
||||||
RoleId int64 `json:"roleId" orm:"role_id" description:"角色ID"` // 角色ID
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ type MerchantAdminInfoIn struct {
|
|||||||
type MerchantAdminInfoOut struct {
|
type MerchantAdminInfoOut struct {
|
||||||
Username string
|
Username string
|
||||||
MerchantId int64
|
MerchantId int64
|
||||||
StoreId int64
|
|
||||||
}
|
}
|
||||||
type MerchantAdminCodeIn struct {
|
type MerchantAdminCodeIn struct {
|
||||||
Phone string
|
Phone string
|
||||||
|
|||||||
@ -82,6 +82,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
// 商户
|
// 商户
|
||||||
{
|
{
|
||||||
|
enforcer.AddPolicy("merchant", "/x/store", "GET", "根据商户 id 获取门店列表")
|
||||||
enforcer.AddPolicy("merchant", "/x/merchant/info", "GET", "获取商户信息")
|
enforcer.AddPolicy("merchant", "/x/merchant/info", "GET", "获取商户信息")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user