feat: diff wecom
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 28s
CI / admin (push) Successful in 21s
CI / bff (push) Successful in 20s
CI / chore (push) Successful in 29s
CI / equipment (push) Failing after 9s
CI / express (push) Successful in 20s
CI / factory (push) Successful in 21s
CI / payment (push) Successful in 22s
CI / product (push) Successful in 27s
CI / record (push) Successful in 26s
CI / sale (push) Successful in 32s
CI / task (push) Successful in 25s
CI / user (push) Successful in 31s
CI / wecom (push) Successful in 33s
CI / changes (push) Successful in 39s
CI / ad (push) Successful in 28s
CI / admin (push) Successful in 21s
CI / bff (push) Successful in 20s
CI / chore (push) Successful in 29s
CI / equipment (push) Failing after 9s
CI / express (push) Successful in 20s
CI / factory (push) Successful in 21s
CI / payment (push) Successful in 22s
CI / product (push) Successful in 27s
CI / record (push) Successful in 26s
CI / sale (push) Successful in 32s
CI / task (push) Successful in 25s
CI / user (push) Successful in 31s
CI / wecom (push) Successful in 33s
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package dao
|
||||
|
||||
type SmsLogCreate struct {
|
||||
Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT;comment:ID" json:"id"`
|
||||
Mobile string `gorm:"column:mobile;type:varchar(255)" json:"mobile"`
|
||||
Content string `gorm:"column:content;type:varchar(255)" json:"content"`
|
||||
BakContent string `gorm:"column:bak_content;type:varchar(255);comment:内容" json:"bak_content"`
|
||||
BrowserInfo string `gorm:"column:browser_info;type:varchar(255);comment:浏览器详细信息" json:"browser_info"`
|
||||
BrowserName string `gorm:"column:browser_name;type:varchar(255);comment:浏览器名称" json:"browser_name"`
|
||||
Ip string `gorm:"column:ip;type:varchar(20);comment:IP;NOT NULL" json:"ip"`
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"lone-services/pkg/sms"
|
||||
"lone-services/pkg/utils"
|
||||
"lone-services/rpc/chore/pb"
|
||||
"lone-services/services/chore/internal/dao"
|
||||
"lone-services/services/chore/internal/model"
|
||||
"lone-services/services/chore/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type SendPasswordLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewSendPasswordLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendPasswordLogic {
|
||||
return &SendPasswordLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *SendPasswordLogic) SendPassword(in *chore.SendPasswordReq) (*chore.SendPasswordResp, error) {
|
||||
if l.svcCtx.SMS == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "短信服务未配置")
|
||||
}
|
||||
|
||||
err := l.svcCtx.SMS.SendByKind(in.Mobile, sms.TemplatePassword, map[string]string{"code": in.Password})
|
||||
|
||||
log := dao.SmsLogCreate{
|
||||
Mobile: in.Mobile,
|
||||
Content: "您的初始密码为:" + in.Password + ",请尽快登录后修改!",
|
||||
BakContent: err.Error(),
|
||||
BrowserInfo: in.BrowserInfo,
|
||||
BrowserName: in.BrowserName,
|
||||
Ip: in.Ip,
|
||||
}
|
||||
sErr := model.SmsLogModel{}.Init().Create(&log)
|
||||
if sErr != nil {
|
||||
l.Errorf("sms log create: %v", sErr)
|
||||
return nil, status.Error(codes.Internal, "短信日志保存失败")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
l.Errorf("sms send: %v", err)
|
||||
return nil, status.Error(codes.InvalidArgument, "短信发送失败")
|
||||
}
|
||||
|
||||
return &chore.SendPasswordResp{Code: utils.NumberOne}, nil
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"lone-services/pkg/modelbase"
|
||||
)
|
||||
|
||||
type SmsLogModel struct {
|
||||
modelbase.Base
|
||||
}
|
||||
|
||||
func (m SmsLogModel) TableName() string {
|
||||
return modelbase.Prefix() + "sms_log"
|
||||
}
|
||||
|
||||
func (m SmsLogModel) Init() SmsLogModel {
|
||||
m.Table = m.TableName()
|
||||
return m
|
||||
}
|
||||
@@ -93,14 +93,17 @@ func (s *ChoreServer) SystemItems(ctx context.Context, in *chore.EmptyReq) (*cho
|
||||
return l.SystemItems(in)
|
||||
}
|
||||
|
||||
// 按 id 批量查地区名称
|
||||
func (s *ChoreServer) RegionsByIds(ctx context.Context, in *chore.RegionsByIdsReq) (*chore.RegionsByIdsData, error) {
|
||||
l := logic.NewRegionsByIdsLogic(ctx, s.svcCtx)
|
||||
return l.RegionsByIds(in)
|
||||
}
|
||||
|
||||
// 服务间:写入编辑申请日志
|
||||
func (s *ChoreServer) InternalActionApplyLogCreate(ctx context.Context, in *chore.InternalActionApplyLogCreateReq) (*chore.InternalActionApplyLogCreateData, error) {
|
||||
l := logic.NewInternalActionApplyLogCreateLogic(ctx, s.svcCtx)
|
||||
return l.InternalActionApplyLogCreate(in)
|
||||
}
|
||||
|
||||
func (s *ChoreServer) SendPassword(ctx context.Context, in *chore.SendPasswordReq) (*chore.SendPasswordResp, error) {
|
||||
l := logic.NewSendPasswordLogic(ctx, s.svcCtx)
|
||||
return l.SendPassword(in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user