| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package vehicle
- import (
- "github.com/gin-gonic/gin"
- "server/dao"
- "server/model/common/request"
- "server/model/common/response"
- "strconv"
- )
- type ShortlistApi struct{}
- func (sa *ShortlistApi) QueryAllShortlists(c *gin.Context) {
- shortlists, err := shortlistService.QueryAllShortlists()
- if err != nil {
- response.FailWithMessage("查询失败", c)
- return
- }
- response.OkWithData(shortlists, c)
- }
- func (sa *ShortlistApi) QueryShortlistList(c *gin.Context) {
- var info request.PageInfo
- err := c.ShouldBindJSON(&info)
- if err != nil {
- response.FailWithMessage("参数错误", c)
- return
- }
- list, total, err := shortlistService.QueryShortlistList(info)
- if err != nil {
- response.FailWithMessage("查询失败", c)
- return
- }
- response.OkWithDetailed(response.PageResult{
- List: list,
- Total: total,
- Page: info.Page,
- PageSize: info.PageSize,
- }, "获取成功", c)
- }
- func (sa *ShortlistApi) CreateShortlist(c *gin.Context) {
- var shortlist dao.Shortlist
- err := c.ShouldBindJSON(&shortlist)
- if err != nil {
- response.FailWithMessage("参数错误", c)
- return
- }
- err = shortlistService.CreateShortlist(shortlist)
- if err != nil {
- response.FailWithMessage("新增失败", c)
- return
- }
- response.OkWithMessage("新增成功", c)
- }
- func (sa *ShortlistApi) UpdateShortlist(c *gin.Context) {
- var shortlist dao.Shortlist
- err := c.ShouldBindJSON(&shortlist)
- if err != nil {
- response.FailWithMessage("参数错误", c)
- return
- }
- err = shortlistService.UpdateShortlist(shortlist)
- if err != nil {
- response.FailWithMessage("修改失败", c)
- return
- }
- response.OkWithMessage("修改成功", c)
- }
- func (sa *ShortlistApi) DeleteShortlist(c *gin.Context) {
- id, err := strconv.Atoi(c.Param("id"))
- if err != nil {
- response.FailWithMessage("参数错误", c)
- return
- }
- err = shortlistService.DeleteShortlist(id)
- if err != nil {
- response.FailWithMessage("删除失败", c)
- return
- }
- response.OkWithMessage("删除成功", c)
- }
|