123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- 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/response"
- )
- type FillDataController struct {
- api.Api
- }
- // GetPage 获取上报实时充装数据
- // @Summary 获取上报实时充装数据
- // @Description 获取上报实时充装数据
- // @Tags 上报实时充装数据
- // @Param stationId query string false "气站id"
- // @Param userId query string false "充装人员id"
- // @Param innerCode query string false "气瓶单位内编码"
- // @Param chipId query string false "高频编码"
- // @Param startFillTime query string false "充装开始时间"
- // @Param endFillTime query string false "充装结束时间"
- // @Param pageSize query int false "页条数"
- // @Param page query int false "页码"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.FillData}} "{"code": 200, "data": [...]}"
- // @Router /api/goods [get]
- // @Security Bearer
- func (e FillDataController) GetPage(c *gin.Context) {
- s := service.FillData{}
- req := dto.FillDataGetPageReq{}
- 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.FillData, 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.FillDataInsertReq true "data"
- // @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
- // @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
- // @Router /api/goods [post]
- // @Security Bearer
- func (e FillDataController) Insert(c *gin.Context) {
- s := service.FillData{}
- fillGunSvc := service.FillGun{}
- req := dto.FillDataInsertReq{}
- err := e.MakeContext(c).
- MakeOrm().
- Bind(&req, binding.JSON).
- MakeService(&s.Service).
- MakeService(&fillGunSvc.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(p.DeptId)
- // 获取充装枪信息
- var fillGun model.FillGun
- err = fillGunSvc.GetByCode(req.ScanGunCode, &fillGun)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- err = s.Insert(&req, fillGun)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- e.OK(req.GetId(), "创建成功")
- }
- // StationList 搜索-气站列表
- // @Summary 搜索-气站列表
- // @Description 搜索-气站列表
- // @Tags 上报实时充装数据
- // @Param deptName query string false "操作记录名称"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
- // @Router /api/operation-log [get]
- // @Security Bearer
- func (e FillDataController) StationList(c *gin.Context) {
- s := service.FillData{}
- err := e.MakeContext(c).
- MakeOrm().
- 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.FillDataDistinctStation, 0)
- var count int64
- err = s.GetStationList(&list, &count, p)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- e.PageOK(list, int(count), 0, 0, "查询成功")
- }
- // UserList 搜索-送气员列表
- // @Summary 搜索-送气员列表
- // @Description 搜索-送气员列表
- // @Tags 上报实时充装数据
- // @Param deptName query string false "操作记录名称"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
- // @Router /api/operation-log [get]
- // @Security Bearer
- func (e FillDataController) UserList(c *gin.Context) {
- s := service.FillData{}
- err := e.MakeContext(c).
- MakeOrm().
- 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.FillDataDistinctUser, 0)
- var count int64
- err = s.GetUserList(&list, &count, p)
- if err != nil {
- e.Error(500, err, err.Error())
- return
- }
- e.PageOK(list, int(count), 0, 0, "查询成功")
- }
|