170 lines
5.1 KiB
Go
170 lines
5.1 KiB
Go
package dto
|
|
|
|
import (
|
|
"errors"
|
|
"go-admin/app/admin/models"
|
|
"go-admin/common/dto"
|
|
common "go-admin/common/models"
|
|
)
|
|
|
|
type SmsPhoneGetPageReq struct {
|
|
dto.Pagination `search:"-"`
|
|
Service string `form:"service" search:"type:exact;column:service;table:sms_phone" comment:"sms 服务"`
|
|
ServiceCode string `form:"serviceCode" search:"type:exact;column:service_code;table:sms_phone" comment:"服务code"`
|
|
Type int `form:"type" search:"-" comment:"类型 0-短效 1-长效"`
|
|
SmsPhoneOrder
|
|
}
|
|
|
|
type SmsPhoneOrder struct {
|
|
Id string `form:"idOrder" search:"type:order;column:id;table:sms_phone"`
|
|
UserId string `form:"userIdOrder" search:"type:order;column:user_id;table:sms_phone"`
|
|
Service string `form:"serviceOrder" search:"type:order;column:service;table:sms_phone"`
|
|
ServiceCode string `form:"serviceCodeOrder" search:"type:order;column:service_code;table:sms_phone"`
|
|
TypeOrder string `form:"typeOrder" search:"type:order;column:type;table:sms_phone"`
|
|
Period string `form:"periodOrder" search:"type:order;column:period;table:sms_phone"`
|
|
Phone string `form:"phoneOrder" search:"type:order;column:phone;table:sms_phone"`
|
|
CreatedAt string `form:"createdAtOrder" search:"type:order;column:created_at;table:sms_phone"`
|
|
UpdatedAt string `form:"updatedAtOrder" search:"type:order;column:updated_at;table:sms_phone"`
|
|
DeletedAt string `form:"deletedAtOrder" search:"type:order;column:deleted_at;table:sms_phone"`
|
|
CreateBy string `form:"createByOrder" search:"type:order;column:create_by;table:sms_phone"`
|
|
UpdateBy string `form:"updateByOrder" search:"type:order;column:update_by;table:sms_phone"`
|
|
}
|
|
|
|
func (m *SmsPhoneGetPageReq) GetNeedSearch() interface{} {
|
|
return *m
|
|
}
|
|
|
|
type SmsPhoneInsertReq struct {
|
|
Id int `json:"-" comment:"主键id"` // 主键id
|
|
UserId int `json:"userId" comment:"用户Id"`
|
|
Service string `json:"service" comment:"sms 服务"`
|
|
ServiceCode string `json:"serviceCode" comment:"服务code"`
|
|
Type int `json:"type" comment:"类型 0-短效 1-长效"`
|
|
Period int `json:"period" comment:"时长(月)"`
|
|
Phone string `json:"phone" comment:"号码"`
|
|
common.ControlBy
|
|
}
|
|
|
|
func (s *SmsPhoneInsertReq) Generate(model *models.SmsPhone) {
|
|
if s.Id == 0 {
|
|
model.Model = common.Model{Id: s.Id}
|
|
}
|
|
model.UserId = s.UserId
|
|
model.Service = s.Service
|
|
model.ServiceCode = s.ServiceCode
|
|
model.Type = s.Type
|
|
model.Period = s.Period
|
|
model.Phone = s.Phone
|
|
model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
|
|
}
|
|
|
|
func (s *SmsPhoneInsertReq) GetId() interface{} {
|
|
return s.Id
|
|
}
|
|
|
|
type SmsPhoneUpdateReq struct {
|
|
Id int `uri:"id" comment:"主键id"` // 主键id
|
|
UserId int `json:"userId" comment:"用户Id"`
|
|
Service string `json:"service" comment:"sms 服务"`
|
|
ServiceCode string `json:"serviceCode" comment:"服务code"`
|
|
Type int `json:"type" comment:"类型 0-短效 1-长效"`
|
|
Period int `json:"period" comment:"时长(月)"`
|
|
Phone string `json:"phone" comment:"号码"`
|
|
common.ControlBy
|
|
}
|
|
|
|
func (s *SmsPhoneUpdateReq) Generate(model *models.SmsPhone) {
|
|
if s.Id == 0 {
|
|
model.Model = common.Model{Id: s.Id}
|
|
}
|
|
model.UserId = s.UserId
|
|
model.Service = s.Service
|
|
model.ServiceCode = s.ServiceCode
|
|
model.Type = s.Type
|
|
model.Period = s.Period
|
|
model.Phone = s.Phone
|
|
model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
|
|
}
|
|
|
|
func (s *SmsPhoneUpdateReq) GetId() interface{} {
|
|
return s.Id
|
|
}
|
|
|
|
// SmsPhoneGetReq 功能获取请求参数
|
|
type SmsPhoneGetReq struct {
|
|
Id int `uri:"id"`
|
|
}
|
|
|
|
func (s *SmsPhoneGetReq) GetId() interface{} {
|
|
return s.Id
|
|
}
|
|
|
|
// SmsPhoneDeleteReq 功能删除请求参数
|
|
type SmsPhoneDeleteReq struct {
|
|
Ids []int `json:"ids"`
|
|
}
|
|
|
|
func (s *SmsPhoneDeleteReq) GetId() interface{} {
|
|
return s.Ids
|
|
}
|
|
|
|
type GetNumberReq struct {
|
|
Type int `json:"type" form:"type" comment:"类型 0-短效 1-长效"`
|
|
ServiceCode string `json:"serviceCode" form:"serviceCode" comment:"服务code"`
|
|
Period int `json:"period" form:"period" comment:"时长(月)"`
|
|
}
|
|
|
|
func (s *GetNumberReq) Validate() error {
|
|
if s.Type > 1 || s.Type < 0 {
|
|
return errors.New("租赁类型错误")
|
|
}
|
|
|
|
if s.ServiceCode == "" {
|
|
return errors.New("请先选择服务")
|
|
}
|
|
|
|
if s.Type == 1 && s.Period <= 0 {
|
|
return errors.New("长租时长不能为空")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type GetCodeReq struct {
|
|
ActivationIds []int `form:"activationIds"`
|
|
}
|
|
|
|
type GetCodeResp struct {
|
|
ActivationId int `json:"activationId" comment:"激活码id"`
|
|
Code string `json:"code" comment:"验证码"`
|
|
Status int `json:"status" comment:"状态 1-等待验证码 2-已获取"`
|
|
}
|
|
|
|
type WeakUpReq struct {
|
|
ActivationId int `json:"activationId" comment:"激活码id"`
|
|
}
|
|
|
|
func (s *WeakUpReq) Validate() error {
|
|
if s.ActivationId <= 0 {
|
|
return errors.New("激活码id不能为空")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type DeleteMyNumberReq struct {
|
|
Id int `json:"id" comment:"短信号码id"`
|
|
}
|
|
|
|
func (s *DeleteMyNumberReq) Validate() error {
|
|
if s.Id <= 0 {
|
|
return errors.New("号码不能为空")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type SmsPhoneCancelNumberReq struct {
|
|
Id int `json:"id" comment:"短信号码id"`
|
|
}
|