db

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

全局数据库对象

Functions

func ConnSqlite

func ConnSqlite() *gorm.DB

func InitDB

func InitDB()

初始化数据库

Types

type Chat

type Chat struct {
	gorm.Model
	Username      string   `gorm:"type:varchar(50);not null;comment:'用户名'" json:"username"`        // 用户名
	Source        string   `gorm:"type:varchar(50);comment:'用户来源:群聊名字,私聊'" json:"source"`          // 对话来源
	ChatType      ChatType `gorm:"type:tinyint(1);default:1;comment:'类型:1问, 2答'" json:"chat_type"` // 状态
	ParentContent uint     `gorm:"default:0;comment:'父消息编号(编号为0时表示为首条)'" json:"parent_content"`
	Content       string   `gorm:"type:varchar(128);comment:'内容'" json:"content"` // 问题或回答的内容
}

func (Chat) Add

func (c Chat) Add() (uint, error)

Add 添加资源

func (Chat) Exist

func (c Chat) Exist(filter map[string]interface{}) bool

Exist 判断资源是否存在

func (Chat) Find

func (c Chat) Find(filter map[string]interface{}, data *Chat) error

Find 获取单个资源

func (Chat) List

func (c Chat) List(req ChatListReq) ([]*Chat, error)

List 获取数据列表

type ChatListReq

type ChatListReq struct {
	Username string `json:"username" form:"username"`
	Source   string `json:"source" form:"source"`
}

type ChatType

type ChatType uint
const A ChatType = 2
const Q ChatType = 1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL