当前位置:网站首页>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 :
边栏推荐
- 【HaaS Hands-On】全新视频节目上线 创意案例我们一起上手做 第一期E01: 物联网工程师 和你一起上手做遥控机械臂
- [leetcode] merge K ascending linked lists
- Interviewer: let me introduce the items in your resume. Tell me more about them, and attach the actual project
- Leetcode binary tree problem
- 【MATLAB】图像复原
- 神经网络极简史,神经网络知识点整理
- EXJ形儿多眼前因断会满意接MBtXE
- 关于CS-3120舵机使用过程中感觉反应慢的问题
- Linux安装mysql数据库详解
- 【MATLAB】图像变换(傅里叶变换、离散余弦变换)
猜你喜欢

Task02: basic use of database (MySQL)

Deep exploration of functions with indefinite parameters in C language

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

On permutation and combination in probability and statistics
![[leetcode] ordered linked list transformation binary search tree](/img/9f/86e819beb8dc678d79c3e307891402.jpg)
[leetcode] ordered linked list transformation binary search tree

flutter_swiper 轮播图 插件

Daily problem essay | 21.11.29: use resttemplate to call external put request, and prompt '400 bad request'

神经网络极简史,神经网络知识点整理
![[leetcode] construct a binary tree by traversing the sequence from front to middle (continuous optimization)](/img/02/114618065e090769543a2aa106aa66.jpg)
[leetcode] construct a binary tree by traversing the sequence from front to middle (continuous optimization)

【云原生 | Kubernetes篇】Ingress案例实战
随机推荐
There is a problem with numpy after CONDA installs pytoch
C语言 深度探究具有不定参数的函数
2021-2-26 compilation of programming language knowledge points
Loki learning summary (1) -- the best choice of Loki small and medium-sized project log system
[leetcode] path sum II (first glimpse recursion + backtracking)
On permutation and Combination in Probabilistic Statistics
【圖像處理】基於matlab GUI多功能圖像處理系統【含Matlab源碼 1876期】
2021-02-27image processing of MATLAB
flutter 状态管理
Daily problem essay | 21.11.29: use resttemplate to call external put request, and prompt '400 bad request'
[leetcode] same tree + symmetric binary tree
[leetcode] LRU cache
China-open-ssl编译的一些记录
Exj shaped children will be satisfied with mbtxe due to disconnection
2.0 detailed explanation of ROS and Px4 communication
Garbled code when the command parameter contains% in VisualStudio debugging
薪的测试开发程序员们,你为何要走?和产品相互残杀到天昏地暗......
关于概率统计中的排列组合
【音乐】基于matlab演奏《过火》【含Matlab源码 1875期】
【错误记录】Android 应用安全检测漏洞修复 ( StrandHogg 漏洞 | 设置 Activity 组件 android:taskAffinity=““ )