123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- package v1_0
- import (
- "adm-gateway/errors"
- param_v1 "adm-gateway/param/v1"
- "adm-gateway/pb"
- v1 "adm-gateway/pb/v1"
- "net/http"
- "github.com/gin-gonic/gin"
- "git.getensh.com/common/gopkgsv2/logger"
- "git.getensh.com/common/gopkgsv2/tasker/httptasker"
- "git.getensh.com/common/gopkgsv2/util"
- "go.uber.org/zap"
- )
- // 信息公告
- // AnnouncementList godoc
- // @Summary 信息公告
- // @Description 信息公告
- // @Tags announcement,v1.0
- // @Accept json
- // @Produce json
- // @Param token header string true "jwt token"
- // @Param vin_rule query string false "vin"
- // @Param brand_name query string false "品牌"
- // @Param model_no query string false "车辆型号"
- // @Param page query int32 false "页码"
- // @Param page_size query int32 false "每页数量,默认10"
- // @Success 200 {object} param_v1.GetAnnouncementResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1.0/announcement [get]
- func (c *Controller) AnnouncementList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.GetAnnouncementRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, nil, nil, &req.GetAnnouncementQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- // 响应数据
- resp := ¶m_v1.GetAnnouncementResponse{}
- r := v1.AnnouncementRequest{
- VinRule: req.VinRule,
- BrandName: req.BrandName,
- ModelNo: req.ModelNo,
- Page: req.Page,
- PageSize: req.PageSize,
- }
- reply, err := pb.Management.AnnouncementList(ctx.Request.Context(), &r)
- if err != nil {
- s, _ := json.MarshalToString(r)
- logger.Error("func",
- zap.String("call", "pb.management.AnnouncementList"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if reply.List == nil {
- reply.List = make([]*v1.AnnouncementList, 0)
- }
- resp.Data = reply
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
- // 编辑
- // EditList godoc
- // @Summary 编辑
- // @Description 编辑
- // @Tags announcement,v1.0
- // @Accept json
- // @Produce json
- // @Param token header string true "jwt token"
- // @Param vehicle_batch query string false "vehicle_batch"
- // @Param model_no query string false "model_no"
- // @Success 200 {object} param_v1.GetEditResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1.0/announcement/edit [get]
- func (c *Controller) EditList(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.GetEditRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, nil, nil, &req.GetEditQuery, nil)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- // 响应数据
- resp := ¶m_v1.GetEditResponse{}
- r := v1.EditRequest{
- VehicleBatch: req.VehicleBatch,
- ModelNo: req.ModelNo,
- }
- reply, err := pb.Management.Edit(ctx.Request.Context(), &r)
- if err != nil {
- s, _ := json.MarshalToString(r)
- logger.Error("func",
- zap.String("call", "pb.management.Edit"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- if reply.List == nil {
- reply.List = make([]*v1.EditList, 0)
- }
- resp.Data = reply
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
|