feat: device info and bind
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
CI / changes (push) Successful in 1m30s
CI / ad (push) Successful in 31s
CI / admin (push) Successful in 24s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 27s
CI / equipment (push) Successful in 21s
CI / express (push) Successful in 23s
CI / factory (push) Successful in 21s
CI / message (push) Successful in 21s
CI / order (push) Successful in 22s
CI / payment (push) Successful in 20s
CI / percutaneous (push) Successful in 20s
CI / product (push) Successful in 20s
CI / record (push) Successful in 19s
CI / sale (push) Successful in 19s
CI / support (push) Successful in 20s
CI / task (push) Successful in 19s
CI / user (push) Successful in 21s
CI / wecom (push) Successful in 22s
This commit is contained in:
@@ -5,10 +5,18 @@ import "lone-services/pkg/utils"
|
||||
type UserStoreAuth struct {
|
||||
Id int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
UserId int64 `gorm:"column:user_id" json:"user_id"`
|
||||
ObjId int64 `gorm:"column:obj_id" json:"obj_id"`
|
||||
StoreId int64 `gorm:"column:store_id" json:"store_id"`
|
||||
ValidityTime utils.CustomTime `gorm:"column:validity_time" json:"validity_time"`
|
||||
Status uint8 `gorm:"column:status" json:"status"`
|
||||
IP string `gorm:"column:ip" json:"ip"`
|
||||
CreateTime utils.CustomTime `gorm:"column:create_time" json:"create_time"`
|
||||
CreatedAt utils.CustomTime `gorm:"column:created_at" json:"created_at"`
|
||||
}
|
||||
|
||||
type StoreAuthItem struct {
|
||||
Id int64 `json:"id"`
|
||||
StoreId int64 `json:"store_id"`
|
||||
Name string `json:"name"`
|
||||
Address string `json:"address"`
|
||||
ValidityTime string `json:"validity_time"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
@@ -5,8 +5,12 @@ const (
|
||||
TypeStore uint8 = 2
|
||||
TypeUser uint8 = 3
|
||||
|
||||
ClientCodeUserSkin = "user_skin"
|
||||
ClientCodeUserSkin = "user_skin"
|
||||
ClientCodeStoreSkin = "store_skin"
|
||||
|
||||
StatusEnabled uint8 = 1
|
||||
StatusDisabled uint8 = 2
|
||||
|
||||
SkinTypeUser int32 = 1
|
||||
SkinTypeStore int32 = 2
|
||||
)
|
||||
|
||||
@@ -78,10 +78,10 @@ func (l *StoreAuthLogic) StoreAuth(in *analysis.StoreAuthReq) (*analysis.Respons
|
||||
return common.OutResponse(utils.ErrorParams, "用户未开通"), nil
|
||||
}
|
||||
|
||||
if err := common.BindStoreAuth(verified.UserId, verified.BizId, storeId, req.ValidityTime); err != nil {
|
||||
if err := common.BindStoreAuth(verified.BizId, storeId, req.ValidityTime); err != nil {
|
||||
l.Errorf("store auth bind: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
return common.OkResponse(map[string]int64{"user_id": verified.UserId}), nil
|
||||
return common.OkResponse(map[string]int64{"user_id": verified.BizId}), nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
equipmentpb "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
"lone-services/services/analysis/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
const skinAnalyzerType int32 = 3
|
||||
|
||||
type DeviceBindLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeviceBindLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeviceBindLogic {
|
||||
return &DeviceBindLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeviceBindLogic) DeviceBind(in *analysis.DeviceBindReq) (*analysis.Response, error) {
|
||||
var req validator.DeviceBindValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return common.OutResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
loginUser := utils.GetUserFromCtx(l.ctx)
|
||||
if !loginUser.Valid || loginUser.ID < utils.NumberOne {
|
||||
return common.FailResponse(utils.ErrorNoLogin), nil
|
||||
}
|
||||
skinType, ok := common.SkinTypeOf(loginUser.ClientCode)
|
||||
if !ok {
|
||||
return common.FailResponse(utils.ErrorAuthority), nil
|
||||
}
|
||||
if l.svcCtx.EquipmentSvcName == utils.StringEmpty {
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
cli, err := svc.GetRpcClient(l.svcCtx.EquipmentSvcName)
|
||||
if err != nil {
|
||||
l.Errorf("device bind get equipment rpc: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
out, err := equipmentpb.NewEquipmentClient(cli.Conn()).InternalBindAdd(l.ctx, &equipmentpb.InternalBindAddRequest{
|
||||
UserId: loginUser.ID,
|
||||
UserNickname: loginUser.Name,
|
||||
HostNickname: utils.StringEmpty,
|
||||
HostCode: req.DeviceNo,
|
||||
Type: skinAnalyzerType,
|
||||
SkinType: skinType,
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("device bind internal add: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
if out == nil {
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
return &analysis.Response{
|
||||
Code: out.Code,
|
||||
Msg: out.Msg,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
equipmentpb "lone-services/rpc/equipment/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeviceInfoLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeviceInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeviceInfoLogic {
|
||||
return &DeviceInfoLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeviceInfoLogic) DeviceInfo(in *analysis.DeviceInfoReq) (*analysis.Response, error) {
|
||||
loginUser := utils.GetUserFromCtx(l.ctx)
|
||||
if !loginUser.Valid || loginUser.ID < utils.NumberOne {
|
||||
return common.FailResponse(utils.ErrorNoLogin), nil
|
||||
}
|
||||
skinType, ok := common.SkinTypeOf(loginUser.ClientCode)
|
||||
if !ok {
|
||||
return common.FailResponse(utils.ErrorAuthority), nil
|
||||
}
|
||||
if l.svcCtx.EquipmentSvcName == utils.StringEmpty {
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
cli, err := svc.GetRpcClient(l.svcCtx.EquipmentSvcName)
|
||||
if err != nil {
|
||||
l.Errorf("device info get equipment rpc: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
out, err := equipmentpb.NewEquipmentClient(cli.Conn()).InternalBindInfo(l.ctx, &equipmentpb.InternalBindInfoRequest{
|
||||
UserId: loginUser.ID,
|
||||
SkinType: skinType,
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("device info internal: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
if out == nil {
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
return &analysis.Response{
|
||||
Code: out.Code,
|
||||
Msg: out.Msg,
|
||||
Data: out.Data,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
"lone-services/services/analysis/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UserAuthDeleteLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewUserAuthDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAuthDeleteLogic {
|
||||
return &UserAuthDeleteLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UserAuthDeleteLogic) UserAuthDelete(in *analysis.UserAuthDeleteReq) (*analysis.Response, error) {
|
||||
var req validator.UserAuthDeleteValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return common.OutResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
bizId, _, fail := common.RequireAnalysisUserId(l.ctx)
|
||||
if fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
if _, err := common.DisableStoreAuth(req.Id, bizId); err != nil {
|
||||
l.Errorf("user auth delete: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
return common.OkResponse(nil), nil
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
storepb "lone-services/rpc/store/pb"
|
||||
"lone-services/services/analysis/internal/dao"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const authTimeLayout = "2006-01-02 15:04"
|
||||
|
||||
type UserAuthListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewUserAuthListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAuthListLogic {
|
||||
return &UserAuthListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UserAuthListLogic) UserAuthList(in *analysis.UserAuthListReq) (*analysis.Response, error) {
|
||||
bizId, _, fail := common.RequireAnalysisUserId(l.ctx)
|
||||
if fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
authList, err := common.ListStoreAuth(bizId)
|
||||
if err != nil {
|
||||
l.Errorf("user auth list: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
if len(authList) == utils.NumberZero {
|
||||
return common.OkResponse([]dao.StoreAuthItem{}), nil
|
||||
}
|
||||
|
||||
storeMap, err := l.loadStores(authList)
|
||||
if err != nil {
|
||||
l.Errorf("user auth list stores: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
list := make([]dao.StoreAuthItem, 0, len(authList))
|
||||
for _, row := range authList {
|
||||
store, ok := storeMap[row.StoreId]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
itemStatus := int(dao.StatusEnabled)
|
||||
if row.ValidityTime.Time.Before(now) {
|
||||
itemStatus = int(dao.StatusDisabled)
|
||||
}
|
||||
list = append(list, dao.StoreAuthItem{
|
||||
Id: row.Id,
|
||||
StoreId: store.Id,
|
||||
Name: store.Name,
|
||||
Address: store.Address,
|
||||
ValidityTime: row.ValidityTime.Format(authTimeLayout),
|
||||
CreatedAt: row.CreatedAt.Format(authTimeLayout),
|
||||
Status: itemStatus,
|
||||
})
|
||||
}
|
||||
return common.OkResponse(list), nil
|
||||
}
|
||||
|
||||
func (l *UserAuthListLogic) loadStores(authList []dao.UserStoreAuth) (map[int64]*storepb.InfoResponse, error) {
|
||||
ids := make([]int64, 0, len(authList))
|
||||
seen := make(map[int64]struct{}, len(authList))
|
||||
for _, row := range authList {
|
||||
if _, ok := seen[row.StoreId]; ok {
|
||||
continue
|
||||
}
|
||||
seen[row.StoreId] = struct{}{}
|
||||
ids = append(ids, row.StoreId)
|
||||
}
|
||||
|
||||
svcName := utils.GetConfigString("services.store")
|
||||
if svcName == utils.StringEmpty {
|
||||
return nil, status.Error(codes.FailedPrecondition, "store service empty")
|
||||
}
|
||||
cli, err := svc.GetRpcClient(svcName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res, err := storepb.NewStoreClient(cli.Conn()).GetInfoByIds(l.ctx, &storepb.IdsRequest{Ids: ids})
|
||||
if err != nil {
|
||||
if st, ok := status.FromError(err); ok && st.Message() == utils.ErrorNotFund.Msg {
|
||||
return map[int64]*storepb.InfoResponse{}, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
storeMap := make(map[int64]*storepb.InfoResponse, len(res.GetItems()))
|
||||
for _, item := range res.GetItems() {
|
||||
storeMap[item.Id] = item
|
||||
}
|
||||
return storeMap, nil
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func (l *UserAuthLogic) UserAuth(in *analysis.UserAuthReq) (*analysis.Response,
|
||||
return common.OutResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
loginUser, fail := common.RequireUserLogin(l.ctx)
|
||||
bizId, _, fail := common.RequireAnalysisUserId(l.ctx)
|
||||
if fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
@@ -52,11 +52,7 @@ func (l *UserAuthLogic) UserAuth(in *analysis.UserAuthReq) (*analysis.Response,
|
||||
}
|
||||
|
||||
if req.Type == int32(utils.StoreAuthBind) {
|
||||
bizId := loginUser.BizId
|
||||
if bizId < utils.NumberOne {
|
||||
return common.OutResponse(utils.ErrorParams, "业务用户不存在"), nil
|
||||
}
|
||||
if err := common.BindStoreAuth(loginUser.ID, bizId, req.StoreId, req.ValidityTime); err != nil {
|
||||
if err := common.BindStoreAuth(bizId, req.StoreId, req.ValidityTime); err != nil {
|
||||
l.Errorf("user auth bind: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/pkg/validate"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
"lone-services/services/analysis/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UserAuthUpdateLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewUserAuthUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserAuthUpdateLogic {
|
||||
return &UserAuthUpdateLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UserAuthUpdateLogic) UserAuthUpdate(in *analysis.UserAuthUpdateReq) (*analysis.Response, error) {
|
||||
var req validator.UserAuthUpdateValidator
|
||||
if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty {
|
||||
return common.OutResponse(utils.ErrorParams, msg), nil
|
||||
}
|
||||
|
||||
bizId, _, fail := common.RequireAnalysisUserId(l.ctx)
|
||||
if fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
|
||||
if _, err := common.UpdateStoreAuthTime(req.Id, bizId, req.ValidityTime); err != nil {
|
||||
l.Errorf("user auth update: %v", err)
|
||||
return common.FailResponse(utils.Fail), nil
|
||||
}
|
||||
return common.OkResponse(nil), nil
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func parseValidityTime(date string) (utils.CustomTime, error) {
|
||||
return utils.CustomTime{Time: t}, nil
|
||||
}
|
||||
|
||||
func BindStoreAuth(userId, objId, storeId int64, validityTime string) error {
|
||||
func BindStoreAuth(userId, storeId int64, validityTime string) error {
|
||||
vt, err := parseValidityTime(validityTime)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -50,10 +50,48 @@ func BindStoreAuth(userId, objId, storeId int64, validityTime string) error {
|
||||
|
||||
return authModel.Create(&dao.UserStoreAuth{
|
||||
UserId: userId,
|
||||
ObjId: objId,
|
||||
StoreId: storeId,
|
||||
ValidityTime: vt,
|
||||
Status: dao.StatusEnabled,
|
||||
CreateTime: utils.Now(),
|
||||
CreatedAt: utils.Now(),
|
||||
})
|
||||
}
|
||||
|
||||
func ListStoreAuth(userId int64) ([]dao.UserStoreAuth, error) {
|
||||
var list []dao.UserStoreAuth
|
||||
err := model.UserStoreAuthModel{}.Init().Items(modelbase.Params{
|
||||
Eq: map[string]string{
|
||||
"user_id": strconv.FormatInt(userId, utils.NumberTen),
|
||||
"status": strconv.Itoa(int(dao.StatusEnabled)),
|
||||
},
|
||||
}, &list)
|
||||
return list, err
|
||||
}
|
||||
|
||||
func DisableStoreAuth(id, userId int64) (int64, error) {
|
||||
return model.UserStoreAuthModel{}.Init().Edit(modelbase.Params{
|
||||
Eq: map[string]string{
|
||||
"id": strconv.FormatInt(id, utils.NumberTen),
|
||||
"user_id": strconv.FormatInt(userId, utils.NumberTen),
|
||||
"status": strconv.Itoa(int(dao.StatusEnabled)),
|
||||
},
|
||||
}, map[string]interface{}{
|
||||
"status": dao.StatusDisabled,
|
||||
})
|
||||
}
|
||||
|
||||
func UpdateStoreAuthTime(id, userId int64, validityTime string) (int64, error) {
|
||||
vt, err := parseValidityTime(validityTime)
|
||||
if err != nil {
|
||||
return utils.NumberZero, err
|
||||
}
|
||||
return model.UserStoreAuthModel{}.Init().Edit(modelbase.Params{
|
||||
Eq: map[string]string{
|
||||
"id": strconv.FormatInt(id, utils.NumberTen),
|
||||
"user_id": strconv.FormatInt(userId, utils.NumberTen),
|
||||
"status": strconv.Itoa(int(dao.StatusEnabled)),
|
||||
},
|
||||
}, map[string]interface{}{
|
||||
"validity_time": vt,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -46,6 +46,17 @@ func RequireUserLogin(ctx context.Context) (utils.UserInfo, *analysis.Response)
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func RequireAnalysisUserId(ctx context.Context) (int64, utils.UserInfo, *analysis.Response) {
|
||||
user, fail := RequireUserLogin(ctx)
|
||||
if fail != nil {
|
||||
return utils.NumberZero, user, fail
|
||||
}
|
||||
if user.BizId < utils.NumberOne {
|
||||
return utils.NumberZero, user, OutResponse(utils.ErrorParams, "业务用户不存在")
|
||||
}
|
||||
return user.BizId, user, nil
|
||||
}
|
||||
|
||||
func LoadAnalysisUser(id int64) (*dao.User, error) {
|
||||
var row dao.User
|
||||
err := model.UserModel{}.Init().GetOne(modelbase.Params{
|
||||
@@ -59,3 +70,14 @@ func LoadAnalysisUser(id int64) (*dao.User, error) {
|
||||
}
|
||||
return &row, nil
|
||||
}
|
||||
|
||||
func SkinTypeOf(clientCode string) (int32, bool) {
|
||||
switch clientCode {
|
||||
case dao.ClientCodeUserSkin:
|
||||
return dao.SkinTypeUser, true
|
||||
case dao.ClientCodeStoreSkin:
|
||||
return dao.SkinTypeStore, true
|
||||
default:
|
||||
return 0, false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ type UserStoreAuthModel struct {
|
||||
}
|
||||
|
||||
func (m UserStoreAuthModel) TableName() string {
|
||||
return modelbase.Prefix() + "skin_user_images_authorize"
|
||||
return modelbase.Prefix() + "user_store_authorize"
|
||||
}
|
||||
|
||||
func (m UserStoreAuthModel) Init() UserStoreAuthModel {
|
||||
|
||||
@@ -23,13 +23,11 @@ func NewAnalysisStoreServer(svcCtx *svc.ServiceContext) *AnalysisStoreServer {
|
||||
}
|
||||
}
|
||||
|
||||
// 门店账号密码授权用户
|
||||
func (s *AnalysisStoreServer) StoreAuth(ctx context.Context, in *analysis.StoreAuthReq) (*analysis.Response, error) {
|
||||
l := analysisstorelogic.NewStoreAuthLogic(ctx, s.svcCtx)
|
||||
return l.StoreAuth(in)
|
||||
}
|
||||
|
||||
// 门店获取扫码授权二维码
|
||||
func (s *AnalysisStoreServer) StoreAuthQrcode(ctx context.Context, in *analysis.StoreAuthQrcodeReq) (*analysis.Response, error) {
|
||||
l := analysisstorelogic.NewStoreAuthQrcodeLogic(ctx, s.svcCtx)
|
||||
return l.StoreAuthQrcode(in)
|
||||
|
||||
@@ -43,8 +43,32 @@ func (s *AnalysisUserServer) UserDelete(ctx context.Context, in *analysis.UserDe
|
||||
return l.UserDelete(in)
|
||||
}
|
||||
|
||||
// 用户扫码确认/拒绝授权
|
||||
func (s *AnalysisUserServer) UserAuth(ctx context.Context, in *analysis.UserAuthReq) (*analysis.Response, error) {
|
||||
l := analysisuserlogic.NewUserAuthLogic(ctx, s.svcCtx)
|
||||
return l.UserAuth(in)
|
||||
}
|
||||
|
||||
func (s *AnalysisUserServer) UserAuthList(ctx context.Context, in *analysis.UserAuthListReq) (*analysis.Response, error) {
|
||||
l := analysisuserlogic.NewUserAuthListLogic(ctx, s.svcCtx)
|
||||
return l.UserAuthList(in)
|
||||
}
|
||||
|
||||
func (s *AnalysisUserServer) UserAuthDelete(ctx context.Context, in *analysis.UserAuthDeleteReq) (*analysis.Response, error) {
|
||||
l := analysisuserlogic.NewUserAuthDeleteLogic(ctx, s.svcCtx)
|
||||
return l.UserAuthDelete(in)
|
||||
}
|
||||
|
||||
func (s *AnalysisUserServer) UserAuthUpdate(ctx context.Context, in *analysis.UserAuthUpdateReq) (*analysis.Response, error) {
|
||||
l := analysisuserlogic.NewUserAuthUpdateLogic(ctx, s.svcCtx)
|
||||
return l.UserAuthUpdate(in)
|
||||
}
|
||||
|
||||
func (s *AnalysisUserServer) DeviceBind(ctx context.Context, in *analysis.DeviceBindReq) (*analysis.Response, error) {
|
||||
l := analysisuserlogic.NewDeviceBindLogic(ctx, s.svcCtx)
|
||||
return l.DeviceBind(in)
|
||||
}
|
||||
|
||||
func (s *AnalysisUserServer) DeviceInfo(ctx context.Context, in *analysis.DeviceInfoReq) (*analysis.Response, error) {
|
||||
l := analysisuserlogic.NewDeviceInfoLogic(ctx, s.svcCtx)
|
||||
return l.DeviceInfo(in)
|
||||
}
|
||||
|
||||
@@ -69,11 +69,12 @@ func GetRpcClient(serviceName string) (zrpc.Client, error) {
|
||||
}
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
DB *gorm.DB
|
||||
Prefix string
|
||||
UserSvcName string
|
||||
ChoreSvcName string
|
||||
Config config.Config
|
||||
DB *gorm.DB
|
||||
Prefix string
|
||||
UserSvcName string
|
||||
ChoreSvcName string
|
||||
EquipmentSvcName string
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext {
|
||||
@@ -85,11 +86,16 @@ func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext {
|
||||
if choreSvc == utils.StringEmpty {
|
||||
logx.Error("config services.chore empty")
|
||||
}
|
||||
equipmentSvc := utils.GetConfigString("services.equipment")
|
||||
if equipmentSvc == utils.StringEmpty {
|
||||
logx.Error("config services.equipment empty")
|
||||
}
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
DB: db,
|
||||
Prefix: utils.GetConfigString("mysql.prefix"),
|
||||
UserSvcName: userSvc,
|
||||
ChoreSvcName: choreSvc,
|
||||
Config: c,
|
||||
DB: db,
|
||||
Prefix: utils.GetConfigString("mysql.prefix"),
|
||||
UserSvcName: userSvc,
|
||||
ChoreSvcName: choreSvc,
|
||||
EquipmentSvcName: equipmentSvc,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user