123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- package models
- import (
- "eta_gn/eta_api/global"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type ReportAuthor struct {
- Id int `gorm:"column:id;primaryKey"` //`orm:"column(id)" description:"报告作者ID"`
- ReportAuthor string `gorm:"column:report_author"` //`description:"报告作者名称"`
- AuthorType int `gorm:"column:author_type"` //`description:"类型,1:中文;2:英文"`
- Enable int `gorm:"column:enable"` //`description:"是否启用,0:禁用,1:启用"`
- IsDelete int `gorm:"column:is_delete"` //`description:"是否删除,0:未删除,1:已删除"`
- CreateTime time.Time `gorm:"column:create_time"` //`description:"创建时间"`
- ModifyTime time.Time `gorm:"column:modify_time"` //`description:"更新时间"`
- }
- // GetReportAuthorList 获取报告作者列表
- func GetReportAuthorList(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*ReportAuthor, err error) {
- baseSql := ` report_author WHERE is_delete=0 `
- if condition != "" {
- baseSql += condition
- }
- totalSql := ` SELECT count(1) total FROM ` + baseSql
- err = global.DmSQL["rddp"].Raw(totalSql, pars...).Scan(&total).Error
- if err != nil {
- return
- }
- sql := ` SELECT * FROM ` + baseSql + ` ORDER BY id desc LIMIT ?,? `
- pars = append(pars, startSize)
- pars = append(pars, pageSize)
- err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
- return
- }
- // GetReportAuthorCount 获取报告作者列表数
- func GetReportAuthorCount(condition string, pars []interface{}) (total int, err error) {
- totalSql := ` SELECT count(1) total FROM report_author WHERE 1=1 `
- if condition != "" {
- totalSql += condition
- }
- err = global.DmSQL["rddp"].Raw(totalSql, pars...).Scan(&total).Error
- return
- }
- type ReportAuthorResp struct {
- List []*ReportAuthor
- Paging *paging.PagingItem `description:"分页数据"`
- }
- // AddReportAuthorReq 新增报告作者请求体
- type AddReportAuthorReq struct {
- Id int `description:"作者id"`
- AuthorType int `description:"类型,1:中文;2:英文"`
- Author string `description:"报告作者名称"`
- }
- // GetReportAuthorById 根据作者id获取数据
- func GetReportAuthorById(authorId int) (item *ReportAuthor, err error) {
- sql := `SELECT * FROM report_author WHERE is_delete=0 AND id = ? `
- err = global.DmSQL["rddp"].Raw(sql, authorId).First(&item).Error
- return
- }
- // GetReportAuthorByAuthor 根据作者名称获取数据
- func GetReportAuthorByAuthor(title string, authorType int) (item *ReportAuthor, err error) {
- sql := `SELECT * FROM report_author WHERE is_delete=0 AND report_author=? AND author_type = ? `
- err = global.DmSQL["rddp"].Raw(sql, title, authorType).First(&item).Error
- return
- }
- // GetReportAuthorByAuthorAndId 根据作者名称和作者id获取数据
- func GetReportAuthorByAuthorAndId(title string, authorType, authorId int) (item *ReportAuthor, err error) {
- sql := `SELECT * FROM report_author WHERE is_delete=0 AND report_author=? AND author_type = ? AND id != ? `
- err = global.DmSQL["rddp"].Raw(sql, title, authorType, authorId).First(&item).Error
- return
- }
- // AddReportAuthor 新增作者
- func AddReportAuthor(item *ReportAuthor) (lastId int64, err error) {
- err = global.DmSQL["rddp"].Create(item).Error
- lastId = int64(item.Id)
- return
- }
- // Update 更新作者基础信息
- func (item *ReportAuthor) Update(cols []string) (err error) {
- err = global.DmSQL["rddp"].Select(cols).Updates(item).Error
- return
- }
- // EnableReportAuthorReq 启用/禁用报告作者请求体
- type EnableReportAuthorReq struct {
- Id int `description:"作者id"`
- EnableType int `description:"是否启用,0:禁用,1:启用"`
- }
- // DeleteReportAuthorReq 删除报告作者请求体
- type DeleteReportAuthorReq struct {
- Id int `description:"作者id"`
- }
|