123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- 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"
- _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
- )
- type RealFillDataController struct {
- api.Api
- }
- // GetPage 获取上报实时充装数据
- // @Summary 获取上报实时充装数据
- // @Description 获取上报实时充装数据
- // @Tags 上报实时充装数据
- // @Param gunCode query string false "充装枪编码"
- // @Param pageSize query int false "页条数"
- // @Param page query int false "页码"
- // @Success 200 {object} response.Response{data=response.Page{list=[]model.RealFillData}} "{"code": 200, "data": [...]}"
- // @Router /api/goods [get]
- // @Security Bearer
- func (e RealFillDataController) GetPage(c *gin.Context) {
- s := service.RealFillData{}
- req := dto.RealFillDataGetPageReq{}
- 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.RealFillData, 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.RealFillDataInsertReq true "data"
- // @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
- // @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
- // @Router /api/goods [post]
- // @Security Bearer
- func (e RealFillDataController) Insert(c *gin.Context) {
- s := service.RealFillData{}
- fillGunSvc := service.FillGun{}
- req := dto.RealFillDataInsertReq{}
- 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(), "创建成功")
- }
|