package crm import ( "github.com/gin-gonic/gin" "server/dao/crm" "server/global" "server/model/common/response" "strconv" ) type CustomerGenreApi struct{} func (cga *CustomerGenreApi) QueryAllCustomerGenres(c *gin.Context) { genres, err := customerGenreService.QueryAllCustomerGenres() if err != nil { response.FailWithMessage("查询失败", c) global.GVA_LOG.Error("QueryAllCustomerGenres ======= " + err.Error()) return } response.OkWithData(genres, c) } func (cga *CustomerGenreApi) CreateCustomerGenre(c *gin.Context) { var customerGenre crm.CustomerGenre err := c.ShouldBindJSON(&customerGenre) if err != nil { response.FailWithMessage("参数解析失败", c) global.GVA_LOG.Error("CreateCustomerGenre ======= " + err.Error()) return } err = customerGenreService.CreateCustomerGenre(customerGenre) if err != nil { response.FailWithMessage("创建失败", c) global.GVA_LOG.Error("CreateCustomerGenre ======= " + err.Error()) return } response.OkWithMessage("创建成功", c) } func (cga *CustomerGenreApi) UpdateCustomerGenre(c *gin.Context) { var customerGenre crm.CustomerGenre err := c.ShouldBindJSON(&customerGenre) if err != nil { response.FailWithMessage("参数解析失败", c) global.GVA_LOG.Error("UpdateCustomerGenre ======= " + err.Error()) return } err = customerGenreService.UpdateCustomerGenre(customerGenre) if err != nil { response.FailWithMessage("更新失败", c) global.GVA_LOG.Error("UpdateCustomerGenre ======= " + err.Error()) return } response.OkWithMessage("更新成功", c) } func (cga *CustomerGenreApi) DeleteCustomerGenre(c *gin.Context) { id := c.Query("id") idInt, _ := strconv.Atoi(id) err := customerGenreService.DeleteCustomerGenre(idInt) if err != nil { response.FailWithMessage("删除失败", c) global.GVA_LOG.Error("DeleteCustomerGenre ======= " + err.Error()) return } response.OkWithMessage("删除成功", c) }