123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- package controller
- import (
- "github.com/gin-gonic/gin"
- "github.com/sirupsen/logrus"
- "youngee_b_api/app/service"
- "youngee_b_api/app/vo"
- )
- type TaskController struct{}
- type GetAllProductParam struct {
- EnterpriseId string `json:"enterprise_id"`
- }
- type SelectionDetailParam struct {
- EnterpriseId string `json:"enterprise_id"`
- SelectionId string `json:"selection_id"`
- }
- // 关联商品-已有商品展示
- func (t TaskController) GetAllProduct(c *gin.Context) {
- search := &GetAllProductParam{}
- err := c.BindJSON(&search)
- if err != nil {
- logrus.Errorf("Request bind err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- result, err := service.ProductService{}.GetTaskProducts(search.EnterpriseId)
- if err != nil {
- returnError(c, 40000, "error")
- return
- }
- returnSuccess(c, 20000, result)
- return
- }
- // 关联商品-新建商品
- func (t TaskController) CreateProduct(c *gin.Context) {
- data := &vo.ProductCreateParam{}
- err := c.BindJSON(data)
- if err != nil {
- logrus.Errorf("Request bind err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- productId, err := service.ProductService{}.CreateProduct(data)
- returnSuccess(c, 20000, productId)
- }
- // 关联商品-完成关联创建带货任务
- func (t TaskController) CreateSelection(c *gin.Context) {
- data := &vo.SelectionInfoCreateParam{}
- err := c.BindJSON(data)
- if err != nil {
- logrus.Errorf("Request bind err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- selectionId, err := service.SelectionInfoService{}.CreateSelectionInfo(data)
- if err != nil {
- logrus.Errorf("[CreateSelection] call CreateSelection err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- returnSuccess(c, 20000, *selectionId)
- }
- // 更新带货任务(样品奖励、补充信息)
- func (t TaskController) UpdateSelection(c *gin.Context) {
- data := &vo.SelectionInfoUpdateParam{}
- err := c.BindJSON(data)
- if err != nil {
- logrus.Errorf("Request bind err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- selectionId, err := service.SelectionInfoService{}.UpdateSelectionInfo(data)
- if err != nil {
- logrus.Errorf("[UpdateSelection] call UpdateSelection err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- returnSuccess(c, 20000, *selectionId)
- }
- // 电商带货任务预览
- func (t TaskController) GetSelectionDetail(c *gin.Context) {
- data := &SelectionDetailParam{}
- err := c.BindJSON(data)
- if err != nil {
- logrus.Errorf("Request bind err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- res, err := service.SelectionInfoService{}.GetSelectionDetail(data.SelectionId, data.EnterpriseId)
- if err != nil {
- logrus.Errorf("[GetSelectionDetail] call Show err:%+v\n", err)
- returnError(c, 40000, "error")
- return
- }
- returnSuccess(c, 20000, res)
- }
|