新需求

This commit is contained in:
桀尼龟 2025-03-11 20:08:53 +08:00
parent 7f66dbd067
commit f5b541ed73
8 changed files with 2031 additions and 1970 deletions

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,18 @@ service Account {
rpc GenerateSliderCaptcha(GenerateSliderCaptchaRequest) returns (GenerateSliderCaptchaResponse) {}// +
rpc VerifySliderCaptcha(VerifySliderCaptchaRequest) returns (VerifySliderCaptchaResponse) {}//
rpc SendNationMsg (SendNationMsgRequest) returns (SendMsgStatusResponse) {} // --
rpc VerifySliderStatus(VerifySliderStatusRequest) returns (VerifySliderStatusResponse) {}//
}
message VerifySliderStatusRequest {
string nonceStr = 1;
}
message VerifySliderStatusResponse {
string nonceStr = 1;
int32 status = 2;
}
message SendNationMsgRequest {
string Domain = 1 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string TelNum = 2 [json_name = "telNum",(validator.field) = {string_not_empty: true,human_error: "70001"}];
@ -128,6 +139,8 @@ message UserListInfo{
string notPassRemarks = 15;
string telNum = 16;
string telAreaCode = 17;
string language = 18;
string subscriberNumber = 19;
}
message UserListRequest{
string domain = 1;
@ -155,6 +168,8 @@ message UserInfoResponse{
string subNum = 12;
string notPassRemarks = 13;
string domain = 14;
string language = 15;
string subscriberNumber = 16;
}
message RealNameResponse{
uint64 id = 1;
@ -400,6 +415,7 @@ message SendMsgRequest {
uint32 mId = 5;
string scope = 6; //
string zone = 7; //
string nonceStr = 8;
}
message SendCustomMsgRequest {
@ -469,30 +485,8 @@ message RemoveResponse {
message UpdateRequest {
uint64 ID = 1 [json_name = "ID"]; //ID
string Domain = 2 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
string NickName = 3 [json_name = "nickName"];
string Password = 4 [json_name = "password"]; //
string Avatar = 5 [json_name = "avatar"]; //
string Status = 7 [json_name = "status"];
string TelNum = 8 [json_name = "telNum"];
string EnterDate = 14 [json_name = "enterDate"];
Extend Extend = 17 [json_name = "extend"];
string Title = 18 [json_name = "title"];
string JobNum = 19 [json_name = "jobNum"];
string BirthDate = 20 [json_name = "birthDate"];
uint64 Sex = 21 [json_name = "sex"];
string IdNum = 22 [json_name = "idNum"];
string RealName = 23 [json_name = "realName"];
string InvitationCode = 24 [json_name = "invitationCode"];
string LeftDate = 25 [json_name = "leftDate"];
string Remark = 26 [json_name = "remark"];
string RecentImg = 27 [json_name = "recentImg"];
string ICNum = 28 [json_name = "icNum"];
string Train = 29 [json_name = "train"];
string Certificate = 30 [json_name = "certificate"];
repeated trainVideo TrainVideos = 31 [json_name = "trainVideos"];
Operator operator = 32;
string SecurityCode = 33 [json_name = "securityCode"];
string Domain = 2 [json_name = "domain"];
string Language = 3 [json_name = "language"];
}
message Operator {
@ -582,6 +576,7 @@ message RegistRequest {
string code = 3;
string address = 4;
string telAreaCode = 5;
string language = 6;
}
message LoginRequest {

View File

@ -17,6 +17,12 @@ var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
func (this *VerifySliderStatusRequest) Validate() error {
return nil
}
func (this *VerifySliderStatusResponse) Validate() error {
return nil
}
func (this *SendNationMsgRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
@ -274,26 +280,6 @@ func (this *RemoveResponse) Validate() error {
return nil
}
func (this *UpdateRequest) Validate() error {
if this.Domain == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
}
if this.Extend != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Extend); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Extend", err)
}
}
for _, item := range this.TrainVideos {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("TrainVideos", err)
}
}
}
if this.Operator != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Operator); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Operator", err)
}
}
return nil
}
func (this *Operator) Validate() error {

View File

@ -67,6 +67,7 @@ type AccountClient interface {
GenerateSliderCaptcha(ctx context.Context, in *GenerateSliderCaptchaRequest, opts ...grpc_go.CallOption) (*GenerateSliderCaptchaResponse, common.ErrorWithAttachment)
VerifySliderCaptcha(ctx context.Context, in *VerifySliderCaptchaRequest, opts ...grpc_go.CallOption) (*VerifySliderCaptchaResponse, common.ErrorWithAttachment)
SendNationMsg(ctx context.Context, in *SendNationMsgRequest, opts ...grpc_go.CallOption) (*SendMsgStatusResponse, common.ErrorWithAttachment)
VerifySliderStatus(ctx context.Context, in *VerifySliderStatusRequest, opts ...grpc_go.CallOption) (*VerifySliderStatusResponse, common.ErrorWithAttachment)
}
type accountClient struct {
@ -112,6 +113,7 @@ type AccountClientImpl struct {
GenerateSliderCaptcha func(ctx context.Context, in *GenerateSliderCaptchaRequest) (*GenerateSliderCaptchaResponse, error)
VerifySliderCaptcha func(ctx context.Context, in *VerifySliderCaptchaRequest) (*VerifySliderCaptchaResponse, error)
SendNationMsg func(ctx context.Context, in *SendNationMsgRequest) (*SendMsgStatusResponse, error)
VerifySliderStatus func(ctx context.Context, in *VerifySliderStatusRequest) (*VerifySliderStatusResponse, error)
}
func (c *AccountClientImpl) GetDubboStub(cc *triple.TripleConn) AccountClient {
@ -354,6 +356,12 @@ func (c *accountClient) SendNationMsg(ctx context.Context, in *SendNationMsgRequ
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SendNationMsg", in, out)
}
func (c *accountClient) VerifySliderStatus(ctx context.Context, in *VerifySliderStatusRequest, opts ...grpc_go.CallOption) (*VerifySliderStatusResponse, common.ErrorWithAttachment) {
out := new(VerifySliderStatusResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/VerifySliderStatus", in, out)
}
// AccountServer is the server API for Account service.
// All implementations must embed UnimplementedAccountServer
// for forward compatibility
@ -397,6 +405,7 @@ type AccountServer interface {
GenerateSliderCaptcha(context.Context, *GenerateSliderCaptchaRequest) (*GenerateSliderCaptchaResponse, error)
VerifySliderCaptcha(context.Context, *VerifySliderCaptchaRequest) (*VerifySliderCaptchaResponse, error)
SendNationMsg(context.Context, *SendNationMsgRequest) (*SendMsgStatusResponse, error)
VerifySliderStatus(context.Context, *VerifySliderStatusRequest) (*VerifySliderStatusResponse, error)
mustEmbedUnimplementedAccountServer()
}
@ -519,6 +528,9 @@ func (UnimplementedAccountServer) VerifySliderCaptcha(context.Context, *VerifySl
func (UnimplementedAccountServer) SendNationMsg(context.Context, *SendNationMsgRequest) (*SendMsgStatusResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendNationMsg not implemented")
}
func (UnimplementedAccountServer) VerifySliderStatus(context.Context, *VerifySliderStatusRequest) (*VerifySliderStatusResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method VerifySliderStatus not implemented")
}
func (s *UnimplementedAccountServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
@ -1649,6 +1661,35 @@ func _Account_SendNationMsg_Handler(srv interface{}, ctx context.Context, dec fu
return interceptor(ctx, in, info, handler)
}
func _Account_VerifySliderStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(VerifySliderStatusRequest)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("VerifySliderStatus", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
// Account_ServiceDesc is the grpc_go.ServiceDesc for Account service.
// It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -1808,6 +1849,10 @@ var Account_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "SendNationMsg",
Handler: _Account_SendNationMsg_Handler,
},
{
MethodName: "VerifySliderStatus",
Handler: _Account_VerifySliderStatus_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "api/account/account.proto",

View File

@ -22,6 +22,10 @@ func migration() {
AddTable(&RealName{})
AddTable(&User{})
AddTable(&RefreshToken{})
AddColumn(&User{}, "nickname")
AddColumn(&User{}, "language")
AddColumn(&User{}, "subscriber_number")
}
// 数据迁移

View File

@ -49,6 +49,9 @@ type User struct {
RealName *RealName `gorm:"foreignKey:RealNameID" json:"RealName"`
PasswordDigest string
NotPassRemarks string `gorm:"column:not_pass_remarks;comment:不通过备注" json:"notPassRemarks"`
Nickname string `gorm:"column:nickname;comment:昵称" json:"nickname"`
Language string `gorm:"column:language;comment:语言" json:"language"`
SubscriberNumber string `gorm:"column:subscriber_number;comment:用户id" json:"subscriberNumber"`
}
const (

View File

@ -101,6 +101,8 @@ func BuildUserList(user []*model.User) []*account.UserListInfo {
NotPassRemarks: i.NotPassRemarks,
TelNum: i.TelNum,
TelAreaCode: i.TelAreaCode,
Language: i.Language,
SubscriberNumber: i.SubscriberNumber,
})
}
return userList

View File

@ -510,6 +510,13 @@ func (a *AccountProvider) Register(_ context.Context, in *account.RegistRequest)
if err != nil {
log.Fatalf("加载时区失败: %v", err)
}
date := time.Now().Format("20060102")
// 生成一个 5 位随机数
rand2.Seed(time.Now().UnixNano())
randomNum := rand2.Intn(90000) + 10000
SubscriberNumber := fmt.Sprintf("FiEE%s%05d", date, randomNum)
user := model.User{
Domain: &in.Domain,
TelNum: in.TelNum,
@ -518,6 +525,8 @@ func (a *AccountProvider) Register(_ context.Context, in *account.RegistRequest)
RegistrationTime: time.Now().In(loc).Format("2006-01-02 15:04:05"),
SubNum: subNum.String,
RealNameID: nil,
SubscriberNumber: SubscriberNumber,
Language: in.Language,
}
if err = model.DB.Create(&user).Error; err != nil {
return &account.RegisterResponse{Status: 0}, err
@ -620,6 +629,8 @@ func (a *AccountProvider) Info(ctx context.Context, in *account.InfoRequest) (*a
Attachment: realName.Attachment,
SubNum: user.SubNum,
NotPassRemarks: user.NotPassRemarks,
Language: user.Language,
SubscriberNumber: user.SubscriberNumber,
}
return response, nil
@ -1002,7 +1013,18 @@ func (a *AccountProvider) UpdateTelNum(_ context.Context, in *account.SendNewTel
return response, err
}
func (a *AccountProvider) Update(_ context.Context, in *account.UpdateRequest) (*account.UpdateResponse, error) {
response := &account.UpdateResponse{}
var user *model.User
if err := model.DB.First(&user, in.ID).Error; err != nil {
return response, errors.New(m.Not_Found)
}
err := model.DB.Model(&model.User{}).Where("id = ?", in.ID).Updates(&model.User{Language: in.Language}).Error
if err != nil {
return nil, err
}
return response, nil
}
func (a *AccountProvider) SendCustomMsg(ctx context.Context, in *account.SendCustomMsgRequest) (*account.SendMsgStatusResponse, error) {
response := &account.SendMsgStatusResponse{}
var user *model.User
@ -1091,3 +1113,22 @@ func (a *AccountProvider) UsersByJobNum(_ context.Context, in *account.UsersByJo
return response, nil
}
func (a *AccountProvider) VerifySliderStatus(_ context.Context, in *account.VerifySliderStatusRequest) (*account.VerifySliderStatusResponse, error) {
resp := &account.VerifySliderStatusResponse{}
status, err := cache.RedisClient.Get("SliderStatus:" + in.NonceStr).Result()
if err == redis.Nil {
err = errors.New("滑块验证状态不存在,请退出重试")
return resp, err
}
if status == "unused" {
// 获取原有的过期时间
ttl, _ := cache.RedisClient.TTL("SliderStatus:" + in.NonceStr).Result()
cache.RedisClient.Set("SliderStatus:"+in.NonceStr, "used", ttl)
resp.Status = 1 // 未使用
} else if status == "used" {
resp.Status = 2 // 已使用
}
return resp, nil
}