56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/services/store/internal/dao"
|
|
"lone-services/services/store/internal/model"
|
|
"strconv"
|
|
|
|
"lone-services/rpc/store/pb"
|
|
"lone-services/services/store/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type SetDefLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewSetDefLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDefLogic {
|
|
return &SetDefLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *SetDefLogic) SetDef(in *store.EmptyRequest) (*store.Response, error) {
|
|
w := modelbase.Params{}
|
|
var info []dao.StoreCreate
|
|
model.StoreModel{}.Init().Items(w, &info)
|
|
for _, item := range info {
|
|
tw := modelbase.Params{
|
|
Eq: map[string]string{"id": strconv.FormatInt(item.Id, 10)},
|
|
}
|
|
mobile, aErr := utils.Crypto{}.AESDecryptECB(item.UserMobile)
|
|
if aErr != nil {
|
|
l.Logger.Error("AESDecryptECB = ", aErr, " id = ", item.Id)
|
|
continue
|
|
}
|
|
item.UserMobile, aErr = utils.EncryptPhone(mobile)
|
|
if aErr != nil {
|
|
l.Logger.Error("EncryptPhone = ", aErr, " id = ", item.Id)
|
|
continue
|
|
}
|
|
|
|
row, err := model.StoreModel{}.Init().Edit(tw, &item)
|
|
logx.Error("Edit = ", err, " row = ", row, " id = ", item.Id)
|
|
}
|
|
|
|
return &store.Response{}, nil
|
|
}
|