当前位置:网站首页>Project sorting of Online Exercise System Based on gin and Gorm
Project sorting of Online Exercise System Based on gin and Gorm
2022-06-11 01:57:00 【JIeJaitt】
go/gin/gorm/mysql Wait for the environment to be built ; use first Navicat Create a new database gin_gorm_online_judge For this project , The contents are as follows: :
Create a new question table in this library problem Here's the picture :
Our normal project logic ( Project process ) It should be that after we define a table, we need to go to our gorm Put it in there model Also sync it to the past ;
We are Goland new directory models Catalog , Then build problem.go The file is shown below :
problem.go The contents are as follows :
package models
import "gorm.io/gorm"
type Problem struct {
gorm.Model
Identity string `gorm:"column:identity;type:varchar(36);" json:"identity"`
CategoryId string `gorm:"column:category_id;type:varchar(255);" json:"category-id"`
Title string `gorm:"column:title;type:varchar(255)" json:"title"`
Content string `gorm:"column:content;type:text" json:"content"`
MaxRuntime int `gorm:"column:max_runtime;type:int(11);" json:"max-runtime"`
MaxMem int `gorm:"column:max_mem;type:int(11);" json:"max_mem"`
}
func (table *Problem) TableName() string {
return "problem"
}
newly build user The table is as follows :
newly build user.go as follows :
package models
import "gorm.io/gorm"
type User struct {
gorm.Model
Identity string `gorm:"column:identity;type:varchar(36);" json:"identity"`
Name string `gorm:"column:name;type:varchar(100)" json:"name"`
Password string `gorm:"column:password;type:varchar(32)" json:"password"`
Phone string `gorm:"column:phone;type:varchar(20)" json:"phone"`
Mail string `gorm:"column:mail;type:varchar(100)" json:"mail"`
}
func (table *User) TableName() string {
return "user"
}
newly build category surface :
newly build category.go file :
package models
import "gorm.io/gorm"
type Category struct {
gorm.Model
Identity string `gorm:"column:identity;type:varchar(36);" json:"identity"`
Name string `gorm:"column:name;type:varchar(100);" json:"name"`
ParentId int `gorm:"column:parent_id;type:int(11);" json:"parent_id"`
}
func (table *Category) TableName() string {
return "category"
}
newly build submit surface :
newly build submit.go The documents are as follows :
package models
import "gorm.io/gorm"
type Submit struct {
gorm.Model
Identity string `gorm:"column:identity;type:varchar(36);" json:"identity"`
ProblemIdentity string `gorm:"column:problem_identity;type:varchar(36)" json:"problem_identity"`
UserIdentity string `gorm:"column:user_identity;type:varchar(36)" json:"user_identity"`
Path string `gorm:"column:path;type:varchar(20)" json:"path"`
}
func (table *Submit) TableName() string {
return "submit"
}
After the overall construction, the directory is as follows :
边栏推荐
- 2021-07-18 ROS notes - basics and communication
- 2021-2-14 gephi学习笔记
- Start with interpreting the code automatically generated by BDC, and explain the trial version of the program components of sapgui
- 【MATLAB】图像增强(幂次变换、直方图规定化处理方法、平滑、锐化滤波)
- There is a problem with numpy after CONDA installs pytoch
- AI 狂想|来这场大会,一起盘盘 AI 的新工具!
- [leetcode] balanced binary tree
- Leetcode 1605 find valid matrix given row and Column Sums
- Leetcode 1567 maximum length of subarray with positive product
- 1.5 Px4 vehicle selection
猜你喜欢

C语言 深度探究具有不定参数的函数

Byte Beijing 23K and pinduoduo Shanghai 28K, how should I choose?

基于Gin、Gorm实现的在线练习系统之项目梳理

Deep exploration of functions with indefinite parameters in C language

關於概率統計中的排列組合

There is a problem with numpy after CONDA installs pytoch

【BSP视频教程】BSP视频教程第17期:单片机bootloader专题,启动,跳转配置和调试下载的各种用法(2022-06-10)

【错误记录】Android 应用安全检测漏洞修复 ( StrandHogg 漏洞 | 设置 Activity 组件 android:taskAffinity=““ )

1个月不到暴增900万播放量,B站3个流量增长密码!

Xpath Injection
随机推荐
Leetcode 1094 car pooling (Analog)
【错误记录】Android 应用安全检测漏洞修复 ( StrandHogg 漏洞 | 设置 Activity 组件 android:taskAffinity=““ )
【MATLAB】图像复原
Leetcode 1248 count number of nice subarrays
Leetcode 430 flat a multilevel double linked list (DFS linked list)
Byte Beijing 23K and pinduoduo Shanghai 28K, how should I choose?
C语言 深度探究具有不定参数的函数
China-open-ssl编译的一些记录
2021-07-18 ROS笔记-基础和通讯
2021-3-1matlas MNIST database training for CNN writing
1.3 introduction to ROS UAV
2021-2-14 gephi learning notes
小包子关于分红的思考
Leetcode permutation and combination problem backtracking
2021-02-27MATLAB的图像处理
Leetcode string problem
Leetcode linked list queue stack problem
2022.6.6-----leetcode. seven hundred and thirty-two
Xpath Injection
[leetcode] same tree + symmetric binary tree