59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package controller
|
|
|
|
import (
|
|
"context"
|
|
|
|
"video-factory/shortdrama/model/dto"
|
|
"video-factory/shortdrama/model/entity"
|
|
"video-factory/shortdrama/service"
|
|
)
|
|
|
|
type regionPricing struct{}
|
|
|
|
var RegionPricing = new(regionPricing)
|
|
|
|
func (c *regionPricing) List(ctx context.Context, req *dto.ListRegionPricingReq) (res *dto.ListRegionPricingRes, err error) {
|
|
if req.Page <= 0 {
|
|
req.Page = 1
|
|
}
|
|
if req.PageSize <= 0 {
|
|
req.PageSize = 20
|
|
}
|
|
list, total, err := service.RegionPricingService.GetListPage(ctx, req.Page, req.PageSize, req.Keyword, req.Protected)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.ListRegionPricingRes{List: list, Total: total}, nil
|
|
}
|
|
|
|
func (c *regionPricing) Save(ctx context.Context, req *dto.SaveRegionPricingReq) (res *struct{}, err error) {
|
|
return nil, service.RegionPricingService.Save(ctx, &entity.RegionPricing{
|
|
Id: req.Id,
|
|
Province: req.Province,
|
|
Region: req.Region,
|
|
Protected: req.Protected,
|
|
Price: req.Price,
|
|
MaxCustomers: req.MaxCustomers,
|
|
})
|
|
}
|
|
|
|
func (c *regionPricing) Cascades(ctx context.Context, req *struct{}) (res *dto.ListRegionCascadesRes, err error) {
|
|
list, err := service.RegionPricingService.GetCascades(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.ListRegionCascadesRes{List: list}, nil
|
|
}
|
|
|
|
func (c *regionPricing) Delete(ctx context.Context, req *struct{ Id int64 }) (res *struct{}, err error) {
|
|
return nil, service.RegionPricingService.Delete(ctx, req.Id)
|
|
}
|
|
|
|
func (c *regionPricing) Regions(ctx context.Context, req *struct{}) (res *dto.ListRegionsRes, err error) {
|
|
regions, err := service.RegionPricingService.GetRegions(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &dto.ListRegionsRes{Regions: regions}, nil
|
|
}
|