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