|
@@ -0,0 +1,130 @@
|
|
|
+package rag
|
|
|
+
|
|
|
+import (
|
|
|
+ "database/sql"
|
|
|
+ "eta/eta_task/global"
|
|
|
+ "eta/eta_task/utils"
|
|
|
+ "fmt"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type WechatPlatform struct {
|
|
|
+ WechatPlatformId int `gorm:"column:wechat_platform_id;type:int(10) UNSIGNED;primaryKey;not null;" description:"wechat_platform_id"`
|
|
|
+ FakeId string `gorm:"column:fake_id;type:varchar(255);comment:公众号唯一id;" description:"fake_id"` // 公众号唯一id
|
|
|
+ Nickname string `gorm:"column:nickname;type:varchar(255);comment:公众号名称;" description:"nickname"` // 公众号名称
|
|
|
+ Alias string `gorm:"column:alias;type:varchar(255);comment:别名;" description:"alias"` // 别名
|
|
|
+ RoundHeadImg string `gorm:"column:round_head_img;type:varchar(255);comment:头像;" description:"round_head_img"` // 头像
|
|
|
+ ServiceType int `gorm:"column:service_type;type:int(11);comment:类型;default:0;" description:"service_type"` // 类型
|
|
|
+ Signature string `gorm:"column:signature;type:varchar(255);comment:签名;" description:"signature"` // 签名
|
|
|
+ Verified int `gorm:"column:verified;type:int(11);comment:是否认证,0:未认证,1:已认证;这个我不确定,再核实下;default:0;" description:"verified"` // 是否认证,0:未认证,1:已认证;这个我不确定,再核实下
|
|
|
+ ArticleLink string `gorm:"column:article_link;type:varchar(255);comment:添加公众时的文章链接;" description:"article_link"` // 添加公众时的文章链接
|
|
|
+ Enabled int `gorm:"column:enabled;type:tinyint(9);comment:是否启用,0:禁用,1:启用;default:1;" description:"enabled"` // 是否启用,0:禁用,1:启用
|
|
|
+ SysUserId int `gorm:"column:sys_user_id;type:int(9) UNSIGNED;comment:用户id;default:0;" description:"sys_user_id"` // 用户id
|
|
|
+ ModifyTime time.Time `gorm:"column:modify_time;type:datetime;comment:最后一次修改时间;default:NULL;" description:"modify_time"` // 最后一次修改时间
|
|
|
+ CreateTime time.Time `gorm:"column:create_time;type:datetime;comment:添加时间;default:NULL;" description:"create_time"` // 添加时间
|
|
|
+}
|
|
|
+
|
|
|
+// TableName get sql table name.获取数据库表名
|
|
|
+func (m *WechatPlatform) TableName() string {
|
|
|
+ return "wechat_platform"
|
|
|
+}
|
|
|
+
|
|
|
+// WechatPlatformColumns get sql column name.获取数据库列名
|
|
|
+var WechatPlatformColumns = struct {
|
|
|
+ WechatPlatformID string
|
|
|
+ FakeID string
|
|
|
+ Nickname string
|
|
|
+ Alias string
|
|
|
+ RoundHeadImg string
|
|
|
+ ServiceType string
|
|
|
+ Signature string
|
|
|
+ Verified string
|
|
|
+ ArticleLink string
|
|
|
+ Enabled string
|
|
|
+ SysUserID string
|
|
|
+ ModifyTime string
|
|
|
+ CreateTime string
|
|
|
+}{
|
|
|
+ WechatPlatformID: "wechat_platform_id",
|
|
|
+ FakeID: "fake_id",
|
|
|
+ Nickname: "nickname",
|
|
|
+ Alias: "alias",
|
|
|
+ RoundHeadImg: "round_head_img",
|
|
|
+ ServiceType: "service_type",
|
|
|
+ Signature: "signature",
|
|
|
+ Verified: "verified",
|
|
|
+ ArticleLink: "article_link",
|
|
|
+ Enabled: "enabled",
|
|
|
+ SysUserID: "sys_user_id",
|
|
|
+ ModifyTime: "modify_time",
|
|
|
+ CreateTime: "create_time",
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) Create() (err error) {
|
|
|
+ err = global.DbMap[utils.DbNameAI].Create(&m).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) Update(updateCols []string) (err error) {
|
|
|
+ err = global.DbMap[utils.DbNameAI].Select(updateCols).Updates(&m).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) Del() (err error) {
|
|
|
+ err = global.DbMap[utils.DbNameAI].Delete(&m).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) GetById(wechatPlatformId int) (item *WechatPlatform, err error) {
|
|
|
+ err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", WechatPlatformColumns.WechatPlatformID), wechatPlatformId).First(&item).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) GetByCondition(condition string, pars []interface{}) (item *WechatPlatform, err error) {
|
|
|
+ sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s`, m.TableName(), condition)
|
|
|
+ err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).First(&item).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) GetListByCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*WechatPlatform, err error) {
|
|
|
+ sqlStr := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT ?,?`, m.TableName(), condition)
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
+ err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Find(&items).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) GetCountByCondition(condition string, pars []interface{}) (total int, err error) {
|
|
|
+ var intNull sql.NullInt64
|
|
|
+ sqlStr := fmt.Sprintf(`SELECT COUNT(1) total FROM %s WHERE 1=1 %s`, m.TableName(), condition)
|
|
|
+ err = global.DbMap[utils.DbNameAI].Raw(sqlStr, pars...).Scan(&intNull).Error
|
|
|
+ if err == nil && intNull.Valid {
|
|
|
+ total = int(intNull.Int64)
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) GetPageListByCondition(condition string, pars []interface{}, startSize, pageSize int) (total int, items []*WechatPlatform, err error) {
|
|
|
+
|
|
|
+ total, err = m.GetCountByCondition(condition, pars)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if total > 0 {
|
|
|
+ items, err = m.GetListByCondition(condition, pars, startSize, pageSize)
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *WechatPlatform) GetByFakeID(fakeId string) (item *WechatPlatform, err error) {
|
|
|
+ err = global.DbMap[utils.DbNameAI].Where(fmt.Sprintf("%s = ?", WechatPlatformColumns.FakeID), fakeId).First(&item).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|