package service import ( "github.com/gin-gonic/gin" "time" "ulink-admin/modules/system/dao" "ulink-admin/modules/system/models/model" "ulink-admin/modules/system/models/req" "ulink-admin/utils" ) type SmsService struct { SmsDao *dao.SmsDao `inject:""` } // List 查询所有短信管理业务方法 func (this SmsService) List(query *req.SmsQuery, list interface{}) { this.SmsDao.List(query, list) } // Page 查询短信管理分页列表 func (this SmsService) Page(query *req.SmsQuery, list interface{}) int64 { return this.SmsDao.Page(query, list) } // Insert 添加短信管理 func (this SmsService) Insert(sms *model.Sms) { this.SmsDao.Insert(sms) } // Get 查询 func (this SmsService) Get(id int64) *model.Sms { return this.SmsDao.GetById(id, &model.Sms{}).(*model.Sms) } // Delete 批量删除 func (this SmsService) Delete(list []int64) { this.SmsDao.Delete(&model.Sms{}, list) } // Edit 修改 func (this SmsService) Edit(sms *model.Sms, cols []string) { this.SmsDao.Update(sms, cols...) } func (this SmsService) GetSmsCode(phone string) string { smsCode := utils.CreateCode() param := gin.H{ "code": smsCode, "product": "身份验证", } utils.SendSms(phone, "登录验证", "SMS_5950449", param) this.Insert(&model.Sms{ Code: smsCode, Phone: phone, State: 1, Mode: "1", CreateTime: time.Now(), UpdateTime: time.Now(), }) return smsCode }