123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- package admin
- import (
- "ulink-admin/frame"
- "ulink-admin/modules/car/models/model"
- "ulink-admin/modules/car/models/req"
- "ulink-admin/modules/car/service"
- "ulink-admin/pkg/excels"
- "ulink-admin/pkg/file"
- "ulink-admin/pkg/page"
- )
- type ViolationApi struct {
- ViolationService *service.ViolationService `inject:""`
- }
- func (this ViolationApi) Page(c *frame.Context) {
- query := &req.ViolationQuery{}
- c.ValidteError(c.ShouldBind(query), query)
- find, i := this.ViolationService.Page(query)
- c.Ok(page.Page{List: find, Total: i, Size: query.PageSize})
- }
- func (this ViolationApi) List(c *frame.Context) {
- query := &req.ViolationQuery{}
- list := make([]model.Violation, 0)
- c.ValidteError(c.ShouldBind(query), query)
- this.ViolationService.List(query, &list)
- c.Ok(list)
- }
- func (this ViolationApi) Get(c *frame.Context) {
- var req struct {
- Id int64 `form:"id" binding:"required" msg:"id不存在" `
- }
- c.ValidteError(c.ShouldBind(&req), &req)
- c.Ok(this.ViolationService.Get(req.Id))
- }
- func (this ViolationApi) Add(c *frame.Context) {
- violation := &model.Violation{}
- c.ValidteError(c.ShouldBind(violation), violation)
- this.ViolationService.Insert(violation)
- }
- func (this ViolationApi) Edit(c *frame.Context) {
- violation := &model.Violation{}
- c.ValidteError(c.ShouldBind(violation), violation)
- this.ViolationService.Edit(violation, c.Cols())
- }
- func (a ViolationApi) Delete(c *frame.Context) {
- var req struct {
- Ids []int64 `form:"ids" binding:"required" msg:"ids不存在"`
- }
- c.ValidteError(c.ShouldBind(&req), &req)
- a.ViolationService.Delete(req.Ids)
- }
- func (this ViolationApi) Export(c *frame.Context) {
- query := &req.ViolationQuery{}
- list := make([]model.Violation, 0)
- c.ValidteError(c.ShouldBind(query), query)
- this.ViolationService.List(query, list)
- excelList := make([]interface{}, 0)
- for _, violation := range list {
- excelList = append(excelList, violation)
- }
- _, files := excels.ExportExcel(excelList, "服务项目数据表")
- file.DownloadExcel(c, files)
- }
|