123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package manage
- import (
- "Cold_Logistic/internal/pkg/common/codex"
- "Cold_Logistic/internal/pkg/common/global"
- "Cold_Logistic/internal/server/application/carsrv"
- "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"
- )
- // carPage
- // @Tags 后台-车辆管理
- // @Summary 车辆列表
- // @Success 200 {object} swagger.PageListResponse "成功响应的结构体"
- // @Param req body swagger.CarPageReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/car/page [post]
- func (api Api) carPage(c *gin.Context) {
- req := carsrv.CarPageReqVO{}
- if err := c.BindJSON(&req); err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrBindJSON, ""))
- return
- }
- srv := carsrv.NewCarService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.CarPage(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // addCar
- // @Tags 后台-车辆管理
- // @Summary 添加车辆
- // @Success 200 {object} carsrv.CarIdRespVO "成功响应的结构体"
- // @Param req body carsrv.AddCarReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/car/add [post]
- func (api Api) addCar(c *gin.Context) {
- req := carsrv.AddCarReqVO{}
- 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 := carsrv.NewCarService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.AddCar(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // updateCar
- // @Tags 后台-车辆管理
- // @Summary 修改车辆
- // @Success 200 {object} carsrv.CarIdRespVO "成功响应的结构体"
- // @Param req body carsrv.UpdateCarReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/car/update [post]
- func (api Api) updateCar(c *gin.Context) {
- req := carsrv.UpdateCarReqVO{}
- 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 := carsrv.NewCarService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.UpdateCar(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrSaveFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
- // updateCar
- // @Tags 后台-车辆管理
- // @Summary 车辆既往司机
- // @Success 200 {object} swagger.ListResponse "成功响应的结构体"
- // @Param req body carsrv.DriverLogReqVO true "请求参数"
- // @Accept application/json
- // @Router /manage/car/driverLog [post]
- func (api Api) driverLog(c *gin.Context) {
- req := carsrv.DriverLogReqVO{}
- 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 := carsrv.NewCarService(dao.NewDataStore(global.CommonConnectRepoInst.StoreDB))
- res, err := srv.DriverLog(c, req)
- if err != nil {
- core.WriteErrResponse(c, errors.WithCodeOnce(err, codex.ErrQueryFailed, ""))
- return
- }
- core.WriteResponse(c, nil, res)
- }
|