12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package manage
- import (
- "Cold_Logistic/internal/pkg/common/codex"
- "Cold_Logistic/internal/pkg/common/global"
- "Cold_Logistic/internal/server/application/commonsrv"
- "Cold_Logistic/internal/server/application/devicesrv"
- "Cold_Logistic/internal/server/infra/dao"
- "github.com/gin-gonic/gin"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
- )
- // userList
- // @Tags 后台-公共接口
- // @Summary 用户列表
- // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
- // @Param req body swagger.UserListReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/common/userList [post]
- func (api Api) userList(c *gin.Context) {
- req := commonsrv.UserListReqVO{}
- if err := c.BindJSON(&req); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
- return
- }
- srv := commonsrv.NewCommonService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.UserList(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // deviceSensorList
- // @Tags 后台-公共接口
- // @Summary 设备探头列表
- // @Success 200 {object} devicesrv.DeviceSensorListRespVO "成功响应的结构体"
- // @Param req body devicesrv.DeviceSensorListReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/common/deviceSensorList [post]
- func (api Api) deviceSensorList(c *gin.Context) {
- req := devicesrv.DeviceSensorListReqVO{}
- if err := c.BindJSON(&req); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
- return
- }
- if err := req.Validate(); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
- return
- }
- srv := devicesrv.NewDeviceService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.DeviceSensorList(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // snDataList
- // @Tags 后台-公共接口
- // @Summary 设备数据列表
- // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
- // @Param req body swagger.SnDataListReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/common/sensorDataList [post]
- func (api Api) snDataList(c *gin.Context) {
- req := devicesrv.SnDataListReqVO{}
- if err := c.BindJSON(&req); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
- return
- }
- if err := req.Validate(); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrParamValidate, "参数验证失败:"))
- return
- }
- srv := devicesrv.NewDeviceService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.SnDataList(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
|