17 changed files with 194 additions and 5 deletions
-
13internal/consts/vote.go
-
22internal/dao/article.go
-
91internal/dao/internal/article.go
-
2internal/dao/internal/user.go
-
2internal/dao/internal/vote_option.go
-
2internal/dao/internal/vote_poll.go
-
2internal/dao/internal/vote_record.go
-
22internal/model/do/article.go
-
1internal/model/do/user.go
-
2internal/model/do/vote_option.go
-
1internal/model/do/vote_poll.go
-
1internal/model/do/vote_record.go
-
20internal/model/entity/article.go
-
3internal/model/entity/user.go
-
13internal/model/entity/vote_option.go
-
1internal/model/entity/vote_poll.go
-
1internal/model/entity/vote_record.go
@ -0,0 +1,13 @@ |
|||
package consts |
|||
|
|||
// 投票活动状态
|
|||
const ( |
|||
VoteStatusGoing = 1 //进行中
|
|||
VoteStatusEnded = 0 //已结束
|
|||
) |
|||
|
|||
// 投票类型
|
|||
const ( |
|||
VoteTypeSingle = 0 //单选
|
|||
VoteTypeMultiple = 1 //多选
|
|||
) |
@ -0,0 +1,22 @@ |
|||
// =================================================================================
|
|||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
|||
// =================================================================================
|
|||
|
|||
package dao |
|||
|
|||
import ( |
|||
"practice_ArticleVote_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// articleDao is the data access object for the table article.
|
|||
// You can define custom methods on it to extend its functionality as needed.
|
|||
type articleDao struct { |
|||
*internal.ArticleDao |
|||
} |
|||
|
|||
var ( |
|||
// Article is a globally accessible object for table article operations.
|
|||
Article = articleDao{internal.NewArticleDao()} |
|||
) |
|||
|
|||
// Add your custom methods and functionality below.
|
@ -0,0 +1,91 @@ |
|||
// ==========================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// ==========================================================================
|
|||
|
|||
package internal |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/database/gdb" |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
// ArticleDao is the data access object for the table article.
|
|||
type ArticleDao struct { |
|||
table string // table is the underlying table name of the DAO.
|
|||
group string // group is the database configuration group name of the current DAO.
|
|||
columns ArticleColumns // columns contains all the column names of Table for convenient usage.
|
|||
handlers []gdb.ModelHandler // handlers for customized model modification.
|
|||
} |
|||
|
|||
// ArticleColumns defines and stores column names for the table article.
|
|||
type ArticleColumns struct { |
|||
Id string //
|
|||
UserId string //
|
|||
ArticleTitle string // 文章/视频标题
|
|||
ArticleContent string // 文章/视频内容
|
|||
VoteStatus string // 是否发起投票:1发起,0不发起
|
|||
CreateTime string //
|
|||
UpdateTime string //
|
|||
} |
|||
|
|||
// articleColumns holds the columns for the table article.
|
|||
var articleColumns = ArticleColumns{ |
|||
Id: "id", |
|||
UserId: "user_id", |
|||
ArticleTitle: "article_title", |
|||
ArticleContent: "article_content", |
|||
VoteStatus: "vote_status", |
|||
CreateTime: "create_time", |
|||
UpdateTime: "update_time", |
|||
} |
|||
|
|||
// NewArticleDao creates and returns a new DAO object for table data access.
|
|||
func NewArticleDao(handlers ...gdb.ModelHandler) *ArticleDao { |
|||
return &ArticleDao{ |
|||
group: "default", |
|||
table: "article", |
|||
columns: articleColumns, |
|||
handlers: handlers, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
|||
func (dao *ArticleDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of the current DAO.
|
|||
func (dao *ArticleDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of the current DAO.
|
|||
func (dao *ArticleDao) Columns() ArticleColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the database configuration group name of the current DAO.
|
|||
func (dao *ArticleDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
|||
func (dao *ArticleDao) Ctx(ctx context.Context) *gdb.Model { |
|||
model := dao.DB().Model(dao.table) |
|||
for _, handler := range dao.handlers { |
|||
model = handler(model) |
|||
} |
|||
return model.Safe().Ctx(ctx) |
|||
} |
|||
|
|||
// Transaction wraps the transaction logic using function f.
|
|||
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
|||
// It commits the transaction and returns nil if function f returns nil.
|
|||
//
|
|||
// Note: Do not commit or roll back the transaction in function f,
|
|||
// as it is automatically handled by this function.
|
|||
func (dao *ArticleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
|||
return dao.Ctx(ctx).Transaction(ctx, f) |
|||
} |
@ -0,0 +1,22 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package do |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
) |
|||
|
|||
// Article is the golang structure of table article for DAO operations like Where/Data.
|
|||
type Article struct { |
|||
g.Meta `orm:"table:article, do:true"` |
|||
Id interface{} //
|
|||
UserId interface{} //
|
|||
ArticleTitle interface{} // 文章/视频标题
|
|||
ArticleContent interface{} // 文章/视频内容
|
|||
VoteStatus interface{} // 是否发起投票:1发起,0不发起
|
|||
CreateTime *gtime.Time //
|
|||
UpdateTime *gtime.Time //
|
|||
} |
@ -0,0 +1,20 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
) |
|||
|
|||
// Article is the golang structure for table article.
|
|||
type Article struct { |
|||
Id int64 `json:"id" orm:"id" description:""` //
|
|||
UserId int64 `json:"userId" orm:"user_id" description:""` //
|
|||
ArticleTitle string `json:"articleTitle" orm:"article_title" description:"文章/视频标题"` // 文章/视频标题
|
|||
ArticleContent string `json:"articleContent" orm:"article_content" description:"文章/视频内容"` // 文章/视频内容
|
|||
VoteStatus int `json:"voteStatus" orm:"vote_status" description:"是否发起投票:1发起,0不发起"` // 是否发起投票:1发起,0不发起
|
|||
CreateTime *gtime.Time `json:"createTime" orm:"create_time" description:""` //
|
|||
UpdateTime *gtime.Time `json:"updateTime" orm:"update_time" description:""` //
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue