| | |
| | | |
| | | package v1 |
| | | |
| | | import ( |
| | | "aps_crm/model" |
| | | "aps_crm/model/request" |
| | | "aps_crm/model/response" |
| | | "aps_crm/pkg/contextx" |
| | | "aps_crm/pkg/ecode" |
| | | "aps_crm/service" |
| | | "github.com/gin-gonic/gin" |
| | | "strconv" |
| | | ) |
| | |
| | | type ServiceContractStatusApi struct{} |
| | | |
| | | // Add |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 添加服务合同状态 |
| | | // @Produce application/json |
| | | // @Param object body request.AddServiceContractStatus true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/add [post] |
| | | // @Tags 合同状态 |
| | | // @Summary 添加合同状态 |
| | | // @Produce application/json |
| | | // @Param object body request.AddServiceContractStatus true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/add [post] |
| | | func (s *ServiceContractStatusApi) Add(c *gin.Context) { |
| | | var params request.AddServiceContractStatus |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | |
| | | return |
| | | } |
| | | |
| | | serviceContractStatus := new(model.ServiceContractStatus) |
| | | serviceContractStatus.Name = params.Name |
| | | |
| | | errCode := serviceContractStatusService.AddServiceContractStatus(serviceContractStatus) |
| | | errCode := service.NewServiceContractStatusService().AddServiceContractStatus(¶ms.ServiceContractStatus) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | } |
| | | |
| | | // Delete |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 删除服务合同状态 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/delete/{id} [delete] |
| | | // @Tags 合同状态 |
| | | // @Summary 删除合同状态 |
| | | // @Produce application/json |
| | | // @Param id path int true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/delete/{id} [delete] |
| | | func (s *ServiceContractStatusApi) Delete(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | |
| | | } |
| | | |
| | | id, _ := strconv.Atoi(c.Param("id")) |
| | | errCode := serviceContractStatusService.DeleteServiceContractStatus(id) |
| | | errCode := service.NewServiceContractStatusService().DeleteServiceContractStatus(id) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | } |
| | | |
| | | // Update |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 更新服务合同状态 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateServiceContractStatuss true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/update [put] |
| | | // @Tags 合同状态 |
| | | // @Summary 更新合同状态 |
| | | // @Produce application/json |
| | | // @Param object body request.UpdateServiceContractStatus true "查询参数" |
| | | // @Success 200 {object} contextx.Response{} |
| | | // @Router /api/serviceContractStatus/update [put] |
| | | func (s *ServiceContractStatusApi) Update(c *gin.Context) { |
| | | var params request.UpdateServiceContractStatuss |
| | | var params request.UpdateServiceContractStatus |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | if params.Id == 0 { |
| | | ctx.Fail(ecode.ParamsErr) |
| | | } |
| | | params.ServiceContractStatus.Id = params.Id |
| | | |
| | | errCode := serviceContractStatusService.UpdateServiceContractStatus(params.ServiceContractStatuss) |
| | | errCode := service.NewServiceContractStatusService().UpdateServiceContractStatus(¶ms.ServiceContractStatus) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags ServiceContractStatus |
| | | // @Summary 获取服务合同状态列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.ServiceContractStatusResponse} |
| | | // @Router /api/serviceContractStatus/list [get] |
| | | // @Tags 合同状态 |
| | | // @Summary 获取合同状态列表 |
| | | // @Produce application/json |
| | | // @Param object query request.GetServiceContractStatusList true "参数" |
| | | // @Success 200 {object} response.ListResponse{data=[]model.ServiceContractStatus} |
| | | // @Router /api/serviceContractStatus/list [get] |
| | | func (s *ServiceContractStatusApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | var params request.GetServiceContractStatusList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | serviceContractStatuss, errCode := serviceContractStatusService.GetServiceContractStatusList() |
| | | serviceContractStatus, total, errCode := service.NewServiceContractStatusService().GetServiceContractStatusList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.ServiceContractStatusResponse{ |
| | | List: serviceContractStatuss, |
| | | ctx.OkWithDetailed(response.ListResponse{ |
| | | Data: serviceContractStatus, |
| | | Count: total, |
| | | }) |
| | | } |