123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- package admin
- import (
- "ulink-admin/frame"
- "ulink-admin/modules/system/models/model"
- "ulink-admin/modules/system/models/req"
- "ulink-admin/modules/system/models/response"
- "ulink-admin/modules/system/service"
- "ulink-admin/pkg/excels"
- "ulink-admin/pkg/file"
- "ulink-admin/pkg/page"
- "ulink-admin/utils"
- )
- type SmsApi struct {
- SmsService *service.SmsService `inject:""`
- }
- // List 查询短信管理分页数据
- // @Summary 分页查询短信管理数据接口
- // @Description 分页查询短信管理数据接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param object query req.SmsQuery false "查询参数"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=page.Page{list=model.Sms},msg=string} "分页获取短信管理列表,返回包括列表,总数,页码,每页数量"
- // @Router /sms/page [get]
- func (this SmsApi) Page(c *frame.Context) {
- query := &req.SmsQuery{}
- c.ValidteError(c.ShouldBind(query), query)
- list := make([]response.SmsResponse, 0)
- i := this.SmsService.Page(query, &list)
- c.Ok(page.Page{List: list, Total: i, Size: query.PageSize})
- }
- // List 查询短信管理所有数据
- // @Summary 查询全部数据短信管理数据接口
- // @Description 查询全部数据短信管理数据接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param object query req.SmsQuery false "查询参数"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=model.Sms,msg=string} "分页获取短信管理列表,返回包括列表,总数,页码,每页数量"
- // @Router /sms/list [get]
- func (this SmsApi) List(c *frame.Context) {
- query := &req.SmsQuery{}
- list := make([]response.SmsResponse, 0)
- c.ValidteError(c.ShouldBind(query), query)
- this.SmsService.List(query, &list)
- c.Ok(list)
- }
- // Get 根据短信管理Id获取详细信息
- // @Summary 短信管理详情查询接口
- // @Description 短信管理详情查询接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param id query int true "id" id
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=model.Sms,msg=string} "返回短信管理详情查询"
- // @Router /sms [get]
- func (this SmsApi) Get(c *frame.Context) {
- var req struct {
- Id int64 `form:"id" binding:"required" msg:"id不存在" ` //id
- }
- c.ValidteError(c.ShouldBind(&req), &req)
- c.Ok(this.SmsService.Get(req.Id))
- }
- // Get 根据短信管理Id获取详细信息
- // @Summary 短信管理详情查询接口
- // @Description 短信管理详情查询接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param id query int true "id" id
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=model.Sms,msg=string} "返回短信管理详情查询"
- // @Router /sms/code [get]
- func (this SmsApi) GetSmsCode(c *frame.Context) {
- var req struct {
- Phone string `form:"phone" binding:"required" msg:"手机号不存在" ` //id
- }
- c.ValidteError(c.ShouldBind(&req), &req)
- c.Ok(this.SmsService.GetSmsCode(req.Phone))
- }
- // Add 新增短信管理
- // @Summary 新增短信管理接口
- // @Description 新增短信管理接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param data body model.Sms true "短信管理实体对象"
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /sms/add [post]
- func (this SmsApi) Add(c *frame.Context) {
- params, sms := &req.SmsAdd{}, &model.Sms{}
- c.ValidteError(c.ShouldBind(params), params)
- utils.CopyFields(sms, params)
- this.SmsService.Insert(sms)
- }
- // Edit 修改短信管理数据接口
- // @Summary 修改短信管理接口
- // @Description 新增短信管理接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param data body model.Sms true "短信管理实体对象"
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /sms/edit [put]
- func (this SmsApi) Edit(c *frame.Context) {
- params, sms := &req.SmsEdit{}, &model.Sms{}
- c.ValidteError(c.ShouldBind(params), params)
- utils.CopyFields(sms, params)
- this.SmsService.Edit(sms, c.Cols())
- }
- // Delete 删除短信管理数据
- // @Summary 删除短信管理接口
- // @Description 删除短信管理接口
- // @Tags 短信管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param id path int true "id" id
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /sms [delete]
- func (a SmsApi) Delete(c *frame.Context) {
- var req struct {
- Ids []int64 `form:"ids" binding:"required" msg:"ids不存在"` //ids
- }
- c.ValidteError(c.ShouldBind(&req), &req)
- a.SmsService.Delete(req.Ids)
- }
- // Export 导出excel
- func (this SmsApi) Export(c *frame.Context) {
- query := &req.SmsQuery{}
- list := make([]model.Sms, 0)
- c.ValidteError(c.ShouldBind(query), query)
- this.SmsService.List(query, list)
- excelList := make([]interface{}, 0)
- for _, sms := range list {
- excelList = append(excelList, sms)
- }
- _, files := excels.ExportExcel(excelList, "短信管理数据表")
- file.DownloadExcel(c, files)
- }
|