package controller import ( "gas-cylinder-api/app/admin/model" "gas-cylinder-api/app/admin/service" "gas-cylinder-api/app/admin/service/dto" "gas-cylinder-api/common/actions" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "gogs.baozhida.cn/zoie/OAuth-core/api" "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth/user" ) type InspectExpandController struct { api.Api } // GetPage 获取入户安全检查项项列表 // @Summary 获取入户安全检查项项列表 // @Description 获取入户安全检查项项列表 // @Tags 入户安全检查项项 // @Param state query int false "订单状态 状态 0-待整改 1-整改中 2-已整改 -1 合格" // @Param inspectStartTime query string false "检查开始时间" // @Param inspectEndTime query string false "检查结束时间" // @Param customerName query string false "客户名称" // @Param inspectorName query string false "检查人" // @Param pageSize query int false "页条数" // @Param page query int false "页码" // @Success 200 {object} response.Response{data=response.Page{list=[]model.InspectExpand}} "{"code": 200, "data": [...]}" // @Router /api/inspect_record [get] // @Security Bearer func (e InspectExpandController) GetPage(c *gin.Context) { s := service.InspectExpand{} req := dto.InspectExpandGetPageReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.Query). MakeService(&s.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } //数据权限检查 p := actions.GetPermissionFromContext(c) list := make([]model.InspectExpand, 0) var count int64 err = s.GetPage(&req, &list, &count, p) if err != nil { e.Error(500, err, err.Error()) return } e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") } // Insert 添加入户安全检查项项 // @Summary 添加入户安全检查项项 // @Description 添加入户安全检查项项 // @Tags 入户安全检查项项 // @Accept application/json // @Product application/json // @Param data body dto.InspectExpandInsertReq true "data" // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /api/inspect_record [post] // @Security Bearer func (e InspectExpandController) Insert(c *gin.Context) { s := service.InspectExpand{} req := dto.InspectExpandInsertReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). MakeService(&s.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } //数据权限检查 p := actions.GetPermissionFromContext(c) // 设置创建人 req.SetCreateBy(user.GetUserId(c)) req.SetDeptId(user.GetDeptId(c)) err = s.Insert(&req, p) if err != nil { e.Error(500, err, err.Error()) return } e.OK(req.GetId(), "创建成功") } // Update 修改入户安全检查项项 // @Summary 修改入户安全检查项项 // @Description 修改入户安全检查项项 // @Tags 入户安全检查项项 // @Accept application/json // @Product application/json // @Param data body dto.InspectExpandInsertReq true "data" // @Success 200 {string} string "{"code": 200, "message": "添加成功"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Router /api/inspect_record [post] // @Security Bearer func (e InspectExpandController) Update(c *gin.Context) { s := service.InspectExpand{} userSvc := service.SysUser{} req := dto.InspectExpandInsertReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON). MakeService(&s.Service). MakeService(&userSvc.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } // 设置创建人 req.SetCreateBy(user.GetUserId(c)) req.SetDeptId(user.GetDeptId(c)) err = s.Update(&req) if err != nil { e.Error(500, err, err.Error()) return } e.OK(req.GetId(), "修改成功") } // Delete 删除钢瓶状态 // @Summary 删除钢瓶状态 // @Description 删除钢瓶状态 // @Tags 钢瓶状态 // @Accept application/json // @Product application/json // @Param data body dto.GasCylinderStatusDeleteReq true "body" // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Router /api/dispatch-cost [delete] // @Security Bearer func (e InspectExpandController) Delete(c *gin.Context) { s := service.InspectExpand{} req := dto.InspectExpandDeleteReq{} userSvc := service.SysUser{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). MakeService(&s.Service). MakeService(&userSvc.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } //数据权限检查 p := actions.GetPermissionFromContext(c) err = s.Remove(&req, p) if err != nil { e.Error(500, err, err.Error()) return } e.OK(req.GetId(), "删除成功") } // SyncStore 删除钢瓶状态 // @Summary 删除钢瓶状态 // @Description 删除钢瓶状态 // @Tags 钢瓶状态 // @Accept application/json // @Product application/json // @Param data body dto.InspectExpandSyncStoreReq true "body" // @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": -1, "message": "删除失败"}" // @Router /api/dispatch-cost [delete] // @Security Bearer func (e InspectExpandController) SyncStore(c *gin.Context) { s := service.InspectExpand{} req := dto.InspectExpandSyncStoreReq{} err := e.MakeContext(c). MakeOrm(). Bind(&req, binding.JSON, nil). MakeService(&s.Service). Errors if err != nil { e.Logger.Error(err) e.Error(500, err, err.Error()) return } //数据权限检查 p := actions.GetPermissionFromContext(c) err = s.SyncStore(&req, p) if err != nil { e.Error(500, err, err.Error()) return } e.OK(req.StoreIds, "同步成功") }