From f355453f545bc088eeeadd7ce915f03d1bdd272a Mon Sep 17 00:00:00 2001 From: weizhihong Date: Tue, 21 Nov 2023 13:33:41 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/projectLink.go | 57 --- api/trainManage.go | 188 ---------- db/dbquery/gen.go | 48 --- db/dbquery/project_train_size.gen.go | 388 -------------------- db/dbquery/project_train_size_link.gen.go | 388 -------------------- db/dbquery/published_gi.gen.go | 412 ---------------------- db/dbquery/train_model.gen.go | 392 -------------------- db/dbquery/train_sensor.gen.go | 396 --------------------- db/dbquery/train_size.gen.go | 396 --------------------- db/dbquery/train_wheel.gen.go | 392 -------------------- db/model/project_train_size.gen.go | 19 - db/model/project_train_size_link.gen.go | 19 - db/model/published_gi.gen.go | 29 -- db/model/train_model.gen.go | 24 -- db/model/train_sensor.gen.go | 24 -- db/model/train_size.gen.go | 21 -- db/model/train_wheel.gen.go | 20 -- dto/projectLink.go | 6 - dto/publishedGi/publishedGi.go | 66 ---- dto/trainManage.go | 44 --- service/projectLink.go | 35 -- service/publishedGi.go | 2 +- service/trainManage.go | 284 --------------- 23 files changed, 1 insertion(+), 3649 deletions(-) delete mode 100644 db/dbquery/project_train_size.gen.go delete mode 100644 db/dbquery/project_train_size_link.gen.go delete mode 100644 db/dbquery/published_gi.gen.go delete mode 100644 db/dbquery/train_model.gen.go delete mode 100644 db/dbquery/train_sensor.gen.go delete mode 100644 db/dbquery/train_size.gen.go delete mode 100644 db/dbquery/train_wheel.gen.go delete mode 100644 db/model/project_train_size.gen.go delete mode 100644 db/model/project_train_size_link.gen.go delete mode 100644 db/model/published_gi.gen.go delete mode 100644 db/model/train_model.gen.go delete mode 100644 db/model/train_sensor.gen.go delete mode 100644 db/model/train_size.gen.go delete mode 100644 db/model/train_wheel.gen.go delete mode 100644 dto/publishedGi/publishedGi.go diff --git a/api/projectLink.go b/api/projectLink.go index ea40021..db5a8a6 100644 --- a/api/projectLink.go +++ b/api/projectLink.go @@ -17,9 +17,6 @@ func InitProjectLinkRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl authed := api.Group("/v1/projectLink").Use(authMiddleware.MiddlewareFunc(), middleware.PermissMiddleware) authed.GET("/info/:id", queryProjectLinkInfo) authed.POST("", saveProjectLinkInfo) - // TODO: 前端修改完成后删除 - authed.GET("/mapInfo/trainSize/:id", queryTrainSizeByMapId) - authed.GET("/project/trainSize/:id", queryTrainSizeByPId) } // 查询项目的所有关联信息 @@ -72,57 +69,3 @@ func saveProjectLinkInfo(c *gin.Context) { service.UpdateProjectLink(&req) c.JSON(http.StatusOK, true) } - -// TODO:前端修改完成后删除 -// 通过项目ID查询项目的关联列车尺寸信息 -// -// @Summary 通过项目ID查询项目的关联列车尺寸信息 -// -// @Security JwtAuth -// -// @Description 通过项目ID查询项目的关联列车尺寸信息 -// @Tags 项目关联信息Api -// @Accept json -// @Produce json -// @Param id path int true "地图ID" -// @Success 200 {object} dto.TrainSizeDto -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/projectLink/project/trainSize/{id} [get] -func queryTrainSizeByMapId(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("查询失败,缺少id")) - } - slog.Debug("传入参数id为" + id) - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.QueryTrainSizeByMapId(int32(int64Id))) -} - -// 通过地图ID查询项目的关联列车尺寸信息 -// -// @Summary 通过地图ID查询项目的关联列车尺寸信息 -// -// @Security JwtAuth -// -// @Description 通过地图ID查询项目的关联列车尺寸信息 -// @Tags 项目关联信息Api -// @Accept json -// @Produce json -// @Param id path int true "地图ID" -// @Success 200 {object} dto.TrainSizeDto -// @Failure 401 {object} dto.ErrorDto -// @Failure 404 {object} dto.ErrorDto -// @Failure 500 {object} dto.ErrorDto -// @Router /api/v1/projectLink/mapInfo/trainSize/{id} [get] -func queryTrainSizeByPId(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("查询失败,缺少id")) - } - slog.Debug("传入参数id为" + id) - int64Id, _ := strconv.ParseInt(id, 10, 64) - trainSizeArr := service.QueryProjectTrainSize(int32(int64Id)) - c.JSON(http.StatusOK, dto.ConvertFromTrainSizeDto(trainSizeArr)) -} diff --git a/api/trainManage.go b/api/trainManage.go index 1920719..1f5d0cd 100644 --- a/api/trainManage.go +++ b/api/trainManage.go @@ -21,25 +21,6 @@ func InitTrainManageRouter(api *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddl authed.GET("/:id", queryTrainInfo) authed.PUT("/:id", updateTrainInfo) authed.DELETE("/:id", deleteTrainInfo) - - authed.GET("/model/paging", pageQueryTrainModel) - authed.GET("/model/list", queryTrainModelList) - authed.POST("/model", createTrainModel) - authed.GET("/model/:id", queryTrainModel) - authed.PUT("/model/:id", updateTrainModel) - authed.DELETE("/model/:id", deleteTrainModel) - authed.GET("/size/paging", pageQueryTrainSize) - authed.GET("/size/list", queryTrainSizeList) - authed.POST("/size", createTrainSize) - authed.GET("/size/:id", queryTrainSize) - authed.PUT("/size/:id", updateTrainSize) - authed.DELETE("/size/:id", deleteTrainSize) - authed.GET("/wheelDiameter/paging", pageQueryTrainWheelDiameter) - authed.GET("/wheelDiameter/list", queryTrainWheelDiameterList) - authed.POST("/wheelDiameter", createTrainWheelDiameter) - authed.GET("/wheelDiameter/:id", queryTrainWheelDiameter) - authed.PUT("/wheelDiameter/:id", updateTrainWheelDiameter) - authed.DELETE("/wheelDiameter/:id", deleteTrainWheelDiameter) } // 分页查询列车列表 @@ -195,172 +176,3 @@ func deleteTrainInfo(c *gin.Context) { service.DeleteTrainInfoById(id) c.JSON(http.StatusOK, true) } - -// TODO: 前端修改完毕后以下代码全部作废 -func pageQueryTrainModel(c *gin.Context) { - req := dto.PageTrainManageReqDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.PageTrainModelQuery(&req)) -} - -func createTrainModel(c *gin.Context) { - req := dto.TrainModelDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("保存失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.CreateTrainModel(&req)) -} - -func queryTrainModel(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("查询失败,缺少主键")) - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.QueryTrainModel(int32(int64Id))) -} - -func updateTrainModel(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("更新失败,缺少主键")) - } - req := dto.TrainModelDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("更新失败,参数格式错误", err)) - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.UpdateTrainModel(int32(int64Id), &req)) -} - -func deleteTrainModel(c *gin.Context) { - idStr := c.Param("id") - id, err := strconv.Atoi(idStr) - if err != nil { - panic(sys_error.New("删除失败,缺少主键")) - } - service.DeleteTrainModelById(id) - c.JSON(http.StatusOK, true) -} - -func queryTrainModelList(c *gin.Context) { - req := dto.TrainManageReqDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.ListTrainModelQuery(&req)) -} - -func pageQueryTrainSize(c *gin.Context) { - req := dto.PageTrainManageReqDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.PageTrainSizeQuery(&req)) -} - -func queryTrainSizeList(c *gin.Context) { - req := dto.TrainManageReqDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.ListTrainSizeQuery(&req)) -} - -func createTrainSize(c *gin.Context) { - req := dto.TrainSizeDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("创建失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.CreateTrainSize(&req)) -} - -func queryTrainSize(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("查询失败,缺少查询主键")) - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.QueryTrainSize(int32(int64Id))) -} - -func updateTrainSize(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("更新失败,缺少查询主键")) - } - req := dto.TrainSizeDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("更新失败,参数格式错误", err)) - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.UpdateTrainSize(int32(int64Id), &req)) -} - -func deleteTrainSize(c *gin.Context) { - idStr := c.Param("id") - id, err := strconv.Atoi(idStr) - if err != nil { - panic(sys_error.New("删除失败,主键格式错误", err)) - } - service.DeleteTrainSizeById(id) - c.JSON(http.StatusOK, true) -} - -func pageQueryTrainWheelDiameter(c *gin.Context) { - req := dto.PageTrainManageReqDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.PageTrainWheelDiameterQuery(&req)) -} - -func queryTrainWheelDiameterList(c *gin.Context) { - req := dto.TrainManageReqDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.ListTrainWheelDiameterQuery(&req)) -} - -func createTrainWheelDiameter(c *gin.Context) { - req := dto.TrainWheelDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("创建失败,参数格式错误", err)) - } - c.JSON(http.StatusOK, service.CreateTrainWheelDiameter(&req)) -} - -func queryTrainWheelDiameter(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("查询失败,缺少查询主键")) - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.QueryTrainWheelDiameter(int32(int64Id))) -} - -func updateTrainWheelDiameter(c *gin.Context) { - id, exist := c.Params.Get("id") - if !exist { - panic(sys_error.New("更新失败,缺少查询主键")) - } - req := dto.TrainWheelDto{} - if err := c.ShouldBind(&req); err != nil { - panic(sys_error.New("查询失败,参数格式错误", err)) - } - int64Id, _ := strconv.ParseInt(id, 10, 64) - c.JSON(http.StatusOK, service.UpdateTrainWheelDiameter(int32(int64Id), &req)) -} - -func deleteTrainWheelDiameter(c *gin.Context) { - idStr := c.Param("id") - id, err := strconv.Atoi(idStr) - if err != nil { - panic(sys_error.New("删除失败,缺少主键")) - } - service.DeleteTrainWheelDiameterById(id) - c.JSON(http.StatusOK, true) -} diff --git a/db/dbquery/gen.go b/db/dbquery/gen.go index 849dd4c..f358624 100644 --- a/db/dbquery/gen.go +++ b/db/dbquery/gen.go @@ -26,15 +26,9 @@ var ( Project *project ProjectPublishLink *projectPublishLink ProjectRunConfig *projectRunConfig - ProjectTrainSizeLink *projectTrainSizeLink Published *published - PublishedGi *publishedGi PublishedVersion *publishedVersion TrainInfo *trainInfo - TrainModel *trainModel - TrainSensor *trainSensor - TrainSize *trainSize - TrainWheel *trainWheel User *user ) @@ -49,15 +43,9 @@ func SetDefault(db *gorm.DB, opts ...gen.DOOption) { Project = &Q.Project ProjectPublishLink = &Q.ProjectPublishLink ProjectRunConfig = &Q.ProjectRunConfig - ProjectTrainSizeLink = &Q.ProjectTrainSizeLink Published = &Q.Published - PublishedGi = &Q.PublishedGi PublishedVersion = &Q.PublishedVersion TrainInfo = &Q.TrainInfo - TrainModel = &Q.TrainModel - TrainSensor = &Q.TrainSensor - TrainSize = &Q.TrainSize - TrainWheel = &Q.TrainWheel User = &Q.User } @@ -73,15 +61,9 @@ func Use(db *gorm.DB, opts ...gen.DOOption) *Query { Project: newProject(db, opts...), ProjectPublishLink: newProjectPublishLink(db, opts...), ProjectRunConfig: newProjectRunConfig(db, opts...), - ProjectTrainSizeLink: newProjectTrainSizeLink(db, opts...), Published: newPublished(db, opts...), - PublishedGi: newPublishedGi(db, opts...), PublishedVersion: newPublishedVersion(db, opts...), TrainInfo: newTrainInfo(db, opts...), - TrainModel: newTrainModel(db, opts...), - TrainSensor: newTrainSensor(db, opts...), - TrainSize: newTrainSize(db, opts...), - TrainWheel: newTrainWheel(db, opts...), User: newUser(db, opts...), } } @@ -98,15 +80,9 @@ type Query struct { Project project ProjectPublishLink projectPublishLink ProjectRunConfig projectRunConfig - ProjectTrainSizeLink projectTrainSizeLink Published published - PublishedGi publishedGi PublishedVersion publishedVersion TrainInfo trainInfo - TrainModel trainModel - TrainSensor trainSensor - TrainSize trainSize - TrainWheel trainWheel User user } @@ -124,15 +100,9 @@ func (q *Query) clone(db *gorm.DB) *Query { Project: q.Project.clone(db), ProjectPublishLink: q.ProjectPublishLink.clone(db), ProjectRunConfig: q.ProjectRunConfig.clone(db), - ProjectTrainSizeLink: q.ProjectTrainSizeLink.clone(db), Published: q.Published.clone(db), - PublishedGi: q.PublishedGi.clone(db), PublishedVersion: q.PublishedVersion.clone(db), TrainInfo: q.TrainInfo.clone(db), - TrainModel: q.TrainModel.clone(db), - TrainSensor: q.TrainSensor.clone(db), - TrainSize: q.TrainSize.clone(db), - TrainWheel: q.TrainWheel.clone(db), User: q.User.clone(db), } } @@ -157,15 +127,9 @@ func (q *Query) ReplaceDB(db *gorm.DB) *Query { Project: q.Project.replaceDB(db), ProjectPublishLink: q.ProjectPublishLink.replaceDB(db), ProjectRunConfig: q.ProjectRunConfig.replaceDB(db), - ProjectTrainSizeLink: q.ProjectTrainSizeLink.replaceDB(db), Published: q.Published.replaceDB(db), - PublishedGi: q.PublishedGi.replaceDB(db), PublishedVersion: q.PublishedVersion.replaceDB(db), TrainInfo: q.TrainInfo.replaceDB(db), - TrainModel: q.TrainModel.replaceDB(db), - TrainSensor: q.TrainSensor.replaceDB(db), - TrainSize: q.TrainSize.replaceDB(db), - TrainWheel: q.TrainWheel.replaceDB(db), User: q.User.replaceDB(db), } } @@ -180,15 +144,9 @@ type queryCtx struct { Project IProjectDo ProjectPublishLink IProjectPublishLinkDo ProjectRunConfig IProjectRunConfigDo - ProjectTrainSizeLink IProjectTrainSizeLinkDo Published IPublishedDo - PublishedGi IPublishedGiDo PublishedVersion IPublishedVersionDo TrainInfo ITrainInfoDo - TrainModel ITrainModelDo - TrainSensor ITrainSensorDo - TrainSize ITrainSizeDo - TrainWheel ITrainWheelDo User IUserDo } @@ -203,15 +161,9 @@ func (q *Query) WithContext(ctx context.Context) *queryCtx { Project: q.Project.WithContext(ctx), ProjectPublishLink: q.ProjectPublishLink.WithContext(ctx), ProjectRunConfig: q.ProjectRunConfig.WithContext(ctx), - ProjectTrainSizeLink: q.ProjectTrainSizeLink.WithContext(ctx), Published: q.Published.WithContext(ctx), - PublishedGi: q.PublishedGi.WithContext(ctx), PublishedVersion: q.PublishedVersion.WithContext(ctx), TrainInfo: q.TrainInfo.WithContext(ctx), - TrainModel: q.TrainModel.WithContext(ctx), - TrainSensor: q.TrainSensor.WithContext(ctx), - TrainSize: q.TrainSize.WithContext(ctx), - TrainWheel: q.TrainWheel.WithContext(ctx), User: q.User.WithContext(ctx), } } diff --git a/db/dbquery/project_train_size.gen.go b/db/dbquery/project_train_size.gen.go deleted file mode 100644 index 888c060..0000000 --- a/db/dbquery/project_train_size.gen.go +++ /dev/null @@ -1,388 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newProjectTrainSize(db *gorm.DB, opts ...gen.DOOption) projectTrainSize { - _projectTrainSize := projectTrainSize{} - - _projectTrainSize.projectTrainSizeDo.UseDB(db, opts...) - _projectTrainSize.projectTrainSizeDo.UseModel(&model.ProjectTrainSize{}) - - tableName := _projectTrainSize.projectTrainSizeDo.TableName() - _projectTrainSize.ALL = field.NewAsterisk(tableName) - _projectTrainSize.ID = field.NewInt32(tableName, "id") - _projectTrainSize.Pid = field.NewInt32(tableName, "pid") - _projectTrainSize.Sid = field.NewInt32(tableName, "sid") - - _projectTrainSize.fillFieldMap() - - return _projectTrainSize -} - -type projectTrainSize struct { - projectTrainSizeDo - - ALL field.Asterisk - ID field.Int32 // 主键 - Pid field.Int32 // 项目主键 - Sid field.Int32 // 列车尺寸主键 - - fieldMap map[string]field.Expr -} - -func (p projectTrainSize) Table(newTableName string) *projectTrainSize { - p.projectTrainSizeDo.UseTable(newTableName) - return p.updateTableName(newTableName) -} - -func (p projectTrainSize) As(alias string) *projectTrainSize { - p.projectTrainSizeDo.DO = *(p.projectTrainSizeDo.As(alias).(*gen.DO)) - return p.updateTableName(alias) -} - -func (p *projectTrainSize) updateTableName(table string) *projectTrainSize { - p.ALL = field.NewAsterisk(table) - p.ID = field.NewInt32(table, "id") - p.Pid = field.NewInt32(table, "pid") - p.Sid = field.NewInt32(table, "sid") - - p.fillFieldMap() - - return p -} - -func (p *projectTrainSize) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := p.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (p *projectTrainSize) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 3) - p.fieldMap["id"] = p.ID - p.fieldMap["pid"] = p.Pid - p.fieldMap["sid"] = p.Sid -} - -func (p projectTrainSize) clone(db *gorm.DB) projectTrainSize { - p.projectTrainSizeDo.ReplaceConnPool(db.Statement.ConnPool) - return p -} - -func (p projectTrainSize) replaceDB(db *gorm.DB) projectTrainSize { - p.projectTrainSizeDo.ReplaceDB(db) - return p -} - -type projectTrainSizeDo struct{ gen.DO } - -type IProjectTrainSizeDo interface { - gen.SubQuery - Debug() IProjectTrainSizeDo - WithContext(ctx context.Context) IProjectTrainSizeDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() IProjectTrainSizeDo - WriteDB() IProjectTrainSizeDo - As(alias string) gen.Dao - Session(config *gorm.Session) IProjectTrainSizeDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) IProjectTrainSizeDo - Not(conds ...gen.Condition) IProjectTrainSizeDo - Or(conds ...gen.Condition) IProjectTrainSizeDo - Select(conds ...field.Expr) IProjectTrainSizeDo - Where(conds ...gen.Condition) IProjectTrainSizeDo - Order(conds ...field.Expr) IProjectTrainSizeDo - Distinct(cols ...field.Expr) IProjectTrainSizeDo - Omit(cols ...field.Expr) IProjectTrainSizeDo - Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo - LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo - RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo - Group(cols ...field.Expr) IProjectTrainSizeDo - Having(conds ...gen.Condition) IProjectTrainSizeDo - Limit(limit int) IProjectTrainSizeDo - Offset(offset int) IProjectTrainSizeDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeDo - Unscoped() IProjectTrainSizeDo - Create(values ...*model.ProjectTrainSize) error - CreateInBatches(values []*model.ProjectTrainSize, batchSize int) error - Save(values ...*model.ProjectTrainSize) error - First() (*model.ProjectTrainSize, error) - Take() (*model.ProjectTrainSize, error) - Last() (*model.ProjectTrainSize, error) - Find() ([]*model.ProjectTrainSize, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSize, err error) - FindInBatches(result *[]*model.ProjectTrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.ProjectTrainSize) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) IProjectTrainSizeDo - Assign(attrs ...field.AssignExpr) IProjectTrainSizeDo - Joins(fields ...field.RelationField) IProjectTrainSizeDo - Preload(fields ...field.RelationField) IProjectTrainSizeDo - FirstOrInit() (*model.ProjectTrainSize, error) - FirstOrCreate() (*model.ProjectTrainSize, error) - FindByPage(offset int, limit int) (result []*model.ProjectTrainSize, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) IProjectTrainSizeDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (p projectTrainSizeDo) Debug() IProjectTrainSizeDo { - return p.withDO(p.DO.Debug()) -} - -func (p projectTrainSizeDo) WithContext(ctx context.Context) IProjectTrainSizeDo { - return p.withDO(p.DO.WithContext(ctx)) -} - -func (p projectTrainSizeDo) ReadDB() IProjectTrainSizeDo { - return p.Clauses(dbresolver.Read) -} - -func (p projectTrainSizeDo) WriteDB() IProjectTrainSizeDo { - return p.Clauses(dbresolver.Write) -} - -func (p projectTrainSizeDo) Session(config *gorm.Session) IProjectTrainSizeDo { - return p.withDO(p.DO.Session(config)) -} - -func (p projectTrainSizeDo) Clauses(conds ...clause.Expression) IProjectTrainSizeDo { - return p.withDO(p.DO.Clauses(conds...)) -} - -func (p projectTrainSizeDo) Returning(value interface{}, columns ...string) IProjectTrainSizeDo { - return p.withDO(p.DO.Returning(value, columns...)) -} - -func (p projectTrainSizeDo) Not(conds ...gen.Condition) IProjectTrainSizeDo { - return p.withDO(p.DO.Not(conds...)) -} - -func (p projectTrainSizeDo) Or(conds ...gen.Condition) IProjectTrainSizeDo { - return p.withDO(p.DO.Or(conds...)) -} - -func (p projectTrainSizeDo) Select(conds ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.Select(conds...)) -} - -func (p projectTrainSizeDo) Where(conds ...gen.Condition) IProjectTrainSizeDo { - return p.withDO(p.DO.Where(conds...)) -} - -func (p projectTrainSizeDo) Order(conds ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.Order(conds...)) -} - -func (p projectTrainSizeDo) Distinct(cols ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.Distinct(cols...)) -} - -func (p projectTrainSizeDo) Omit(cols ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.Omit(cols...)) -} - -func (p projectTrainSizeDo) Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.Join(table, on...)) -} - -func (p projectTrainSizeDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.LeftJoin(table, on...)) -} - -func (p projectTrainSizeDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.RightJoin(table, on...)) -} - -func (p projectTrainSizeDo) Group(cols ...field.Expr) IProjectTrainSizeDo { - return p.withDO(p.DO.Group(cols...)) -} - -func (p projectTrainSizeDo) Having(conds ...gen.Condition) IProjectTrainSizeDo { - return p.withDO(p.DO.Having(conds...)) -} - -func (p projectTrainSizeDo) Limit(limit int) IProjectTrainSizeDo { - return p.withDO(p.DO.Limit(limit)) -} - -func (p projectTrainSizeDo) Offset(offset int) IProjectTrainSizeDo { - return p.withDO(p.DO.Offset(offset)) -} - -func (p projectTrainSizeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeDo { - return p.withDO(p.DO.Scopes(funcs...)) -} - -func (p projectTrainSizeDo) Unscoped() IProjectTrainSizeDo { - return p.withDO(p.DO.Unscoped()) -} - -func (p projectTrainSizeDo) Create(values ...*model.ProjectTrainSize) error { - if len(values) == 0 { - return nil - } - return p.DO.Create(values) -} - -func (p projectTrainSizeDo) CreateInBatches(values []*model.ProjectTrainSize, batchSize int) error { - return p.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (p projectTrainSizeDo) Save(values ...*model.ProjectTrainSize) error { - if len(values) == 0 { - return nil - } - return p.DO.Save(values) -} - -func (p projectTrainSizeDo) First() (*model.ProjectTrainSize, error) { - if result, err := p.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSize), nil - } -} - -func (p projectTrainSizeDo) Take() (*model.ProjectTrainSize, error) { - if result, err := p.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSize), nil - } -} - -func (p projectTrainSizeDo) Last() (*model.ProjectTrainSize, error) { - if result, err := p.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSize), nil - } -} - -func (p projectTrainSizeDo) Find() ([]*model.ProjectTrainSize, error) { - result, err := p.DO.Find() - return result.([]*model.ProjectTrainSize), err -} - -func (p projectTrainSizeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSize, err error) { - buf := make([]*model.ProjectTrainSize, 0, batchSize) - err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (p projectTrainSizeDo) FindInBatches(result *[]*model.ProjectTrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return p.DO.FindInBatches(result, batchSize, fc) -} - -func (p projectTrainSizeDo) Attrs(attrs ...field.AssignExpr) IProjectTrainSizeDo { - return p.withDO(p.DO.Attrs(attrs...)) -} - -func (p projectTrainSizeDo) Assign(attrs ...field.AssignExpr) IProjectTrainSizeDo { - return p.withDO(p.DO.Assign(attrs...)) -} - -func (p projectTrainSizeDo) Joins(fields ...field.RelationField) IProjectTrainSizeDo { - for _, _f := range fields { - p = *p.withDO(p.DO.Joins(_f)) - } - return &p -} - -func (p projectTrainSizeDo) Preload(fields ...field.RelationField) IProjectTrainSizeDo { - for _, _f := range fields { - p = *p.withDO(p.DO.Preload(_f)) - } - return &p -} - -func (p projectTrainSizeDo) FirstOrInit() (*model.ProjectTrainSize, error) { - if result, err := p.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSize), nil - } -} - -func (p projectTrainSizeDo) FirstOrCreate() (*model.ProjectTrainSize, error) { - if result, err := p.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSize), nil - } -} - -func (p projectTrainSizeDo) FindByPage(offset int, limit int) (result []*model.ProjectTrainSize, count int64, err error) { - result, err = p.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = p.Offset(-1).Limit(-1).Count() - return -} - -func (p projectTrainSizeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = p.Count() - if err != nil { - return - } - - err = p.Offset(offset).Limit(limit).Scan(result) - return -} - -func (p projectTrainSizeDo) Scan(result interface{}) (err error) { - return p.DO.Scan(result) -} - -func (p projectTrainSizeDo) Delete(models ...*model.ProjectTrainSize) (result gen.ResultInfo, err error) { - return p.DO.Delete(models) -} - -func (p *projectTrainSizeDo) withDO(do gen.Dao) *projectTrainSizeDo { - p.DO = *do.(*gen.DO) - return p -} diff --git a/db/dbquery/project_train_size_link.gen.go b/db/dbquery/project_train_size_link.gen.go deleted file mode 100644 index b18efcd..0000000 --- a/db/dbquery/project_train_size_link.gen.go +++ /dev/null @@ -1,388 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newProjectTrainSizeLink(db *gorm.DB, opts ...gen.DOOption) projectTrainSizeLink { - _projectTrainSizeLink := projectTrainSizeLink{} - - _projectTrainSizeLink.projectTrainSizeLinkDo.UseDB(db, opts...) - _projectTrainSizeLink.projectTrainSizeLinkDo.UseModel(&model.ProjectTrainSizeLink{}) - - tableName := _projectTrainSizeLink.projectTrainSizeLinkDo.TableName() - _projectTrainSizeLink.ALL = field.NewAsterisk(tableName) - _projectTrainSizeLink.ID = field.NewInt32(tableName, "id") - _projectTrainSizeLink.Pid = field.NewInt32(tableName, "pid") - _projectTrainSizeLink.Sid = field.NewInt32(tableName, "sid") - - _projectTrainSizeLink.fillFieldMap() - - return _projectTrainSizeLink -} - -type projectTrainSizeLink struct { - projectTrainSizeLinkDo - - ALL field.Asterisk - ID field.Int32 // 主键 - Pid field.Int32 // 项目主键 - Sid field.Int32 // 列车尺寸主键 - - fieldMap map[string]field.Expr -} - -func (p projectTrainSizeLink) Table(newTableName string) *projectTrainSizeLink { - p.projectTrainSizeLinkDo.UseTable(newTableName) - return p.updateTableName(newTableName) -} - -func (p projectTrainSizeLink) As(alias string) *projectTrainSizeLink { - p.projectTrainSizeLinkDo.DO = *(p.projectTrainSizeLinkDo.As(alias).(*gen.DO)) - return p.updateTableName(alias) -} - -func (p *projectTrainSizeLink) updateTableName(table string) *projectTrainSizeLink { - p.ALL = field.NewAsterisk(table) - p.ID = field.NewInt32(table, "id") - p.Pid = field.NewInt32(table, "pid") - p.Sid = field.NewInt32(table, "sid") - - p.fillFieldMap() - - return p -} - -func (p *projectTrainSizeLink) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := p.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (p *projectTrainSizeLink) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 3) - p.fieldMap["id"] = p.ID - p.fieldMap["pid"] = p.Pid - p.fieldMap["sid"] = p.Sid -} - -func (p projectTrainSizeLink) clone(db *gorm.DB) projectTrainSizeLink { - p.projectTrainSizeLinkDo.ReplaceConnPool(db.Statement.ConnPool) - return p -} - -func (p projectTrainSizeLink) replaceDB(db *gorm.DB) projectTrainSizeLink { - p.projectTrainSizeLinkDo.ReplaceDB(db) - return p -} - -type projectTrainSizeLinkDo struct{ gen.DO } - -type IProjectTrainSizeLinkDo interface { - gen.SubQuery - Debug() IProjectTrainSizeLinkDo - WithContext(ctx context.Context) IProjectTrainSizeLinkDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() IProjectTrainSizeLinkDo - WriteDB() IProjectTrainSizeLinkDo - As(alias string) gen.Dao - Session(config *gorm.Session) IProjectTrainSizeLinkDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) IProjectTrainSizeLinkDo - Not(conds ...gen.Condition) IProjectTrainSizeLinkDo - Or(conds ...gen.Condition) IProjectTrainSizeLinkDo - Select(conds ...field.Expr) IProjectTrainSizeLinkDo - Where(conds ...gen.Condition) IProjectTrainSizeLinkDo - Order(conds ...field.Expr) IProjectTrainSizeLinkDo - Distinct(cols ...field.Expr) IProjectTrainSizeLinkDo - Omit(cols ...field.Expr) IProjectTrainSizeLinkDo - Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo - LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo - RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo - Group(cols ...field.Expr) IProjectTrainSizeLinkDo - Having(conds ...gen.Condition) IProjectTrainSizeLinkDo - Limit(limit int) IProjectTrainSizeLinkDo - Offset(offset int) IProjectTrainSizeLinkDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeLinkDo - Unscoped() IProjectTrainSizeLinkDo - Create(values ...*model.ProjectTrainSizeLink) error - CreateInBatches(values []*model.ProjectTrainSizeLink, batchSize int) error - Save(values ...*model.ProjectTrainSizeLink) error - First() (*model.ProjectTrainSizeLink, error) - Take() (*model.ProjectTrainSizeLink, error) - Last() (*model.ProjectTrainSizeLink, error) - Find() ([]*model.ProjectTrainSizeLink, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSizeLink, err error) - FindInBatches(result *[]*model.ProjectTrainSizeLink, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.ProjectTrainSizeLink) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo - Assign(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo - Joins(fields ...field.RelationField) IProjectTrainSizeLinkDo - Preload(fields ...field.RelationField) IProjectTrainSizeLinkDo - FirstOrInit() (*model.ProjectTrainSizeLink, error) - FirstOrCreate() (*model.ProjectTrainSizeLink, error) - FindByPage(offset int, limit int) (result []*model.ProjectTrainSizeLink, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) IProjectTrainSizeLinkDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (p projectTrainSizeLinkDo) Debug() IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Debug()) -} - -func (p projectTrainSizeLinkDo) WithContext(ctx context.Context) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.WithContext(ctx)) -} - -func (p projectTrainSizeLinkDo) ReadDB() IProjectTrainSizeLinkDo { - return p.Clauses(dbresolver.Read) -} - -func (p projectTrainSizeLinkDo) WriteDB() IProjectTrainSizeLinkDo { - return p.Clauses(dbresolver.Write) -} - -func (p projectTrainSizeLinkDo) Session(config *gorm.Session) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Session(config)) -} - -func (p projectTrainSizeLinkDo) Clauses(conds ...clause.Expression) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Clauses(conds...)) -} - -func (p projectTrainSizeLinkDo) Returning(value interface{}, columns ...string) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Returning(value, columns...)) -} - -func (p projectTrainSizeLinkDo) Not(conds ...gen.Condition) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Not(conds...)) -} - -func (p projectTrainSizeLinkDo) Or(conds ...gen.Condition) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Or(conds...)) -} - -func (p projectTrainSizeLinkDo) Select(conds ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Select(conds...)) -} - -func (p projectTrainSizeLinkDo) Where(conds ...gen.Condition) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Where(conds...)) -} - -func (p projectTrainSizeLinkDo) Order(conds ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Order(conds...)) -} - -func (p projectTrainSizeLinkDo) Distinct(cols ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Distinct(cols...)) -} - -func (p projectTrainSizeLinkDo) Omit(cols ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Omit(cols...)) -} - -func (p projectTrainSizeLinkDo) Join(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Join(table, on...)) -} - -func (p projectTrainSizeLinkDo) LeftJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.LeftJoin(table, on...)) -} - -func (p projectTrainSizeLinkDo) RightJoin(table schema.Tabler, on ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.RightJoin(table, on...)) -} - -func (p projectTrainSizeLinkDo) Group(cols ...field.Expr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Group(cols...)) -} - -func (p projectTrainSizeLinkDo) Having(conds ...gen.Condition) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Having(conds...)) -} - -func (p projectTrainSizeLinkDo) Limit(limit int) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Limit(limit)) -} - -func (p projectTrainSizeLinkDo) Offset(offset int) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Offset(offset)) -} - -func (p projectTrainSizeLinkDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Scopes(funcs...)) -} - -func (p projectTrainSizeLinkDo) Unscoped() IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Unscoped()) -} - -func (p projectTrainSizeLinkDo) Create(values ...*model.ProjectTrainSizeLink) error { - if len(values) == 0 { - return nil - } - return p.DO.Create(values) -} - -func (p projectTrainSizeLinkDo) CreateInBatches(values []*model.ProjectTrainSizeLink, batchSize int) error { - return p.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (p projectTrainSizeLinkDo) Save(values ...*model.ProjectTrainSizeLink) error { - if len(values) == 0 { - return nil - } - return p.DO.Save(values) -} - -func (p projectTrainSizeLinkDo) First() (*model.ProjectTrainSizeLink, error) { - if result, err := p.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSizeLink), nil - } -} - -func (p projectTrainSizeLinkDo) Take() (*model.ProjectTrainSizeLink, error) { - if result, err := p.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSizeLink), nil - } -} - -func (p projectTrainSizeLinkDo) Last() (*model.ProjectTrainSizeLink, error) { - if result, err := p.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSizeLink), nil - } -} - -func (p projectTrainSizeLinkDo) Find() ([]*model.ProjectTrainSizeLink, error) { - result, err := p.DO.Find() - return result.([]*model.ProjectTrainSizeLink), err -} - -func (p projectTrainSizeLinkDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ProjectTrainSizeLink, err error) { - buf := make([]*model.ProjectTrainSizeLink, 0, batchSize) - err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (p projectTrainSizeLinkDo) FindInBatches(result *[]*model.ProjectTrainSizeLink, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return p.DO.FindInBatches(result, batchSize, fc) -} - -func (p projectTrainSizeLinkDo) Attrs(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Attrs(attrs...)) -} - -func (p projectTrainSizeLinkDo) Assign(attrs ...field.AssignExpr) IProjectTrainSizeLinkDo { - return p.withDO(p.DO.Assign(attrs...)) -} - -func (p projectTrainSizeLinkDo) Joins(fields ...field.RelationField) IProjectTrainSizeLinkDo { - for _, _f := range fields { - p = *p.withDO(p.DO.Joins(_f)) - } - return &p -} - -func (p projectTrainSizeLinkDo) Preload(fields ...field.RelationField) IProjectTrainSizeLinkDo { - for _, _f := range fields { - p = *p.withDO(p.DO.Preload(_f)) - } - return &p -} - -func (p projectTrainSizeLinkDo) FirstOrInit() (*model.ProjectTrainSizeLink, error) { - if result, err := p.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSizeLink), nil - } -} - -func (p projectTrainSizeLinkDo) FirstOrCreate() (*model.ProjectTrainSizeLink, error) { - if result, err := p.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.ProjectTrainSizeLink), nil - } -} - -func (p projectTrainSizeLinkDo) FindByPage(offset int, limit int) (result []*model.ProjectTrainSizeLink, count int64, err error) { - result, err = p.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = p.Offset(-1).Limit(-1).Count() - return -} - -func (p projectTrainSizeLinkDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = p.Count() - if err != nil { - return - } - - err = p.Offset(offset).Limit(limit).Scan(result) - return -} - -func (p projectTrainSizeLinkDo) Scan(result interface{}) (err error) { - return p.DO.Scan(result) -} - -func (p projectTrainSizeLinkDo) Delete(models ...*model.ProjectTrainSizeLink) (result gen.ResultInfo, err error) { - return p.DO.Delete(models) -} - -func (p *projectTrainSizeLinkDo) withDO(do gen.Dao) *projectTrainSizeLinkDo { - p.DO = *do.(*gen.DO) - return p -} diff --git a/db/dbquery/published_gi.gen.go b/db/dbquery/published_gi.gen.go deleted file mode 100644 index 499a470..0000000 --- a/db/dbquery/published_gi.gen.go +++ /dev/null @@ -1,412 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newPublishedGi(db *gorm.DB, opts ...gen.DOOption) publishedGi { - _publishedGi := publishedGi{} - - _publishedGi.publishedGiDo.UseDB(db, opts...) - _publishedGi.publishedGiDo.UseModel(&model.PublishedGi{}) - - tableName := _publishedGi.publishedGiDo.TableName() - _publishedGi.ALL = field.NewAsterisk(tableName) - _publishedGi.ID = field.NewInt32(tableName, "id") - _publishedGi.Name = field.NewString(tableName, "name") - _publishedGi.Proto = field.NewBytes(tableName, "proto") - _publishedGi.UserID = field.NewInt32(tableName, "user_id") - _publishedGi.PublishAt = field.NewTime(tableName, "publish_at") - _publishedGi.Category = field.NewString(tableName, "category") - _publishedGi.Note = field.NewString(tableName, "note") - _publishedGi.Status = field.NewInt32(tableName, "status") - _publishedGi.Type = field.NewInt32(tableName, "type") - - _publishedGi.fillFieldMap() - - return _publishedGi -} - -type publishedGi struct { - publishedGiDo - - ALL field.Asterisk - ID field.Int32 // id - Name field.String // 发布图形界面名称 - Proto field.Bytes // 图形界面数据 - UserID field.Int32 // 发布用户id - PublishAt field.Time // 发布时间 - Category field.String // 厂家信息 - Note field.String // 发布描述 - Status field.Int32 // 显示状态 - Type field.Int32 // 数据类型 - - fieldMap map[string]field.Expr -} - -func (p publishedGi) Table(newTableName string) *publishedGi { - p.publishedGiDo.UseTable(newTableName) - return p.updateTableName(newTableName) -} - -func (p publishedGi) As(alias string) *publishedGi { - p.publishedGiDo.DO = *(p.publishedGiDo.As(alias).(*gen.DO)) - return p.updateTableName(alias) -} - -func (p *publishedGi) updateTableName(table string) *publishedGi { - p.ALL = field.NewAsterisk(table) - p.ID = field.NewInt32(table, "id") - p.Name = field.NewString(table, "name") - p.Proto = field.NewBytes(table, "proto") - p.UserID = field.NewInt32(table, "user_id") - p.PublishAt = field.NewTime(table, "publish_at") - p.Category = field.NewString(table, "category") - p.Note = field.NewString(table, "note") - p.Status = field.NewInt32(table, "status") - p.Type = field.NewInt32(table, "type") - - p.fillFieldMap() - - return p -} - -func (p *publishedGi) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := p.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (p *publishedGi) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 9) - p.fieldMap["id"] = p.ID - p.fieldMap["name"] = p.Name - p.fieldMap["proto"] = p.Proto - p.fieldMap["user_id"] = p.UserID - p.fieldMap["publish_at"] = p.PublishAt - p.fieldMap["category"] = p.Category - p.fieldMap["note"] = p.Note - p.fieldMap["status"] = p.Status - p.fieldMap["type"] = p.Type -} - -func (p publishedGi) clone(db *gorm.DB) publishedGi { - p.publishedGiDo.ReplaceConnPool(db.Statement.ConnPool) - return p -} - -func (p publishedGi) replaceDB(db *gorm.DB) publishedGi { - p.publishedGiDo.ReplaceDB(db) - return p -} - -type publishedGiDo struct{ gen.DO } - -type IPublishedGiDo interface { - gen.SubQuery - Debug() IPublishedGiDo - WithContext(ctx context.Context) IPublishedGiDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() IPublishedGiDo - WriteDB() IPublishedGiDo - As(alias string) gen.Dao - Session(config *gorm.Session) IPublishedGiDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) IPublishedGiDo - Not(conds ...gen.Condition) IPublishedGiDo - Or(conds ...gen.Condition) IPublishedGiDo - Select(conds ...field.Expr) IPublishedGiDo - Where(conds ...gen.Condition) IPublishedGiDo - Order(conds ...field.Expr) IPublishedGiDo - Distinct(cols ...field.Expr) IPublishedGiDo - Omit(cols ...field.Expr) IPublishedGiDo - Join(table schema.Tabler, on ...field.Expr) IPublishedGiDo - LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedGiDo - RightJoin(table schema.Tabler, on ...field.Expr) IPublishedGiDo - Group(cols ...field.Expr) IPublishedGiDo - Having(conds ...gen.Condition) IPublishedGiDo - Limit(limit int) IPublishedGiDo - Offset(offset int) IPublishedGiDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedGiDo - Unscoped() IPublishedGiDo - Create(values ...*model.PublishedGi) error - CreateInBatches(values []*model.PublishedGi, batchSize int) error - Save(values ...*model.PublishedGi) error - First() (*model.PublishedGi, error) - Take() (*model.PublishedGi, error) - Last() (*model.PublishedGi, error) - Find() ([]*model.PublishedGi, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PublishedGi, err error) - FindInBatches(result *[]*model.PublishedGi, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.PublishedGi) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) IPublishedGiDo - Assign(attrs ...field.AssignExpr) IPublishedGiDo - Joins(fields ...field.RelationField) IPublishedGiDo - Preload(fields ...field.RelationField) IPublishedGiDo - FirstOrInit() (*model.PublishedGi, error) - FirstOrCreate() (*model.PublishedGi, error) - FindByPage(offset int, limit int) (result []*model.PublishedGi, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) IPublishedGiDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (p publishedGiDo) Debug() IPublishedGiDo { - return p.withDO(p.DO.Debug()) -} - -func (p publishedGiDo) WithContext(ctx context.Context) IPublishedGiDo { - return p.withDO(p.DO.WithContext(ctx)) -} - -func (p publishedGiDo) ReadDB() IPublishedGiDo { - return p.Clauses(dbresolver.Read) -} - -func (p publishedGiDo) WriteDB() IPublishedGiDo { - return p.Clauses(dbresolver.Write) -} - -func (p publishedGiDo) Session(config *gorm.Session) IPublishedGiDo { - return p.withDO(p.DO.Session(config)) -} - -func (p publishedGiDo) Clauses(conds ...clause.Expression) IPublishedGiDo { - return p.withDO(p.DO.Clauses(conds...)) -} - -func (p publishedGiDo) Returning(value interface{}, columns ...string) IPublishedGiDo { - return p.withDO(p.DO.Returning(value, columns...)) -} - -func (p publishedGiDo) Not(conds ...gen.Condition) IPublishedGiDo { - return p.withDO(p.DO.Not(conds...)) -} - -func (p publishedGiDo) Or(conds ...gen.Condition) IPublishedGiDo { - return p.withDO(p.DO.Or(conds...)) -} - -func (p publishedGiDo) Select(conds ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.Select(conds...)) -} - -func (p publishedGiDo) Where(conds ...gen.Condition) IPublishedGiDo { - return p.withDO(p.DO.Where(conds...)) -} - -func (p publishedGiDo) Order(conds ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.Order(conds...)) -} - -func (p publishedGiDo) Distinct(cols ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.Distinct(cols...)) -} - -func (p publishedGiDo) Omit(cols ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.Omit(cols...)) -} - -func (p publishedGiDo) Join(table schema.Tabler, on ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.Join(table, on...)) -} - -func (p publishedGiDo) LeftJoin(table schema.Tabler, on ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.LeftJoin(table, on...)) -} - -func (p publishedGiDo) RightJoin(table schema.Tabler, on ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.RightJoin(table, on...)) -} - -func (p publishedGiDo) Group(cols ...field.Expr) IPublishedGiDo { - return p.withDO(p.DO.Group(cols...)) -} - -func (p publishedGiDo) Having(conds ...gen.Condition) IPublishedGiDo { - return p.withDO(p.DO.Having(conds...)) -} - -func (p publishedGiDo) Limit(limit int) IPublishedGiDo { - return p.withDO(p.DO.Limit(limit)) -} - -func (p publishedGiDo) Offset(offset int) IPublishedGiDo { - return p.withDO(p.DO.Offset(offset)) -} - -func (p publishedGiDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IPublishedGiDo { - return p.withDO(p.DO.Scopes(funcs...)) -} - -func (p publishedGiDo) Unscoped() IPublishedGiDo { - return p.withDO(p.DO.Unscoped()) -} - -func (p publishedGiDo) Create(values ...*model.PublishedGi) error { - if len(values) == 0 { - return nil - } - return p.DO.Create(values) -} - -func (p publishedGiDo) CreateInBatches(values []*model.PublishedGi, batchSize int) error { - return p.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (p publishedGiDo) Save(values ...*model.PublishedGi) error { - if len(values) == 0 { - return nil - } - return p.DO.Save(values) -} - -func (p publishedGiDo) First() (*model.PublishedGi, error) { - if result, err := p.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.PublishedGi), nil - } -} - -func (p publishedGiDo) Take() (*model.PublishedGi, error) { - if result, err := p.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.PublishedGi), nil - } -} - -func (p publishedGiDo) Last() (*model.PublishedGi, error) { - if result, err := p.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.PublishedGi), nil - } -} - -func (p publishedGiDo) Find() ([]*model.PublishedGi, error) { - result, err := p.DO.Find() - return result.([]*model.PublishedGi), err -} - -func (p publishedGiDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.PublishedGi, err error) { - buf := make([]*model.PublishedGi, 0, batchSize) - err = p.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (p publishedGiDo) FindInBatches(result *[]*model.PublishedGi, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return p.DO.FindInBatches(result, batchSize, fc) -} - -func (p publishedGiDo) Attrs(attrs ...field.AssignExpr) IPublishedGiDo { - return p.withDO(p.DO.Attrs(attrs...)) -} - -func (p publishedGiDo) Assign(attrs ...field.AssignExpr) IPublishedGiDo { - return p.withDO(p.DO.Assign(attrs...)) -} - -func (p publishedGiDo) Joins(fields ...field.RelationField) IPublishedGiDo { - for _, _f := range fields { - p = *p.withDO(p.DO.Joins(_f)) - } - return &p -} - -func (p publishedGiDo) Preload(fields ...field.RelationField) IPublishedGiDo { - for _, _f := range fields { - p = *p.withDO(p.DO.Preload(_f)) - } - return &p -} - -func (p publishedGiDo) FirstOrInit() (*model.PublishedGi, error) { - if result, err := p.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.PublishedGi), nil - } -} - -func (p publishedGiDo) FirstOrCreate() (*model.PublishedGi, error) { - if result, err := p.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.PublishedGi), nil - } -} - -func (p publishedGiDo) FindByPage(offset int, limit int) (result []*model.PublishedGi, count int64, err error) { - result, err = p.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = p.Offset(-1).Limit(-1).Count() - return -} - -func (p publishedGiDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = p.Count() - if err != nil { - return - } - - err = p.Offset(offset).Limit(limit).Scan(result) - return -} - -func (p publishedGiDo) Scan(result interface{}) (err error) { - return p.DO.Scan(result) -} - -func (p publishedGiDo) Delete(models ...*model.PublishedGi) (result gen.ResultInfo, err error) { - return p.DO.Delete(models) -} - -func (p *publishedGiDo) withDO(do gen.Dao) *publishedGiDo { - p.DO = *do.(*gen.DO) - return p -} diff --git a/db/dbquery/train_model.gen.go b/db/dbquery/train_model.gen.go deleted file mode 100644 index 1f88009..0000000 --- a/db/dbquery/train_model.gen.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newTrainModel(db *gorm.DB, opts ...gen.DOOption) trainModel { - _trainModel := trainModel{} - - _trainModel.trainModelDo.UseDB(db, opts...) - _trainModel.trainModelDo.UseModel(&model.TrainModel{}) - - tableName := _trainModel.trainModelDo.TableName() - _trainModel.ALL = field.NewAsterisk(tableName) - _trainModel.ID = field.NewInt32(tableName, "id") - _trainModel.Name = field.NewString(tableName, "name") - _trainModel.CreatedAt = field.NewTime(tableName, "created_at") - _trainModel.UpdateAt = field.NewTime(tableName, "update_at") - - _trainModel.fillFieldMap() - - return _trainModel -} - -type trainModel struct { - trainModelDo - - ALL field.Asterisk - ID field.Int32 - Name field.String // 组次名称 - CreatedAt field.Time // 创建时间 - UpdateAt field.Time // 更新时间 - - fieldMap map[string]field.Expr -} - -func (t trainModel) Table(newTableName string) *trainModel { - t.trainModelDo.UseTable(newTableName) - return t.updateTableName(newTableName) -} - -func (t trainModel) As(alias string) *trainModel { - t.trainModelDo.DO = *(t.trainModelDo.As(alias).(*gen.DO)) - return t.updateTableName(alias) -} - -func (t *trainModel) updateTableName(table string) *trainModel { - t.ALL = field.NewAsterisk(table) - t.ID = field.NewInt32(table, "id") - t.Name = field.NewString(table, "name") - t.CreatedAt = field.NewTime(table, "created_at") - t.UpdateAt = field.NewTime(table, "update_at") - - t.fillFieldMap() - - return t -} - -func (t *trainModel) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := t.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (t *trainModel) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 4) - t.fieldMap["id"] = t.ID - t.fieldMap["name"] = t.Name - t.fieldMap["created_at"] = t.CreatedAt - t.fieldMap["update_at"] = t.UpdateAt -} - -func (t trainModel) clone(db *gorm.DB) trainModel { - t.trainModelDo.ReplaceConnPool(db.Statement.ConnPool) - return t -} - -func (t trainModel) replaceDB(db *gorm.DB) trainModel { - t.trainModelDo.ReplaceDB(db) - return t -} - -type trainModelDo struct{ gen.DO } - -type ITrainModelDo interface { - gen.SubQuery - Debug() ITrainModelDo - WithContext(ctx context.Context) ITrainModelDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() ITrainModelDo - WriteDB() ITrainModelDo - As(alias string) gen.Dao - Session(config *gorm.Session) ITrainModelDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) ITrainModelDo - Not(conds ...gen.Condition) ITrainModelDo - Or(conds ...gen.Condition) ITrainModelDo - Select(conds ...field.Expr) ITrainModelDo - Where(conds ...gen.Condition) ITrainModelDo - Order(conds ...field.Expr) ITrainModelDo - Distinct(cols ...field.Expr) ITrainModelDo - Omit(cols ...field.Expr) ITrainModelDo - Join(table schema.Tabler, on ...field.Expr) ITrainModelDo - LeftJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo - RightJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo - Group(cols ...field.Expr) ITrainModelDo - Having(conds ...gen.Condition) ITrainModelDo - Limit(limit int) ITrainModelDo - Offset(offset int) ITrainModelDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainModelDo - Unscoped() ITrainModelDo - Create(values ...*model.TrainModel) error - CreateInBatches(values []*model.TrainModel, batchSize int) error - Save(values ...*model.TrainModel) error - First() (*model.TrainModel, error) - Take() (*model.TrainModel, error) - Last() (*model.TrainModel, error) - Find() ([]*model.TrainModel, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainModel, err error) - FindInBatches(result *[]*model.TrainModel, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.TrainModel) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) ITrainModelDo - Assign(attrs ...field.AssignExpr) ITrainModelDo - Joins(fields ...field.RelationField) ITrainModelDo - Preload(fields ...field.RelationField) ITrainModelDo - FirstOrInit() (*model.TrainModel, error) - FirstOrCreate() (*model.TrainModel, error) - FindByPage(offset int, limit int) (result []*model.TrainModel, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) ITrainModelDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (t trainModelDo) Debug() ITrainModelDo { - return t.withDO(t.DO.Debug()) -} - -func (t trainModelDo) WithContext(ctx context.Context) ITrainModelDo { - return t.withDO(t.DO.WithContext(ctx)) -} - -func (t trainModelDo) ReadDB() ITrainModelDo { - return t.Clauses(dbresolver.Read) -} - -func (t trainModelDo) WriteDB() ITrainModelDo { - return t.Clauses(dbresolver.Write) -} - -func (t trainModelDo) Session(config *gorm.Session) ITrainModelDo { - return t.withDO(t.DO.Session(config)) -} - -func (t trainModelDo) Clauses(conds ...clause.Expression) ITrainModelDo { - return t.withDO(t.DO.Clauses(conds...)) -} - -func (t trainModelDo) Returning(value interface{}, columns ...string) ITrainModelDo { - return t.withDO(t.DO.Returning(value, columns...)) -} - -func (t trainModelDo) Not(conds ...gen.Condition) ITrainModelDo { - return t.withDO(t.DO.Not(conds...)) -} - -func (t trainModelDo) Or(conds ...gen.Condition) ITrainModelDo { - return t.withDO(t.DO.Or(conds...)) -} - -func (t trainModelDo) Select(conds ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.Select(conds...)) -} - -func (t trainModelDo) Where(conds ...gen.Condition) ITrainModelDo { - return t.withDO(t.DO.Where(conds...)) -} - -func (t trainModelDo) Order(conds ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.Order(conds...)) -} - -func (t trainModelDo) Distinct(cols ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.Distinct(cols...)) -} - -func (t trainModelDo) Omit(cols ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.Omit(cols...)) -} - -func (t trainModelDo) Join(table schema.Tabler, on ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.Join(table, on...)) -} - -func (t trainModelDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.LeftJoin(table, on...)) -} - -func (t trainModelDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.RightJoin(table, on...)) -} - -func (t trainModelDo) Group(cols ...field.Expr) ITrainModelDo { - return t.withDO(t.DO.Group(cols...)) -} - -func (t trainModelDo) Having(conds ...gen.Condition) ITrainModelDo { - return t.withDO(t.DO.Having(conds...)) -} - -func (t trainModelDo) Limit(limit int) ITrainModelDo { - return t.withDO(t.DO.Limit(limit)) -} - -func (t trainModelDo) Offset(offset int) ITrainModelDo { - return t.withDO(t.DO.Offset(offset)) -} - -func (t trainModelDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainModelDo { - return t.withDO(t.DO.Scopes(funcs...)) -} - -func (t trainModelDo) Unscoped() ITrainModelDo { - return t.withDO(t.DO.Unscoped()) -} - -func (t trainModelDo) Create(values ...*model.TrainModel) error { - if len(values) == 0 { - return nil - } - return t.DO.Create(values) -} - -func (t trainModelDo) CreateInBatches(values []*model.TrainModel, batchSize int) error { - return t.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (t trainModelDo) Save(values ...*model.TrainModel) error { - if len(values) == 0 { - return nil - } - return t.DO.Save(values) -} - -func (t trainModelDo) First() (*model.TrainModel, error) { - if result, err := t.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.TrainModel), nil - } -} - -func (t trainModelDo) Take() (*model.TrainModel, error) { - if result, err := t.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.TrainModel), nil - } -} - -func (t trainModelDo) Last() (*model.TrainModel, error) { - if result, err := t.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.TrainModel), nil - } -} - -func (t trainModelDo) Find() ([]*model.TrainModel, error) { - result, err := t.DO.Find() - return result.([]*model.TrainModel), err -} - -func (t trainModelDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainModel, err error) { - buf := make([]*model.TrainModel, 0, batchSize) - err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (t trainModelDo) FindInBatches(result *[]*model.TrainModel, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return t.DO.FindInBatches(result, batchSize, fc) -} - -func (t trainModelDo) Attrs(attrs ...field.AssignExpr) ITrainModelDo { - return t.withDO(t.DO.Attrs(attrs...)) -} - -func (t trainModelDo) Assign(attrs ...field.AssignExpr) ITrainModelDo { - return t.withDO(t.DO.Assign(attrs...)) -} - -func (t trainModelDo) Joins(fields ...field.RelationField) ITrainModelDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Joins(_f)) - } - return &t -} - -func (t trainModelDo) Preload(fields ...field.RelationField) ITrainModelDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Preload(_f)) - } - return &t -} - -func (t trainModelDo) FirstOrInit() (*model.TrainModel, error) { - if result, err := t.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.TrainModel), nil - } -} - -func (t trainModelDo) FirstOrCreate() (*model.TrainModel, error) { - if result, err := t.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.TrainModel), nil - } -} - -func (t trainModelDo) FindByPage(offset int, limit int) (result []*model.TrainModel, count int64, err error) { - result, err = t.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = t.Offset(-1).Limit(-1).Count() - return -} - -func (t trainModelDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = t.Count() - if err != nil { - return - } - - err = t.Offset(offset).Limit(limit).Scan(result) - return -} - -func (t trainModelDo) Scan(result interface{}) (err error) { - return t.DO.Scan(result) -} - -func (t trainModelDo) Delete(models ...*model.TrainModel) (result gen.ResultInfo, err error) { - return t.DO.Delete(models) -} - -func (t *trainModelDo) withDO(do gen.Dao) *trainModelDo { - t.DO = *do.(*gen.DO) - return t -} diff --git a/db/dbquery/train_sensor.gen.go b/db/dbquery/train_sensor.gen.go deleted file mode 100644 index 5a905ab..0000000 --- a/db/dbquery/train_sensor.gen.go +++ /dev/null @@ -1,396 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newTrainSensor(db *gorm.DB, opts ...gen.DOOption) trainSensor { - _trainSensor := trainSensor{} - - _trainSensor.trainSensorDo.UseDB(db, opts...) - _trainSensor.trainSensorDo.UseModel(&model.TrainSensor{}) - - tableName := _trainSensor.trainSensorDo.TableName() - _trainSensor.ALL = field.NewAsterisk(tableName) - _trainSensor.ID = field.NewInt32(tableName, "id") - _trainSensor.Name = field.NewString(tableName, "name") - _trainSensor.AxialPosition = field.NewInt32(tableName, "axial_position") - _trainSensor.InstallDirection = field.NewString(tableName, "install_direction") - - _trainSensor.fillFieldMap() - - return _trainSensor -} - -type trainSensor struct { - trainSensorDo - - ALL field.Asterisk - ID field.Int32 - Name field.String // 名称 - AxialPosition field.Int32 // 速度传感器安装轴位,本端车前进方向的第几轴 - /* - 速度传感器安装方向, - 本端车前进方向的左侧或右侧 - */ - InstallDirection field.String - - fieldMap map[string]field.Expr -} - -func (t trainSensor) Table(newTableName string) *trainSensor { - t.trainSensorDo.UseTable(newTableName) - return t.updateTableName(newTableName) -} - -func (t trainSensor) As(alias string) *trainSensor { - t.trainSensorDo.DO = *(t.trainSensorDo.As(alias).(*gen.DO)) - return t.updateTableName(alias) -} - -func (t *trainSensor) updateTableName(table string) *trainSensor { - t.ALL = field.NewAsterisk(table) - t.ID = field.NewInt32(table, "id") - t.Name = field.NewString(table, "name") - t.AxialPosition = field.NewInt32(table, "axial_position") - t.InstallDirection = field.NewString(table, "install_direction") - - t.fillFieldMap() - - return t -} - -func (t *trainSensor) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := t.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (t *trainSensor) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 4) - t.fieldMap["id"] = t.ID - t.fieldMap["name"] = t.Name - t.fieldMap["axial_position"] = t.AxialPosition - t.fieldMap["install_direction"] = t.InstallDirection -} - -func (t trainSensor) clone(db *gorm.DB) trainSensor { - t.trainSensorDo.ReplaceConnPool(db.Statement.ConnPool) - return t -} - -func (t trainSensor) replaceDB(db *gorm.DB) trainSensor { - t.trainSensorDo.ReplaceDB(db) - return t -} - -type trainSensorDo struct{ gen.DO } - -type ITrainSensorDo interface { - gen.SubQuery - Debug() ITrainSensorDo - WithContext(ctx context.Context) ITrainSensorDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() ITrainSensorDo - WriteDB() ITrainSensorDo - As(alias string) gen.Dao - Session(config *gorm.Session) ITrainSensorDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) ITrainSensorDo - Not(conds ...gen.Condition) ITrainSensorDo - Or(conds ...gen.Condition) ITrainSensorDo - Select(conds ...field.Expr) ITrainSensorDo - Where(conds ...gen.Condition) ITrainSensorDo - Order(conds ...field.Expr) ITrainSensorDo - Distinct(cols ...field.Expr) ITrainSensorDo - Omit(cols ...field.Expr) ITrainSensorDo - Join(table schema.Tabler, on ...field.Expr) ITrainSensorDo - LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSensorDo - RightJoin(table schema.Tabler, on ...field.Expr) ITrainSensorDo - Group(cols ...field.Expr) ITrainSensorDo - Having(conds ...gen.Condition) ITrainSensorDo - Limit(limit int) ITrainSensorDo - Offset(offset int) ITrainSensorDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSensorDo - Unscoped() ITrainSensorDo - Create(values ...*model.TrainSensor) error - CreateInBatches(values []*model.TrainSensor, batchSize int) error - Save(values ...*model.TrainSensor) error - First() (*model.TrainSensor, error) - Take() (*model.TrainSensor, error) - Last() (*model.TrainSensor, error) - Find() ([]*model.TrainSensor, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSensor, err error) - FindInBatches(result *[]*model.TrainSensor, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.TrainSensor) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) ITrainSensorDo - Assign(attrs ...field.AssignExpr) ITrainSensorDo - Joins(fields ...field.RelationField) ITrainSensorDo - Preload(fields ...field.RelationField) ITrainSensorDo - FirstOrInit() (*model.TrainSensor, error) - FirstOrCreate() (*model.TrainSensor, error) - FindByPage(offset int, limit int) (result []*model.TrainSensor, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) ITrainSensorDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (t trainSensorDo) Debug() ITrainSensorDo { - return t.withDO(t.DO.Debug()) -} - -func (t trainSensorDo) WithContext(ctx context.Context) ITrainSensorDo { - return t.withDO(t.DO.WithContext(ctx)) -} - -func (t trainSensorDo) ReadDB() ITrainSensorDo { - return t.Clauses(dbresolver.Read) -} - -func (t trainSensorDo) WriteDB() ITrainSensorDo { - return t.Clauses(dbresolver.Write) -} - -func (t trainSensorDo) Session(config *gorm.Session) ITrainSensorDo { - return t.withDO(t.DO.Session(config)) -} - -func (t trainSensorDo) Clauses(conds ...clause.Expression) ITrainSensorDo { - return t.withDO(t.DO.Clauses(conds...)) -} - -func (t trainSensorDo) Returning(value interface{}, columns ...string) ITrainSensorDo { - return t.withDO(t.DO.Returning(value, columns...)) -} - -func (t trainSensorDo) Not(conds ...gen.Condition) ITrainSensorDo { - return t.withDO(t.DO.Not(conds...)) -} - -func (t trainSensorDo) Or(conds ...gen.Condition) ITrainSensorDo { - return t.withDO(t.DO.Or(conds...)) -} - -func (t trainSensorDo) Select(conds ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.Select(conds...)) -} - -func (t trainSensorDo) Where(conds ...gen.Condition) ITrainSensorDo { - return t.withDO(t.DO.Where(conds...)) -} - -func (t trainSensorDo) Order(conds ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.Order(conds...)) -} - -func (t trainSensorDo) Distinct(cols ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.Distinct(cols...)) -} - -func (t trainSensorDo) Omit(cols ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.Omit(cols...)) -} - -func (t trainSensorDo) Join(table schema.Tabler, on ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.Join(table, on...)) -} - -func (t trainSensorDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.LeftJoin(table, on...)) -} - -func (t trainSensorDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.RightJoin(table, on...)) -} - -func (t trainSensorDo) Group(cols ...field.Expr) ITrainSensorDo { - return t.withDO(t.DO.Group(cols...)) -} - -func (t trainSensorDo) Having(conds ...gen.Condition) ITrainSensorDo { - return t.withDO(t.DO.Having(conds...)) -} - -func (t trainSensorDo) Limit(limit int) ITrainSensorDo { - return t.withDO(t.DO.Limit(limit)) -} - -func (t trainSensorDo) Offset(offset int) ITrainSensorDo { - return t.withDO(t.DO.Offset(offset)) -} - -func (t trainSensorDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSensorDo { - return t.withDO(t.DO.Scopes(funcs...)) -} - -func (t trainSensorDo) Unscoped() ITrainSensorDo { - return t.withDO(t.DO.Unscoped()) -} - -func (t trainSensorDo) Create(values ...*model.TrainSensor) error { - if len(values) == 0 { - return nil - } - return t.DO.Create(values) -} - -func (t trainSensorDo) CreateInBatches(values []*model.TrainSensor, batchSize int) error { - return t.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (t trainSensorDo) Save(values ...*model.TrainSensor) error { - if len(values) == 0 { - return nil - } - return t.DO.Save(values) -} - -func (t trainSensorDo) First() (*model.TrainSensor, error) { - if result, err := t.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.TrainSensor), nil - } -} - -func (t trainSensorDo) Take() (*model.TrainSensor, error) { - if result, err := t.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.TrainSensor), nil - } -} - -func (t trainSensorDo) Last() (*model.TrainSensor, error) { - if result, err := t.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.TrainSensor), nil - } -} - -func (t trainSensorDo) Find() ([]*model.TrainSensor, error) { - result, err := t.DO.Find() - return result.([]*model.TrainSensor), err -} - -func (t trainSensorDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSensor, err error) { - buf := make([]*model.TrainSensor, 0, batchSize) - err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (t trainSensorDo) FindInBatches(result *[]*model.TrainSensor, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return t.DO.FindInBatches(result, batchSize, fc) -} - -func (t trainSensorDo) Attrs(attrs ...field.AssignExpr) ITrainSensorDo { - return t.withDO(t.DO.Attrs(attrs...)) -} - -func (t trainSensorDo) Assign(attrs ...field.AssignExpr) ITrainSensorDo { - return t.withDO(t.DO.Assign(attrs...)) -} - -func (t trainSensorDo) Joins(fields ...field.RelationField) ITrainSensorDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Joins(_f)) - } - return &t -} - -func (t trainSensorDo) Preload(fields ...field.RelationField) ITrainSensorDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Preload(_f)) - } - return &t -} - -func (t trainSensorDo) FirstOrInit() (*model.TrainSensor, error) { - if result, err := t.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.TrainSensor), nil - } -} - -func (t trainSensorDo) FirstOrCreate() (*model.TrainSensor, error) { - if result, err := t.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.TrainSensor), nil - } -} - -func (t trainSensorDo) FindByPage(offset int, limit int) (result []*model.TrainSensor, count int64, err error) { - result, err = t.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = t.Offset(-1).Limit(-1).Count() - return -} - -func (t trainSensorDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = t.Count() - if err != nil { - return - } - - err = t.Offset(offset).Limit(limit).Scan(result) - return -} - -func (t trainSensorDo) Scan(result interface{}) (err error) { - return t.DO.Scan(result) -} - -func (t trainSensorDo) Delete(models ...*model.TrainSensor) (result gen.ResultInfo, err error) { - return t.DO.Delete(models) -} - -func (t *trainSensorDo) withDO(do gen.Dao) *trainSensorDo { - t.DO = *do.(*gen.DO) - return t -} diff --git a/db/dbquery/train_size.gen.go b/db/dbquery/train_size.gen.go deleted file mode 100644 index cb1e62a..0000000 --- a/db/dbquery/train_size.gen.go +++ /dev/null @@ -1,396 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newTrainSize(db *gorm.DB, opts ...gen.DOOption) trainSize { - _trainSize := trainSize{} - - _trainSize.trainSizeDo.UseDB(db, opts...) - _trainSize.trainSizeDo.UseModel(&model.TrainSize{}) - - tableName := _trainSize.trainSizeDo.TableName() - _trainSize.ALL = field.NewAsterisk(tableName) - _trainSize.ID = field.NewInt32(tableName, "id") - _trainSize.Name = field.NewString(tableName, "name") - _trainSize.CarriageLength = field.NewInt32(tableName, "carriage_length") - _trainSize.TotalLength = field.NewInt32(tableName, "total_length") - _trainSize.Description = field.NewString(tableName, "description") - - _trainSize.fillFieldMap() - - return _trainSize -} - -type trainSize struct { - trainSizeDo - - ALL field.Asterisk - ID field.Int32 // 主键 - Name field.String // 名称 - CarriageLength field.Int32 // 列车车厢长度 - TotalLength field.Int32 // 总长度 - Description field.String // 其他描述内容 - - fieldMap map[string]field.Expr -} - -func (t trainSize) Table(newTableName string) *trainSize { - t.trainSizeDo.UseTable(newTableName) - return t.updateTableName(newTableName) -} - -func (t trainSize) As(alias string) *trainSize { - t.trainSizeDo.DO = *(t.trainSizeDo.As(alias).(*gen.DO)) - return t.updateTableName(alias) -} - -func (t *trainSize) updateTableName(table string) *trainSize { - t.ALL = field.NewAsterisk(table) - t.ID = field.NewInt32(table, "id") - t.Name = field.NewString(table, "name") - t.CarriageLength = field.NewInt32(table, "carriage_length") - t.TotalLength = field.NewInt32(table, "total_length") - t.Description = field.NewString(table, "description") - - t.fillFieldMap() - - return t -} - -func (t *trainSize) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := t.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (t *trainSize) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 5) - t.fieldMap["id"] = t.ID - t.fieldMap["name"] = t.Name - t.fieldMap["carriage_length"] = t.CarriageLength - t.fieldMap["total_length"] = t.TotalLength - t.fieldMap["description"] = t.Description -} - -func (t trainSize) clone(db *gorm.DB) trainSize { - t.trainSizeDo.ReplaceConnPool(db.Statement.ConnPool) - return t -} - -func (t trainSize) replaceDB(db *gorm.DB) trainSize { - t.trainSizeDo.ReplaceDB(db) - return t -} - -type trainSizeDo struct{ gen.DO } - -type ITrainSizeDo interface { - gen.SubQuery - Debug() ITrainSizeDo - WithContext(ctx context.Context) ITrainSizeDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() ITrainSizeDo - WriteDB() ITrainSizeDo - As(alias string) gen.Dao - Session(config *gorm.Session) ITrainSizeDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) ITrainSizeDo - Not(conds ...gen.Condition) ITrainSizeDo - Or(conds ...gen.Condition) ITrainSizeDo - Select(conds ...field.Expr) ITrainSizeDo - Where(conds ...gen.Condition) ITrainSizeDo - Order(conds ...field.Expr) ITrainSizeDo - Distinct(cols ...field.Expr) ITrainSizeDo - Omit(cols ...field.Expr) ITrainSizeDo - Join(table schema.Tabler, on ...field.Expr) ITrainSizeDo - LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo - RightJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo - Group(cols ...field.Expr) ITrainSizeDo - Having(conds ...gen.Condition) ITrainSizeDo - Limit(limit int) ITrainSizeDo - Offset(offset int) ITrainSizeDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSizeDo - Unscoped() ITrainSizeDo - Create(values ...*model.TrainSize) error - CreateInBatches(values []*model.TrainSize, batchSize int) error - Save(values ...*model.TrainSize) error - First() (*model.TrainSize, error) - Take() (*model.TrainSize, error) - Last() (*model.TrainSize, error) - Find() ([]*model.TrainSize, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSize, err error) - FindInBatches(result *[]*model.TrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.TrainSize) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) ITrainSizeDo - Assign(attrs ...field.AssignExpr) ITrainSizeDo - Joins(fields ...field.RelationField) ITrainSizeDo - Preload(fields ...field.RelationField) ITrainSizeDo - FirstOrInit() (*model.TrainSize, error) - FirstOrCreate() (*model.TrainSize, error) - FindByPage(offset int, limit int) (result []*model.TrainSize, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) ITrainSizeDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (t trainSizeDo) Debug() ITrainSizeDo { - return t.withDO(t.DO.Debug()) -} - -func (t trainSizeDo) WithContext(ctx context.Context) ITrainSizeDo { - return t.withDO(t.DO.WithContext(ctx)) -} - -func (t trainSizeDo) ReadDB() ITrainSizeDo { - return t.Clauses(dbresolver.Read) -} - -func (t trainSizeDo) WriteDB() ITrainSizeDo { - return t.Clauses(dbresolver.Write) -} - -func (t trainSizeDo) Session(config *gorm.Session) ITrainSizeDo { - return t.withDO(t.DO.Session(config)) -} - -func (t trainSizeDo) Clauses(conds ...clause.Expression) ITrainSizeDo { - return t.withDO(t.DO.Clauses(conds...)) -} - -func (t trainSizeDo) Returning(value interface{}, columns ...string) ITrainSizeDo { - return t.withDO(t.DO.Returning(value, columns...)) -} - -func (t trainSizeDo) Not(conds ...gen.Condition) ITrainSizeDo { - return t.withDO(t.DO.Not(conds...)) -} - -func (t trainSizeDo) Or(conds ...gen.Condition) ITrainSizeDo { - return t.withDO(t.DO.Or(conds...)) -} - -func (t trainSizeDo) Select(conds ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.Select(conds...)) -} - -func (t trainSizeDo) Where(conds ...gen.Condition) ITrainSizeDo { - return t.withDO(t.DO.Where(conds...)) -} - -func (t trainSizeDo) Order(conds ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.Order(conds...)) -} - -func (t trainSizeDo) Distinct(cols ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.Distinct(cols...)) -} - -func (t trainSizeDo) Omit(cols ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.Omit(cols...)) -} - -func (t trainSizeDo) Join(table schema.Tabler, on ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.Join(table, on...)) -} - -func (t trainSizeDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.LeftJoin(table, on...)) -} - -func (t trainSizeDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.RightJoin(table, on...)) -} - -func (t trainSizeDo) Group(cols ...field.Expr) ITrainSizeDo { - return t.withDO(t.DO.Group(cols...)) -} - -func (t trainSizeDo) Having(conds ...gen.Condition) ITrainSizeDo { - return t.withDO(t.DO.Having(conds...)) -} - -func (t trainSizeDo) Limit(limit int) ITrainSizeDo { - return t.withDO(t.DO.Limit(limit)) -} - -func (t trainSizeDo) Offset(offset int) ITrainSizeDo { - return t.withDO(t.DO.Offset(offset)) -} - -func (t trainSizeDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainSizeDo { - return t.withDO(t.DO.Scopes(funcs...)) -} - -func (t trainSizeDo) Unscoped() ITrainSizeDo { - return t.withDO(t.DO.Unscoped()) -} - -func (t trainSizeDo) Create(values ...*model.TrainSize) error { - if len(values) == 0 { - return nil - } - return t.DO.Create(values) -} - -func (t trainSizeDo) CreateInBatches(values []*model.TrainSize, batchSize int) error { - return t.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (t trainSizeDo) Save(values ...*model.TrainSize) error { - if len(values) == 0 { - return nil - } - return t.DO.Save(values) -} - -func (t trainSizeDo) First() (*model.TrainSize, error) { - if result, err := t.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.TrainSize), nil - } -} - -func (t trainSizeDo) Take() (*model.TrainSize, error) { - if result, err := t.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.TrainSize), nil - } -} - -func (t trainSizeDo) Last() (*model.TrainSize, error) { - if result, err := t.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.TrainSize), nil - } -} - -func (t trainSizeDo) Find() ([]*model.TrainSize, error) { - result, err := t.DO.Find() - return result.([]*model.TrainSize), err -} - -func (t trainSizeDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainSize, err error) { - buf := make([]*model.TrainSize, 0, batchSize) - err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (t trainSizeDo) FindInBatches(result *[]*model.TrainSize, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return t.DO.FindInBatches(result, batchSize, fc) -} - -func (t trainSizeDo) Attrs(attrs ...field.AssignExpr) ITrainSizeDo { - return t.withDO(t.DO.Attrs(attrs...)) -} - -func (t trainSizeDo) Assign(attrs ...field.AssignExpr) ITrainSizeDo { - return t.withDO(t.DO.Assign(attrs...)) -} - -func (t trainSizeDo) Joins(fields ...field.RelationField) ITrainSizeDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Joins(_f)) - } - return &t -} - -func (t trainSizeDo) Preload(fields ...field.RelationField) ITrainSizeDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Preload(_f)) - } - return &t -} - -func (t trainSizeDo) FirstOrInit() (*model.TrainSize, error) { - if result, err := t.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.TrainSize), nil - } -} - -func (t trainSizeDo) FirstOrCreate() (*model.TrainSize, error) { - if result, err := t.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.TrainSize), nil - } -} - -func (t trainSizeDo) FindByPage(offset int, limit int) (result []*model.TrainSize, count int64, err error) { - result, err = t.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = t.Offset(-1).Limit(-1).Count() - return -} - -func (t trainSizeDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = t.Count() - if err != nil { - return - } - - err = t.Offset(offset).Limit(limit).Scan(result) - return -} - -func (t trainSizeDo) Scan(result interface{}) (err error) { - return t.DO.Scan(result) -} - -func (t trainSizeDo) Delete(models ...*model.TrainSize) (result gen.ResultInfo, err error) { - return t.DO.Delete(models) -} - -func (t *trainSizeDo) withDO(do gen.Dao) *trainSizeDo { - t.DO = *do.(*gen.DO) - return t -} diff --git a/db/dbquery/train_wheel.gen.go b/db/dbquery/train_wheel.gen.go deleted file mode 100644 index e6d1516..0000000 --- a/db/dbquery/train_wheel.gen.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package dbquery - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "joylink.club/bj-rtsts-server/db/model" -) - -func newTrainWheel(db *gorm.DB, opts ...gen.DOOption) trainWheel { - _trainWheel := trainWheel{} - - _trainWheel.trainWheelDo.UseDB(db, opts...) - _trainWheel.trainWheelDo.UseModel(&model.TrainWheel{}) - - tableName := _trainWheel.trainWheelDo.TableName() - _trainWheel.ALL = field.NewAsterisk(tableName) - _trainWheel.ID = field.NewInt32(tableName, "id") - _trainWheel.MinDiameter = field.NewInt32(tableName, "min_diameter") - _trainWheel.MaxDiameter = field.NewInt32(tableName, "max_diameter") - _trainWheel.Name = field.NewString(tableName, "name") - - _trainWheel.fillFieldMap() - - return _trainWheel -} - -type trainWheel struct { - trainWheelDo - - ALL field.Asterisk - ID field.Int32 - MinDiameter field.Int32 // 车轮的最小直径(mm) - MaxDiameter field.Int32 // 车轮的最大直径(mm) - Name field.String // 名称 - - fieldMap map[string]field.Expr -} - -func (t trainWheel) Table(newTableName string) *trainWheel { - t.trainWheelDo.UseTable(newTableName) - return t.updateTableName(newTableName) -} - -func (t trainWheel) As(alias string) *trainWheel { - t.trainWheelDo.DO = *(t.trainWheelDo.As(alias).(*gen.DO)) - return t.updateTableName(alias) -} - -func (t *trainWheel) updateTableName(table string) *trainWheel { - t.ALL = field.NewAsterisk(table) - t.ID = field.NewInt32(table, "id") - t.MinDiameter = field.NewInt32(table, "min_diameter") - t.MaxDiameter = field.NewInt32(table, "max_diameter") - t.Name = field.NewString(table, "name") - - t.fillFieldMap() - - return t -} - -func (t *trainWheel) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := t.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (t *trainWheel) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 4) - t.fieldMap["id"] = t.ID - t.fieldMap["min_diameter"] = t.MinDiameter - t.fieldMap["max_diameter"] = t.MaxDiameter - t.fieldMap["name"] = t.Name -} - -func (t trainWheel) clone(db *gorm.DB) trainWheel { - t.trainWheelDo.ReplaceConnPool(db.Statement.ConnPool) - return t -} - -func (t trainWheel) replaceDB(db *gorm.DB) trainWheel { - t.trainWheelDo.ReplaceDB(db) - return t -} - -type trainWheelDo struct{ gen.DO } - -type ITrainWheelDo interface { - gen.SubQuery - Debug() ITrainWheelDo - WithContext(ctx context.Context) ITrainWheelDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() ITrainWheelDo - WriteDB() ITrainWheelDo - As(alias string) gen.Dao - Session(config *gorm.Session) ITrainWheelDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) ITrainWheelDo - Not(conds ...gen.Condition) ITrainWheelDo - Or(conds ...gen.Condition) ITrainWheelDo - Select(conds ...field.Expr) ITrainWheelDo - Where(conds ...gen.Condition) ITrainWheelDo - Order(conds ...field.Expr) ITrainWheelDo - Distinct(cols ...field.Expr) ITrainWheelDo - Omit(cols ...field.Expr) ITrainWheelDo - Join(table schema.Tabler, on ...field.Expr) ITrainWheelDo - LeftJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDo - RightJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDo - Group(cols ...field.Expr) ITrainWheelDo - Having(conds ...gen.Condition) ITrainWheelDo - Limit(limit int) ITrainWheelDo - Offset(offset int) ITrainWheelDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainWheelDo - Unscoped() ITrainWheelDo - Create(values ...*model.TrainWheel) error - CreateInBatches(values []*model.TrainWheel, batchSize int) error - Save(values ...*model.TrainWheel) error - First() (*model.TrainWheel, error) - Take() (*model.TrainWheel, error) - Last() (*model.TrainWheel, error) - Find() ([]*model.TrainWheel, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainWheel, err error) - FindInBatches(result *[]*model.TrainWheel, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.TrainWheel) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) ITrainWheelDo - Assign(attrs ...field.AssignExpr) ITrainWheelDo - Joins(fields ...field.RelationField) ITrainWheelDo - Preload(fields ...field.RelationField) ITrainWheelDo - FirstOrInit() (*model.TrainWheel, error) - FirstOrCreate() (*model.TrainWheel, error) - FindByPage(offset int, limit int) (result []*model.TrainWheel, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) ITrainWheelDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (t trainWheelDo) Debug() ITrainWheelDo { - return t.withDO(t.DO.Debug()) -} - -func (t trainWheelDo) WithContext(ctx context.Context) ITrainWheelDo { - return t.withDO(t.DO.WithContext(ctx)) -} - -func (t trainWheelDo) ReadDB() ITrainWheelDo { - return t.Clauses(dbresolver.Read) -} - -func (t trainWheelDo) WriteDB() ITrainWheelDo { - return t.Clauses(dbresolver.Write) -} - -func (t trainWheelDo) Session(config *gorm.Session) ITrainWheelDo { - return t.withDO(t.DO.Session(config)) -} - -func (t trainWheelDo) Clauses(conds ...clause.Expression) ITrainWheelDo { - return t.withDO(t.DO.Clauses(conds...)) -} - -func (t trainWheelDo) Returning(value interface{}, columns ...string) ITrainWheelDo { - return t.withDO(t.DO.Returning(value, columns...)) -} - -func (t trainWheelDo) Not(conds ...gen.Condition) ITrainWheelDo { - return t.withDO(t.DO.Not(conds...)) -} - -func (t trainWheelDo) Or(conds ...gen.Condition) ITrainWheelDo { - return t.withDO(t.DO.Or(conds...)) -} - -func (t trainWheelDo) Select(conds ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.Select(conds...)) -} - -func (t trainWheelDo) Where(conds ...gen.Condition) ITrainWheelDo { - return t.withDO(t.DO.Where(conds...)) -} - -func (t trainWheelDo) Order(conds ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.Order(conds...)) -} - -func (t trainWheelDo) Distinct(cols ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.Distinct(cols...)) -} - -func (t trainWheelDo) Omit(cols ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.Omit(cols...)) -} - -func (t trainWheelDo) Join(table schema.Tabler, on ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.Join(table, on...)) -} - -func (t trainWheelDo) LeftJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.LeftJoin(table, on...)) -} - -func (t trainWheelDo) RightJoin(table schema.Tabler, on ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.RightJoin(table, on...)) -} - -func (t trainWheelDo) Group(cols ...field.Expr) ITrainWheelDo { - return t.withDO(t.DO.Group(cols...)) -} - -func (t trainWheelDo) Having(conds ...gen.Condition) ITrainWheelDo { - return t.withDO(t.DO.Having(conds...)) -} - -func (t trainWheelDo) Limit(limit int) ITrainWheelDo { - return t.withDO(t.DO.Limit(limit)) -} - -func (t trainWheelDo) Offset(offset int) ITrainWheelDo { - return t.withDO(t.DO.Offset(offset)) -} - -func (t trainWheelDo) Scopes(funcs ...func(gen.Dao) gen.Dao) ITrainWheelDo { - return t.withDO(t.DO.Scopes(funcs...)) -} - -func (t trainWheelDo) Unscoped() ITrainWheelDo { - return t.withDO(t.DO.Unscoped()) -} - -func (t trainWheelDo) Create(values ...*model.TrainWheel) error { - if len(values) == 0 { - return nil - } - return t.DO.Create(values) -} - -func (t trainWheelDo) CreateInBatches(values []*model.TrainWheel, batchSize int) error { - return t.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (t trainWheelDo) Save(values ...*model.TrainWheel) error { - if len(values) == 0 { - return nil - } - return t.DO.Save(values) -} - -func (t trainWheelDo) First() (*model.TrainWheel, error) { - if result, err := t.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.TrainWheel), nil - } -} - -func (t trainWheelDo) Take() (*model.TrainWheel, error) { - if result, err := t.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.TrainWheel), nil - } -} - -func (t trainWheelDo) Last() (*model.TrainWheel, error) { - if result, err := t.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.TrainWheel), nil - } -} - -func (t trainWheelDo) Find() ([]*model.TrainWheel, error) { - result, err := t.DO.Find() - return result.([]*model.TrainWheel), err -} - -func (t trainWheelDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.TrainWheel, err error) { - buf := make([]*model.TrainWheel, 0, batchSize) - err = t.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (t trainWheelDo) FindInBatches(result *[]*model.TrainWheel, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return t.DO.FindInBatches(result, batchSize, fc) -} - -func (t trainWheelDo) Attrs(attrs ...field.AssignExpr) ITrainWheelDo { - return t.withDO(t.DO.Attrs(attrs...)) -} - -func (t trainWheelDo) Assign(attrs ...field.AssignExpr) ITrainWheelDo { - return t.withDO(t.DO.Assign(attrs...)) -} - -func (t trainWheelDo) Joins(fields ...field.RelationField) ITrainWheelDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Joins(_f)) - } - return &t -} - -func (t trainWheelDo) Preload(fields ...field.RelationField) ITrainWheelDo { - for _, _f := range fields { - t = *t.withDO(t.DO.Preload(_f)) - } - return &t -} - -func (t trainWheelDo) FirstOrInit() (*model.TrainWheel, error) { - if result, err := t.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.TrainWheel), nil - } -} - -func (t trainWheelDo) FirstOrCreate() (*model.TrainWheel, error) { - if result, err := t.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.TrainWheel), nil - } -} - -func (t trainWheelDo) FindByPage(offset int, limit int) (result []*model.TrainWheel, count int64, err error) { - result, err = t.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = t.Offset(-1).Limit(-1).Count() - return -} - -func (t trainWheelDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = t.Count() - if err != nil { - return - } - - err = t.Offset(offset).Limit(limit).Scan(result) - return -} - -func (t trainWheelDo) Scan(result interface{}) (err error) { - return t.DO.Scan(result) -} - -func (t trainWheelDo) Delete(models ...*model.TrainWheel) (result gen.ResultInfo, err error) { - return t.DO.Delete(models) -} - -func (t *trainWheelDo) withDO(do gen.Dao) *trainWheelDo { - t.DO = *do.(*gen.DO) - return t -} diff --git a/db/model/project_train_size.gen.go b/db/model/project_train_size.gen.go deleted file mode 100644 index 7af082b..0000000 --- a/db/model/project_train_size.gen.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -const TableNameProjectTrainSize = "project_train_size" - -// ProjectTrainSize mapped from table -type ProjectTrainSize struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 - Pid int32 `gorm:"column:pid;comment:项目主键" json:"pid"` // 项目主键 - Sid int32 `gorm:"column:sid;comment:列车尺寸主键" json:"sid"` // 列车尺寸主键 -} - -// TableName ProjectTrainSize's table name -func (*ProjectTrainSize) TableName() string { - return TableNameProjectTrainSize -} diff --git a/db/model/project_train_size_link.gen.go b/db/model/project_train_size_link.gen.go deleted file mode 100644 index c553cf6..0000000 --- a/db/model/project_train_size_link.gen.go +++ /dev/null @@ -1,19 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -const TableNameProjectTrainSizeLink = "project_train_size_link" - -// ProjectTrainSizeLink mapped from table -type ProjectTrainSizeLink struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 - Pid int32 `gorm:"column:pid;comment:项目主键" json:"pid"` // 项目主键 - Sid int32 `gorm:"column:sid;comment:列车尺寸主键" json:"sid"` // 列车尺寸主键 -} - -// TableName ProjectTrainSizeLink's table name -func (*ProjectTrainSizeLink) TableName() string { - return TableNameProjectTrainSizeLink -} diff --git a/db/model/published_gi.gen.go b/db/model/published_gi.gen.go deleted file mode 100644 index 707ddcb..0000000 --- a/db/model/published_gi.gen.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -import ( - "time" -) - -const TableNamePublishedGi = "published_gi" - -// PublishedGi mapped from table -type PublishedGi struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:id" json:"id"` // id - Name string `gorm:"column:name;not null;comment:发布图形界面名称" json:"name"` // 发布图形界面名称 - Proto []byte `gorm:"column:proto;not null;comment:图形界面数据" json:"proto"` // 图形界面数据 - UserID int32 `gorm:"column:user_id;not null;comment:发布用户id" json:"user_id"` // 发布用户id - PublishAt time.Time `gorm:"column:publish_at;not null;comment:发布时间" json:"publish_at"` // 发布时间 - Category string `gorm:"column:category;comment:厂家信息" json:"category"` // 厂家信息 - Note string `gorm:"column:note;comment:发布描述" json:"note"` // 发布描述 - Status int32 `gorm:"column:status;default:1;comment:显示状态" json:"status"` // 显示状态 - Type int32 `gorm:"column:type;comment:数据类型" json:"type"` // 数据类型 -} - -// TableName PublishedGi's table name -func (*PublishedGi) TableName() string { - return TableNamePublishedGi -} diff --git a/db/model/train_model.gen.go b/db/model/train_model.gen.go deleted file mode 100644 index 7f13f54..0000000 --- a/db/model/train_model.gen.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -import ( - "time" -) - -const TableNameTrainModel = "train_model" - -// TrainModel mapped from table -type TrainModel struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` - Name string `gorm:"column:name;comment:组次名称" json:"name"` // 组次名称 - CreatedAt time.Time `gorm:"column:created_at;comment:创建时间" json:"created_at"` // 创建时间 - UpdateAt time.Time `gorm:"column:update_at;comment:更新时间" json:"update_at"` // 更新时间 -} - -// TableName TrainModel's table name -func (*TrainModel) TableName() string { - return TableNameTrainModel -} diff --git a/db/model/train_sensor.gen.go b/db/model/train_sensor.gen.go deleted file mode 100644 index 87da0fc..0000000 --- a/db/model/train_sensor.gen.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -const TableNameTrainSensor = "train_sensor" - -// TrainSensor mapped from table -type TrainSensor struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` - Name string `gorm:"column:name;comment:名称" json:"name"` // 名称 - AxialPosition int32 `gorm:"column:axial_position;comment:速度传感器安装轴位,本端车前进方向的第几轴" json:"axial_position"` // 速度传感器安装轴位,本端车前进方向的第几轴 - /* - 速度传感器安装方向, - 本端车前进方向的左侧或右侧 - */ - InstallDirection string `gorm:"column:install_direction;comment:速度传感器安装方向,\n本端车前进方向的左侧或右侧" json:"install_direction"` -} - -// TableName TrainSensor's table name -func (*TrainSensor) TableName() string { - return TableNameTrainSensor -} diff --git a/db/model/train_size.gen.go b/db/model/train_size.gen.go deleted file mode 100644 index 37b0b0f..0000000 --- a/db/model/train_size.gen.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -const TableNameTrainSize = "train_size" - -// TrainSize mapped from table -type TrainSize struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true;comment:主键" json:"id"` // 主键 - Name string `gorm:"column:name;comment:名称" json:"name"` // 名称 - CarriageLength int32 `gorm:"column:carriage_length;comment:列车车厢长度" json:"carriage_length"` // 列车车厢长度 - TotalLength int32 `gorm:"column:total_length;comment:总长度" json:"total_length"` // 总长度 - Description string `gorm:"column:description;comment:其他描述内容" json:"description"` // 其他描述内容 -} - -// TableName TrainSize's table name -func (*TrainSize) TableName() string { - return TableNameTrainSize -} diff --git a/db/model/train_wheel.gen.go b/db/model/train_wheel.gen.go deleted file mode 100644 index 880ffa6..0000000 --- a/db/model/train_wheel.gen.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package model - -const TableNameTrainWheel = "train_wheel" - -// TrainWheel mapped from table -type TrainWheel struct { - ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"` - MinDiameter int32 `gorm:"column:min_diameter;comment:车轮的最小直径(mm)" json:"min_diameter"` // 车轮的最小直径(mm) - MaxDiameter int32 `gorm:"column:max_diameter;comment:车轮的最大直径(mm)" json:"max_diameter"` // 车轮的最大直径(mm) - Name string `gorm:"column:name;comment:名称" json:"name"` // 名称 -} - -// TableName TrainWheel's table name -func (*TrainWheel) TableName() string { - return TableNameTrainWheel -} diff --git a/dto/projectLink.go b/dto/projectLink.go index 48fbd5e..d25ff02 100644 --- a/dto/projectLink.go +++ b/dto/projectLink.go @@ -7,15 +7,11 @@ type ProjectLinkRspDto struct { Name string `json:"name" form:"name"` Code string `json:"code" form:"code"` PublishedGiLinks []*PublishedGiLinkDto `json:"mapInfoLinks" form:"mapInfoLinks"` - // TODO:前端修改完成后删除 - TrainSizeLinks []*TrainSizeDto `json:"trainSizeLinks" form:"trainSizeLinks"` } type ProjectLinkReqDto struct { Pid int32 `json:"pid" form:"pid"` Mids []*int32 `json:"mids" form:"mids"` - // TODO:前端修改完成后删除 - Sids []*int32 `json:"sids" form:"sids"` } type PublishedGiLinkDto struct { @@ -31,8 +27,6 @@ func ConvertProjectLink(gi *model.Project) *ProjectLinkRspDto { Name: gi.Name, Code: gi.Code, PublishedGiLinks: []*PublishedGiLinkDto{}, - // TODO:前端修改完成后删除 - TrainSizeLinks: []*TrainSizeDto{}, } } diff --git a/dto/publishedGi/publishedGi.go b/dto/publishedGi/publishedGi.go deleted file mode 100644 index 5457e24..0000000 --- a/dto/publishedGi/publishedGi.go +++ /dev/null @@ -1,66 +0,0 @@ -package publishedGi - -import ( - "joylink.club/bj-rtsts-server/db/model" - "joylink.club/bj-rtsts-server/dto" -) - -type PublishedGiReqDto struct { - dto.PageQueryDto - Name string `json:"name" form:"name"` -} - -type PublishedGiListReqDto struct { - Name string `json:"name" form:"name"` - Type int32 `json:"type" form:"type"` - Category string `json:"category" form:"category"` - - Time dto.JsonTime `json:"time" form:"time" time_format:"2006-01-02 15:04:05"` -} - -type PublishReqDto struct { - //发布后的名称 - Name string `json:"name" form:"name"` - //草稿数据的id - DraftId int32 `json:"draftId" form:"draftId"` - Note string `json:"note" form:"note"` - //Time dto.JsonTime `json:"time" form:"time"` - ////是否覆盖同名数据 - //Overwrite bool `json:"overwrite" form:"overwrite"` -} - -type PublishedGiDto struct { - ID int32 `json:"id"` - Name string `json:"name"` - Proto []byte `json:"proto"` - UserID int32 `json:"userID"` - Note string `json:"note"` - Category string `json:"category" form:"category"` - PublishAt dto.JsonTime `json:"publishAt" time_format:"2006-01-02 15:04:05"` -} - -// PublishedGiSingleQueryDto 单个查询发布地图数据 -type PublishedGiSingleQueryDto struct { - Name string `json:"name" form:"name"` - Detail bool `json:"detail" form:"detail"` -} - -func ConvertFrom(gi *model.PublishedGi) *PublishedGiDto { - return &PublishedGiDto{ - ID: gi.ID, - Name: gi.Name, - Proto: gi.Proto, - Note: gi.Note, - UserID: gi.UserID, - Category: gi.Category, - PublishAt: dto.JsonTime(gi.PublishAt), - } -} - -func ConvertFromSlice(giSlice []*model.PublishedGi) []*PublishedGiDto { - var result []*PublishedGiDto - for _, gi := range giSlice { - result = append(result, ConvertFrom(gi)) - } - return result -} diff --git a/dto/trainManage.go b/dto/trainManage.go index d05c5c1..cb2f143 100644 --- a/dto/trainManage.go +++ b/dto/trainManage.go @@ -65,47 +65,3 @@ func ConvertTrainInfoFromDto(t *TrainInfoDto) *model.TrainInfo { info.Proto = b return info } - -// TODO: 前端修改完毕后以下代码全部删除 -type PageTrainManageReqDto struct { - PageQueryDto - Name string `json:"name" form:"name"` -} - -type TrainManageReqDto struct { - Name string `json:"name" form:"name"` -} - -type TrainModelDto struct { - Id int32 `json:"id" form:"id"` - Name string `json:"name" form:"name"` -} - -type TrainSizeDto struct { - Id int32 `json:"id" form:"id"` - Name string `json:"name" form:"name"` - CarriageLength int32 `json:"carriage_length" form:"carriage_length"` - TotalLength int32 `json:"total_length" form:"total_length"` - Description string `json:"description" form:"description"` -} - -func ConvertFromTrainSizeDto(giSlice []*model.TrainSize) []*TrainSizeDto { - var result []*TrainSizeDto - for _, gi := range giSlice { - result = append(result, &TrainSizeDto{ - Id: gi.ID, - Name: gi.Name, - CarriageLength: gi.CarriageLength, - TotalLength: gi.TotalLength, - Description: gi.Description, - }) - } - return result -} - -type TrainWheelDto struct { - Id int32 `json:"id" form:"id"` - Name string `json:"name" form:"name"` - MinDiameter int32 `json:"min_diameter" form:"min_diameter"` - MaxDiameter int32 `json:"max_diameter" form:"max_diameter"` -} diff --git a/service/projectLink.go b/service/projectLink.go index e3eaa23..f9b7d55 100644 --- a/service/projectLink.go +++ b/service/projectLink.go @@ -15,9 +15,6 @@ func QueryProjectLinkInfo(id int32) *dto.ProjectLinkRspDto { projectLink := dto.ConvertProjectLink(pro) // 关联地图列表 projectLink.PublishedGiLinks = dto.ConvertFromPublishedGiLink(QueryProjectPublished(id)) - // TODO:前端修改完成后删除 - // 关联列车尺寸列表 - projectLink.TrainSizeLinks = dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(id)) return projectLink } @@ -25,11 +22,6 @@ func QueryProjectLinkInfo(id int32) *dto.ProjectLinkRspDto { func UpdateProjectLink(req *dto.ProjectLinkReqDto) { delProjectMapLink(req.Pid) saveProjectMapLink(req.Pid, req.Mids) - - // TODO:前端修改完成后删除 - // 保存新关联关系 - delProjectSizeLink(req.Pid) - saveProjectSize(req.Pid, req.Sids) } // 删除项目地图关联关系 @@ -48,30 +40,3 @@ func saveProjectMapLink(pid int32, mids []*int32) { } dbquery.ProjectPublishLink.Save(mapInfos...) } - -// TODO: 以下代码前端修改完成后删除 -// 通过地图ID获取列车尺寸列表 -func QueryTrainSizeByMapId(mid int32) []*dto.TrainSizeDto { - pl, err := dbquery.ProjectPublishLink.Where(dbquery.ProjectPublishLink.Mid.Eq(mid)).First() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return dto.ConvertFromTrainSizeDto(QueryProjectTrainSize(pl.Pid)) -} - -// 保存项目尺寸关联关系 -func saveProjectSize(pid int32, sids []*int32) { - if len(sids) == 0 { - return - } - sizeInfos := make([]*model.ProjectTrainSizeLink, len(sids)) - for i, sid := range sids { - sizeInfos[i] = &model.ProjectTrainSizeLink{Pid: pid, Sid: *sid} - } - dbquery.ProjectTrainSizeLink.Save(sizeInfos...) -} - -// 删除项目列车尺寸关联关系 -func delProjectSizeLink(pid int32) { - dbquery.ProjectTrainSizeLink.Where(dbquery.ProjectTrainSizeLink.Pid.Eq(pid)).Delete() -} diff --git a/service/publishedGi.go b/service/publishedGi.go index cb2c223..d694897 100644 --- a/service/publishedGi.go +++ b/service/publishedGi.go @@ -45,7 +45,7 @@ func PageQueryPublished(req *dto.PagePublishedReqDto) *dto.PageDto { func ListQueryPublished(req *dto.PublishedListReqDto) []*dto.PublishedDto { where := dbquery.Published.Where(dbquery.Published.Status.Eq(1)) if req.Name != "" { - where = where.Where(dbquery.PublishedGi.Name.Like(fmt.Sprintf("%%%s%%", req.Name))) + where = where.Where(dbquery.Published.Code.Like(fmt.Sprintf("%%%s%%", req.Name))) } result, err := where.Debug().Find() if err != nil { diff --git a/service/trainManage.go b/service/trainManage.go index e2b60be..cec34f2 100644 --- a/service/trainManage.go +++ b/service/trainManage.go @@ -2,7 +2,6 @@ package service import ( "fmt" - "time" "joylink.club/bj-rtsts-server/db/dbquery" "joylink.club/bj-rtsts-server/db/model" @@ -72,286 +71,3 @@ func UpdateTrainInfo(id int32, td *dto.TrainInfoDto) bool { func DeleteTrainInfoById(id int) { _, _ = dbquery.TrainInfo.Debug().Where(dbquery.TrainInfo.ID.Eq(int32(id))).Delete() } - -// TODO:前端修改完毕,以下代码全部删除 -// 查询列车型号信息列表 -func PageTrainModelQuery(query *dto.PageTrainManageReqDto) *dto.PageDto { - d := dbquery.TrainModel - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, total, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).FindByPage(query.Offset(), query.Size) - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records} -} - -// 查询列车型号信息列表 -func ListTrainModelQuery(query *dto.TrainManageReqDto) []*model.TrainModel { - d := dbquery.TrainModel - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, err := dq.Debug().Select(d.ID, d.Name, d.UpdateAt, d.CreatedAt).Find() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return records -} - -// 创建列车型号信息 -func CreateTrainModel(td *dto.TrainModelDto) *model.TrainModel { - if err := checkTrainModel(td.Name, 0); err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - d := model.TrainModel{ - Name: td.Name, - CreatedAt: time.Now(), - UpdateAt: time.Now(), - } - dt := dbquery.TrainModel - err := dt.Save(&d) - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - data, err2 := dt.Where(dt.Name.Eq(td.Name)).Order(dt.CreatedAt).Debug().First() - if err2 != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()}) - } - return data -} - -// 查询列车型号信息 -func QueryTrainModel(id int32) *model.TrainModel { - dt := dbquery.TrainModel - data, err := dt.Where(dt.ID.Eq(id)).Debug().First() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return data -} - -// 更新列车型号信息 -func UpdateTrainModel(id int32, td *dto.TrainModelDto) bool { - if err := checkTrainModel(td.Name, id); err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - findOldQuery := dbquery.TrainModel - oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() - if oldD == nil || err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - oldD.Name = td.Name - oldD.UpdateAt = time.Now() - _, err2 := dbquery.TrainModel.Updates(oldD) - if err2 != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()}) - } - return true -} - -// 删除列车型号 -func DeleteTrainModelById(id int) { - _, _ = dbquery.TrainModel.Debug().Where(dbquery.TrainModel.ID.Eq(int32(id))).Delete() -} - -// 查询列车尺寸信息列表 -func PageTrainSizeQuery(query *dto.PageTrainManageReqDto) *dto.PageDto { - d := dbquery.TrainSize - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, total, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.TotalLength, d.Description).FindByPage(query.Offset(), query.Size) - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records} -} - -// 查询列车尺寸信息列表 -func ListTrainSizeQuery(query *dto.TrainManageReqDto) []*model.TrainSize { - d := dbquery.TrainSize - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, err := dq.Debug().Select(d.ID, d.Name, d.CarriageLength, d.TotalLength, d.Description).Find() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return records -} - -// 创建列车尺寸信息 -func CreateTrainSize(td *dto.TrainSizeDto) *model.TrainSize { - d := model.TrainSize{ - Name: td.Name, - CarriageLength: td.CarriageLength, - TotalLength: td.TotalLength, - Description: td.Description, - } - dt := dbquery.TrainSize - err := dt.Save(&d) - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - data, err := dt.Where(dt.Name.Eq(td.Name)).Order(dt.Name).Debug().First() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return data -} - -// 查询列车尺寸信息 -func QueryTrainSize(id int32) *model.TrainSize { - dt := dbquery.TrainSize - data, err := dt.Where(dt.ID.Eq(id)).Debug().First() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return data -} - -// 更新列车尺寸信息 -func UpdateTrainSize(id int32, td *dto.TrainSizeDto) bool { - findOldQuery := dbquery.TrainSize - oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() - if oldD == nil || err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - oldD.Name = td.Name - oldD.CarriageLength = td.CarriageLength - oldD.TotalLength = td.TotalLength - oldD.Description = td.Description - _, err2 := dbquery.TrainSize.Updates(oldD) - if err2 != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()}) - } - return true -} - -// 删除列车尺寸 -func DeleteTrainSizeById(id int) { - sid := int32(id) - _, _ = dbquery.TrainSize.Debug().Where(dbquery.TrainSize.ID.Eq(sid)).Delete() - dbquery.ProjectTrainSizeLink.Where(dbquery.ProjectTrainSizeLink.Sid.Eq(sid)).Delete() -} - -func QueryProjectTrainSize(id int32) []*model.TrainSize { - // 获取项目关联的列车尺寸 - ptsl := dbquery.ProjectTrainSizeLink - slinks, _ := ptsl.Select(ptsl.Sid).Distinct(ptsl.Sid).Where(ptsl.Pid.Eq(id)).Find() - if len(slinks) == 0 { - return nil - } - sids := make([]int32, len(slinks)) - for i, sid := range slinks { - sids[i] = sid.Sid - } - ts := dbquery.TrainSize - trainSizes, _ := ts.Select(ts.ID, ts.Name, ts.TotalLength, ts.CarriageLength, ts.Description).Where(ts.ID.In(sids...)).Find() - return trainSizes -} - -// 查询列车轮径信息列表 -func PageTrainWheelDiameterQuery(query *dto.PageTrainManageReqDto) *dto.PageDto { - d := dbquery.TrainWheel - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, total, err := dq.Debug().Select(d.ID, d.Name, d.MinDiameter, d.MaxDiameter).FindByPage(query.Offset(), query.Size) - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return &dto.PageDto{Total: int(total), PageQueryDto: query.PageQueryDto, Records: records} -} - -// 查询列车轮径信息列表 -func ListTrainWheelDiameterQuery(query *dto.TrainManageReqDto) []*model.TrainWheel { - d := dbquery.TrainWheel - dq := d.Where() - if query.Name != "" { - dq = dq.Where(d.Name.Like(fmt.Sprintf("%%%s%%", query.Name))) - } - records, err := dq.Debug().Select(d.ID, d.Name, d.MinDiameter, d.MaxDiameter).Find() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return records -} - -// 创建列车轮径信息 -func CreateTrainWheelDiameter(twd *dto.TrainWheelDto) *model.TrainWheel { - d := model.TrainWheel{ - Name: twd.Name, - MinDiameter: twd.MinDiameter, - MaxDiameter: twd.MaxDiameter, - } - dt := dbquery.TrainWheel - err := dt.Save(&d) - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - data, err := dt.Where(dt.Name.Eq(twd.Name)).Order(dt.Name).Debug().First() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return data -} - -// 查询列车轮径信息 -func QueryTrainWheelDiameter(id int32) *model.TrainWheel { - dt := dbquery.TrainWheel - data, err := dt.Where(dt.ID.Eq(id)).Debug().First() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - return data -} - -// 更新列车轮径信息 -func UpdateTrainWheelDiameter(id int32, twd *dto.TrainWheelDto) bool { - findOldQuery := dbquery.TrainWheel - oldD, err := findOldQuery.Where(findOldQuery.ID.Eq(id)).Debug().First() - if oldD == nil || err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - oldD.Name = twd.Name - oldD.MinDiameter = twd.MinDiameter - oldD.MaxDiameter = twd.MaxDiameter - _, err2 := dbquery.TrainWheel.Updates(oldD) - if err2 != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err2.Error()}) - } - return true -} - -// 删除列车轮径 -func DeleteTrainWheelDiameterById(id int) { - _, _ = dbquery.TrainWheel.Debug().Where(dbquery.TrainWheel.ID.Eq(int32(id))).Delete() -} - -// 检查列车型号名称 -func checkTrainModel(name string, id int32) error { - if name == "" { - return nil - } - findNameQuery := dbquery.TrainModel - w := findNameQuery.Where() - if id != 0 { - w = w.Where(findNameQuery.ID.NotIn(id)) - } - count, err := w.Where(findNameQuery.Name.Eq(name)).Debug().Count() - if err != nil { - panic(dto.ErrorDto{Code: dto.QueryDBError, Message: err.Error()}) - } - if count > 0 { - panic(dto.ErrorDto{Code: dto.DataAlreadyExist, Message: "名称已存在"}) - } - return nil -}