// ========================================================================== // GFast自动生成controller操作代码。 // 生成日期:2025-08-08 11:21:24 // 生成路径: internal/app/businesses/controller/geography.go // 生成人:gfast // desc:地理分布 // company:云南奇讯科技有限公司 // ========================================================================== package controller import ( "context" "github.com/gogf/gf/v2/frame/g" "github.com/tiger1103/gfast/v3/api/v1/businesses" "github.com/tiger1103/gfast/v3/internal/app/businesses/common" "github.com/tiger1103/gfast/v3/internal/app/businesses/dao" "github.com/tiger1103/gfast/v3/internal/app/businesses/service" "github.com/tiger1103/gfast/v3/internal/app/lock" systemController "github.com/tiger1103/gfast/v3/internal/app/system/controller" ) type geographyController struct { systemController.BaseController } var Geography = new(geographyController) // List 列表 func (c *geographyController) List(ctx context.Context, req *businesses.GeographySearchReq) (res *businesses.GeographySearchRes, err error) { res = new(businesses.GeographySearchRes) res.GeographySearchRes, err = service.Geography().List(ctx, &req.GeographySearchReq) return } // Get 获取地理分布 func (c *geographyController) Get(ctx context.Context, req *businesses.GeographyGetReq) (res *businesses.GeographyGetRes, err error) { res = new(businesses.GeographyGetRes) res.GeographyInfoRes, err = service.Geography().GetById(ctx, req.Id) return } // Add 添加地理分布 func (c *geographyController) Add(ctx context.Context, req *businesses.GeographyAddReq) (res *businesses.GeographyAddRes, err error) { err = service.Geography().Add(ctx, req.GeographyAddReq) return } // Edit 修改地理分布 func (c *geographyController) Edit(ctx context.Context, req *businesses.GeographyEditReq) (res *businesses.GeographyEditRes, err error) { newVersion, err := lock.TryOptimisticLock(ctx, dao.Geography.Ctx(ctx), "id", req.Id, req.Version) if err != nil { return nil, err } req.Version = newVersion err = service.Geography().Edit(ctx, req.GeographyEditReq) return } // Delete 删除地理分布 func (c *geographyController) Delete(ctx context.Context, req *businesses.GeographyDeleteReq) (res *businesses.GeographyDeleteRes, err error) { for i, id := range req.Ids { _, err = lock.TryOptimisticLock(ctx, dao.Geography.Ctx(ctx), "id", id, req.Version[i]) if err != nil { return nil, err } } err = service.Geography().Delete(ctx, req.Ids) return } func (c *geographyController) Audit(ctx context.Context, req *common.AuditReq) (res *g.Map, err error) { err = common.Audit.Audit(ctx, dao.Geography.Ctx(ctx), req, func(ctx context.Context, req *common.AuditReq) error { return common.Audit.SaveAudit(dao.Geography.Ctx(ctx), req) }) if err != nil { return nil, err } return &g.Map{ "msg": "审核成功", "newVersion": req.Version, }, nil }