package v1
|
|
import (
|
"aps_crm/model"
|
"aps_crm/model/request"
|
"aps_crm/model/response"
|
"aps_crm/pkg/contextx"
|
"aps_crm/pkg/ecode"
|
"github.com/gin-gonic/gin"
|
"strconv"
|
)
|
|
type SatisfactionApi struct{}
|
|
// Add
|
//
|
// @Tags Satisfaction
|
// @Summary 添加满意度
|
// @Produce application/json
|
// @Param object body request.AddSatisfaction true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/satisfaction/add [post]
|
func (s *SatisfactionApi) Add(c *gin.Context) {
|
var params request.AddSatisfaction
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
satisfaction := new(model.Satisfaction)
|
satisfaction.Name = params.Name
|
|
errCode := satisfactionService.AddSatisfaction(satisfaction)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Delete
|
//
|
// @Tags Satisfaction
|
// @Summary 删除满意度
|
// @Produce application/json
|
// @Param id path int true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/satisfaction/delete/{id} [delete]
|
func (s *SatisfactionApi) Delete(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
id, _ := strconv.Atoi(c.Param("id"))
|
errCode := satisfactionService.DeleteSatisfaction(id)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// Update
|
//
|
// @Tags Satisfaction
|
// @Summary 更新满意度
|
// @Produce application/json
|
// @Param object body request.UpdateSatisfactions true "查询参数"
|
// @Success 200 {object} contextx.Response{}
|
// @Router /api/satisfaction/update [put]
|
func (s *SatisfactionApi) Update(c *gin.Context) {
|
var params request.UpdateSatisfactions
|
ctx, ok := contextx.NewContext(c, ¶ms)
|
if !ok {
|
return
|
}
|
|
errCode := satisfactionService.UpdateSatisfaction(params.Satisfactions)
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.Ok()
|
}
|
|
// List
|
//
|
// @Tags Satisfaction
|
// @Summary 满意度列表
|
// @Produce application/json
|
// @Success 200 {object} contextx.Response{data=response.SatisfactionResponse}
|
// @Router /api/satisfaction/list [get]
|
func (s *SatisfactionApi) List(c *gin.Context) {
|
ctx, ok := contextx.NewContext(c, nil)
|
if !ok {
|
return
|
}
|
|
satisfactions, errCode := satisfactionService.GetSatisfactionList()
|
if errCode != ecode.OK {
|
ctx.Fail(errCode)
|
return
|
}
|
|
ctx.OkWithDetailed(response.SatisfactionResponse{
|
List: satisfactions,
|
})
|
}
|