123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- package admin
- import (
- "ulink-admin/frame"
- "ulink-admin/modules/site/models/model"
- "ulink-admin/modules/site/models/req"
- "ulink-admin/modules/site/service"
- "ulink-admin/pkg/excels"
- "ulink-admin/pkg/file"
- "ulink-admin/pkg/page"
- )
- type SiteApi struct {
- siteService service.SiteService
- }
- // List 查询站点管理分页数据
- // @Summary 分页查询站点管理数据接口
- // @Description 分页查询站点管理数据接口
- // @Tags 站点管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param object query req.SiteQuery false "查询参数"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=page.Page{list=model.Site},msg=string} "分页获取站点管理列表,返回包括列表,总数,页码,每页数量"
- // @Router /site/page [get]
- func (this SiteApi) Page(c *frame.Context) {
- query := &req.SiteQuery{}
- c.ValidteError(c.ShouldBind(query), query)
- find, i := this.siteService.Page(query)
- c.Ok(page.Page{List: find, 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.SiteQuery false "查询参数"
- // @Security ApiKeyAuth
- // @Success 200 {object} resp.Response{data=model.Site,msg=string} "分页获取站点管理列表,返回包括列表,总数,页码,每页数量"
- // @Router /site/list [get]
- func (this SiteApi) List(c *frame.Context) {
- query := &req.SiteQuery{}
- list := &model.Site{}
- c.ValidteError(c.ShouldBind(query), query)
- this.siteService.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.Site,msg=string} "返回站点管理详情查询"
- // @Router /site [get]
- func (this SiteApi) 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.siteService.Get(req.Id))
- }
- // Add 新增站点管理
- // @Summary 新增站点管理接口
- // @Description 新增站点管理接口
- // @Tags 站点管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param data body model.Site true "站点管理实体对象"
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /site/add [post]
- func (this SiteApi) Add(c *frame.Context) {
- site := &model.Site{}
- c.ValidteError(c.ShouldBind(site), site)
- this.siteService.Insert(site)
- }
- // Edit 修改站点管理数据接口
- // @Summary 修改站点管理接口
- // @Description 新增站点管理接口
- // @Tags 站点管理相关接口
- // @Accept application/json
- // @Produce application/json
- // @Param Authorization header string false "Bearer 令牌"
- // @Param data body model.Site true "站点管理实体对象"
- // @Success 200 {object} resp.Response{msg=string} "操作状态"
- // @Router /site/edit [put]
- func (this SiteApi) Edit(c *frame.Context) {
- site := &model.Site{}
- c.ValidteError(c.ShouldBind(site), site)
- this.siteService.Edit(site, 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 /site [delete]
- func (a SiteApi) Delete(c *frame.Context) {
- var req struct {
- Ids []int64 `form:"ids" binding:"required" msg:"ids不存在"` //ids
- }
- c.ValidteError(c.ShouldBind(&req), &req)
- a.siteService.Delete(req.Ids)
- }
- // Export 导出excel
- func (this SiteApi) Export(c *frame.Context) {
- query := &req.SiteQuery{}
- list := make([]model.Site, 0)
- c.ValidteError(c.ShouldBind(query), query)
- this.siteService.List(query, list)
- excelList := make([]interface{}, 0)
- for _, site := range list {
- excelList = append(excelList, site)
- }
- _, files := excels.ExportExcel(excelList, "站点管理数据表")
- file.DownloadExcel(c, files)
- }
|