package im

import (
	"applet/app/e"
	md "applet/app/md/im"
	svc "applet/app/svc/im"
	"github.com/gin-gonic/gin"
)

// PageCustomerService
// @Summary      Im-客服(列表)
// @Tags         客服
// @Description  客服(列表)
// @Accept       json
// @Produce      json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @param req body  md.PageCustomerServiceReq true "相关参数"
// @Success      200   {object}  	md.GetBasicResp "设置列表"
// @Failure      400   {object}   md.Response              	"具体错误"
// @Router       /api/im/pageCustomerService [POST]
func PageCustomerService(c *gin.Context) {
	var req *md.PageCustomerServiceReq
	if err1 := c.ShouldBindJSON(&req); err1 != nil {
		e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
		return
	}
	err, resp := svc.PageCustomerService(*req)
	if err != nil {
		e.OutErr(c, e.ERR, err.Error())
		return
	}
	e.OutSuc(c, resp, nil)
}

// AddCustomerService
// @Summary      Im-客服(新增)
// @Tags         客服
// @Description  客服(新增)
// @Accept       json
// @Produce      json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @param req body  md.AddCustomerServiceReq true "相关参数"
// @Success      200   {string}  	 "success"
// @Failure      400   {object}   md.Response              	"具体错误"
// @Router       /api/im/addCustomerService [post]
func AddCustomerService(c *gin.Context) {
	var req *md.AddCustomerServiceReq
	if err1 := c.ShouldBindJSON(&req); err1 != nil {
		e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
		return
	}

	err := svc.AddCustomerService(*req)
	if err != nil {
		e.OutErr(c, e.ERR, err.Error())
		return
	}
	e.OutSuc(c, "success", nil)
}

// SetCustomerServiceState
// @Summary      Im-客服(更新状态)
// @Tags         客服
// @Description  客服(更新状态)
// @Accept       json
// @Produce      json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @param req body  md.SetCustomerServiceStateReq true "相关参数"
// @Success      200   {string}  	 "success"
// @Failure      400   {object}   md.Response              	"具体错误"
// @Router       /api/im/setCustomerServiceState [post]
func SetCustomerServiceState(c *gin.Context) {
	var req *md.SetCustomerServiceStateReq
	if err1 := c.ShouldBindJSON(&req); err1 != nil {
		e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
		return
	}

	err := svc.SetCustomerServiceState(*req)
	if err != nil {
		e.OutErr(c, e.ERR, err.Error())
		return
	}
	e.OutSuc(c, "success", nil)
}

// UpdateCustomerServiceMemo
// @Summary      Im-客服(编辑备注)
// @Tags         客服
// @Description  客服(编辑备注)
// @Accept       json
// @Produce      json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @param req body  md.UpdateCustomerServiceMemoReq true "相关参数"
// @Success      200   {string}  	 "success"
// @Failure      400   {object}   md.Response              	"具体错误"
// @Router       /api/im/updateCustomerServiceMemo [post]
func UpdateCustomerServiceMemo(c *gin.Context) {
	var req *md.UpdateCustomerServiceMemoReq
	if err1 := c.ShouldBindJSON(&req); err1 != nil {
		e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
		return
	}

	err := svc.UpdateCustomerServiceMemo(*req)
	if err != nil {
		e.OutErr(c, e.ERR, err.Error())
		return
	}
	e.OutSuc(c, "success", nil)
}