diff --git a/Nozomi9967/CRUD/CRUD.go b/Nozomi9967/CRUD/CRUD.go new file mode 100644 index 0000000..0931489 --- /dev/null +++ b/Nozomi9967/CRUD/CRUD.go @@ -0,0 +1,114 @@ +package CRUD + +import ( + "fmt" + "github.com/gin-gonic/gin" + "github/piexlMax/web/comment" + "github/piexlMax/web/gorm" + "github/piexlMax/web/post" + "net/http" + "strconv" +) + +func SearchPostByindex(c *gin.Context) { + indexstring := c.Param("index") + index, error := strconv.Atoi(indexstring) + if error != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "index类型转换失败"}) + return + } + var post post.Post + //order:按照id来升序排序,offset:跳过前index-1条数据,limit:查找index-1后的一条数据,find:赋值给post + gorm.GLOBAL_DB.Table("t_post").Order("id").Offset(index - 1).Limit(1).Find(&post) + fmt.Println("第", index, "条数据:", post) + c.JSON(http.StatusOK, gin.H{"PostId": post.ID}) +} + +func DeletePost(c *gin.Context) { + + //json绑定前端帖子id信息 + var Postid struct { + PostID uint + } + error := c.BindJSON(&Postid) + if error != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "绑定json失败"}) + return + } + fmt.Println("删除帖子函数接收到的postid为", Postid.PostID) + + //数据库总寻找对应id帖子 + var post post.Post + result := gorm.GLOBAL_DB.Table("t_post").First(&post, Postid.PostID) + if result.RowsAffected == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "没有找到对应帖子"}) + return + } + fmt.Println("待删除的post为", post) + + //删除对应帖子的评论 + var comments []comment.Comment + gorm.GLOBAL_DB.Table("t_comment").Where("post_id = ?", post.ID).Find(&comments) + fmt.Println("帖子对应评论:", comments) + if len(comments) > 0 { + gorm.GLOBAL_DB.Table("t_comment").Delete(&comments) + } + + //删除帖子 + gorm.GLOBAL_DB.Delete(&post) + c.JSON(200, gin.H{"msg": "删除成功"}) +} + +func GetModifInfo(c *gin.Context) { + //string转int + var postid = c.Param("postid") + var PostIdInt, error = strconv.Atoi(postid) + if error != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "postid转换类型失败"}) + return + } + + //数据库查找帖子,帖子数据绑定到post + var post post.Post + result := gorm.GLOBAL_DB.Table("t_post").First(&post, PostIdInt) + if result.RowsAffected == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "帖子不存在"}) + return + } + + //只需返回标题和内容 + c.JSON(http.StatusOK, gin.H{"PostHeadline": post.Headline, "PostContent": post.Content}) +} + +func ModifyPost(c *gin.Context) { + + //处理前端发来的信息 + var PostId = c.Param("postid") + var PostIdInt, error = strconv.Atoi(PostId) + if error != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "postid转换类型失败"}) + return + } + var Postinfo struct { + Headline string `json:"headline"` + Content string `json:"content"` + } + error = c.BindJSON(&Postinfo) + if error != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "json数据绑定失败"}) + } + + var post post.Post + result := gorm.GLOBAL_DB.Table("t_post").First(&post, PostIdInt) + if result.RowsAffected == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "帖子不存在"}) + return + } + + post.Headline = Postinfo.Headline + post.Content = Postinfo.Content + fmt.Println("修改后的post:", post) + gorm.GLOBAL_DB.Save(&post) + + c.JSON(200, gin.H{"msg": "修改成功"}) +} diff --git a/Nozomi9967/comment/comment.go b/Nozomi9967/comment/comment.go new file mode 100644 index 0000000..ebd10f9 --- /dev/null +++ b/Nozomi9967/comment/comment.go @@ -0,0 +1,103 @@ +package comment + +import ( + "fmt" + "github/piexlMax/web/gorm" +) + +type Comment struct { + ID uint `gorm:"primary_key"` + PostID uint `gorm:"index;not null"` + UserID uint `gorm:"index"` //发布评论的用户的id + UserName string `gorm:"type:text"` + ParentID uint `gorm:"index"` //父评论的id + Content string `gorm:"type:text"` + FormattedTime string `gorm:"type:text"` + //Post post.Post `gorm:"foreignkey:PostID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` + Replies []Comment `gorm:"foreignKey:ParentID;references:ID"` // 关联关系定义 +} + +type TopcommentJson struct { + ID uint `json:"id"` + Username string `json:"username"` + Content string `json:"content"` + FormattedTime string `json:"formatted_time"` + Replies []TopcommentJson `json:"replies"` +} + +func CreateCommentTable() { + gorm.GLOBAL_DB.AutoMigrate(&Comment{}) +} + +func GetAllComment(Postid uint) ([]TopcommentJson, error) { + //var SummitComments struct { + // ID uint `json:"id"` + // UserID uint `json:"user_id"` + // Content string `json:"content"` + // CreatedAt time.Time `json:"created_at"` + // FormattedTime string `json:"formatted_time"` + //} + + //fmt.Println("GetAllComment执行") + + //添加回复 + var TopComments []Comment + gorm.GLOBAL_DB.Where("post_id = ? AND parent_id=0", Postid).Find(&TopComments) + + //帖子没有评论直接返回 + if TopComments == nil { + + return nil, nil + } + + var EnrichedTopComments []Comment + for _, TopComment := range TopComments { + + var Replies []Comment + + gorm.GLOBAL_DB.Where("parent_id=?", TopComment.ID).Find(&Replies) + fmt.Println("ID=", TopComment.ID) + fmt.Println("找到的Replies为", Replies) + TopComment.Replies = Replies + EnrichedTopComments = append(EnrichedTopComments, TopComment) + } + + //fmt.Println("未处理之前的TopComments为", TopComments) + + //转json + var topcommentsJson []TopcommentJson + for _, EnrichedTopComment := range EnrichedTopComments { + + //先把父评论的回复转为json + topcommentRepliesJson := make([]TopcommentJson, len(EnrichedTopComment.Replies)) + for i, Reply := range EnrichedTopComment.Replies { + topcommentRepliesJson[i] = TopcommentJson{ + ID: Reply.ID, + Username: Reply.UserName, + Content: Reply.Content, + FormattedTime: Reply.FormattedTime, + } + } + + //fmt.Println("转json执行") + //fmt.Println("ID为", EnrichedTopComment.ID) + //fmt.Println(topcommentRepliesJson) + + //将父评论的其它变量转为json + topcommentsJson = append(topcommentsJson, TopcommentJson{ + ID: EnrichedTopComment.ID, + Username: EnrichedTopComment.UserName, + Content: EnrichedTopComment.Content, + FormattedTime: EnrichedTopComment.FormattedTime, + Replies: topcommentRepliesJson, + }) + + } + + //JsonData, err := json.Marshal(topcommentsJson) + //if err != nil { + // fmt.Println(err) + // return nil, err + //} + return topcommentsJson, nil +} diff --git a/Nozomi9967/go.mod b/Nozomi9967/go.mod new file mode 100644 index 0000000..3364b4c --- /dev/null +++ b/Nozomi9967/go.mod @@ -0,0 +1,46 @@ +module github/piexlMax/web + +go 1.23.1 + +require ( + github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/gin-contrib/sessions v1.0.1 + github.com/gin-gonic/gin v1.10.0 + gorm.io/driver/mysql v1.5.7 + gorm.io/gorm v1.25.12 +) + +require ( + github.com/bytedance/sonic v1.12.3 // indirect + github.com/bytedance/sonic/loader v0.2.0 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.5 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.22.1 // indirect + github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/goccy/go-json v0.10.3 // indirect + github.com/gorilla/context v1.1.2 // indirect + github.com/gorilla/securecookie v1.1.2 // indirect + github.com/gorilla/sessions v1.4.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.8 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + golang.org/x/arch v0.10.0 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/text v0.18.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/Nozomi9967/go.sum b/Nozomi9967/go.sum new file mode 100644 index 0000000..e69987c --- /dev/null +++ b/Nozomi9967/go.sum @@ -0,0 +1,109 @@ +github.com/bytedance/sonic v1.12.3 h1:W2MGa7RCU1QTeYRTPE3+88mVC0yXmsRQRChiyVocVjU= +github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/bytedance/sonic/loader v0.2.0 h1:zNprn+lsIP06C/IqCHs3gPQIvnvpKbbxyXQP1iU4kWM= +github.com/bytedance/sonic/loader v0.2.0/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= +github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= +github.com/gin-contrib/sessions v1.0.1 h1:3hsJyNs7v7N8OtelFmYXFrulAf6zSR7nW/putcPEHxI= +github.com/gin-contrib/sessions v1.0.1/go.mod h1:ouxSFM24/OgIud5MJYQJLpy6AwxQ5EYO9yLhbtObGkM= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= +github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= +github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/gorilla/context v1.1.2 h1:WRkNAv2uoa03QNIc1A6u4O7DAGMUVoopZhkiXWA2V1o= +github.com/gorilla/context v1.1.2/go.mod h1:KDPwT9i/MeWHiLl90fuTgrt4/wPcv75vFAZLaOOcbxM= +github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= +github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= +github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ= +github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= +github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +golang.org/x/arch v0.10.0 h1:S3huipmSclq3PJMNe76NGwkBR504WFkQ5dhzWzP8ZW8= +golang.org/x/arch v0.10.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= +gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= +gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= +gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= diff --git a/Nozomi9967/gorm/gorm.go b/Nozomi9967/gorm/gorm.go new file mode 100644 index 0000000..6e4bc9d --- /dev/null +++ b/Nozomi9967/gorm/gorm.go @@ -0,0 +1,42 @@ +package gorm + +import ( + "github.com/gin-gonic/gin" + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/schema" + "net/http" + "time" +) + +var GLOBAL_DB *gorm.DB + +func Gorm() { + db, _ := gorm.Open(mysql.New(mysql.Config{ + DSN: "root:123456@tcp(127.0.0.1:3306)/my_database?charset=utf8mb4&parseTime=True&loc=Local", + DefaultStringSize: 171, + }), &gorm.Config{ + SkipDefaultTransaction: false, + NamingStrategy: schema.NamingStrategy{ + TablePrefix: "t_", // table name prefix, table for `User` would be `t_users` + SingularTable: true, // use singular table name, table for `User` would be `user` with this option enabled + }, + DisableForeignKeyConstraintWhenMigrating: true, + }) + + if db.Error != nil { + panic(db.Error) + } + + sqldb, _ := db.DB() + sqldb.SetMaxIdleConns(10) + sqldb.SetMaxOpenConns(100) + sqldb.SetConnMaxLifetime(time.Hour) + + GLOBAL_DB = db + +} + +func SelfInfoHandler(c *gin.Context) { + c.HTML(http.StatusOK, "selfinfo", nil) +} diff --git a/Nozomi9967/main.go b/Nozomi9967/main.go new file mode 100644 index 0000000..bcfbadf --- /dev/null +++ b/Nozomi9967/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "github.com/gin-gonic/gin" + "github/piexlMax/web/CRUD" + "github/piexlMax/web/gorm" + "github/piexlMax/web/my_func" + "net/http" +) + +func main() { + gorm.Gorm() + my_func.Init() + + server := gin.Default() + + //store := cookie.NewStore([]byte("secret-key")) + //server.Use(sessions.Sessions("my_session", store)) + + //server.Use(my_func.InitSessionMiddleware()) + + server.LoadHTMLGlob("templates/**/*") + server.Static("/c", "templates/css") + + server.GET("/menu", my_func.Menu) + server.GET("/regis_page", my_func.Regis_page) + server.GET("/login_page", my_func.Login_page) + server.POST("/regis", my_func.Regis) + server.POST("/login", my_func.Login) + server.GET("/self_info_page", gorm.SelfInfoHandler) + server.GET("/post_question_page", my_func.Post_question_page) + server.GET("/main", my_func.Main_page_re) + server.GET("/post/:id", func(c *gin.Context) { + PostId := c.Param("id") + c.HTML(http.StatusOK, "Post_page", gin.H{"PostId": PostId}) + }) + server.GET("/modif/:postid", func(c *gin.Context) { + PostId := c.Param("postid") + c.HTML(http.StatusOK, "Modif_page", gin.H{"PostId": PostId}) + }) + + auth := server.Group("/auth", my_func.AuthMiddleware()) + { + auth.GET("/post_question", my_func.Post_question_page) + auth.POST("/upload_post_info", my_func.UploadPostInfo) + auth.POST("/upload_summit_comment", my_func.Upload_comment) + auth.POST("/get_posts/page:index", my_func.GetPosts) + auth.GET("/post/:index", CRUD.SearchPostByindex) + auth.POST("/get_idpost_info", my_func.GetIdpostInfo) + auth.POST("/delete_post", CRUD.DeletePost) //删除帖子请求 + auth.POST("/modif_post_info/:postid", CRUD.ModifyPost) //修改帖子请求 + auth.GET("/self_info", gorm.SelfInfoHandler) + auth.GET("/get_pre_modif_Info/:postid", CRUD.GetModifInfo) + } + + server.Run(":8080") +} diff --git a/Nozomi9967/model.go b/Nozomi9967/model.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/Nozomi9967/model.go @@ -0,0 +1 @@ +package main diff --git a/Nozomi9967/my_func/func.go b/Nozomi9967/my_func/func.go new file mode 100644 index 0000000..c976cac --- /dev/null +++ b/Nozomi9967/my_func/func.go @@ -0,0 +1,355 @@ +package my_func + +import ( + "fmt" + "github.com/dgrijalva/jwt-go" + "github.com/gin-gonic/gin" + "github/piexlMax/web/comment" + "github/piexlMax/web/gorm" + "github/piexlMax/web/post" + "net/http" + "reflect" + "strconv" + "time" +) + +var SinglePageSize = 10 + +type CustomClaims struct { + UserId uint `json:"user_id"` + jwt.StandardClaims +} + +type User struct { + ID uint `gorm:"primary_key"` + Name string + Psw string +} + +func Init() { + CreateUserTable() + CreatePostTable() + comment.CreateCommentTable() +} + +func CreateUserTable() { + gorm.GLOBAL_DB.AutoMigrate(&User{}) +} + +func CreatePostTable() { + gorm.GLOBAL_DB.AutoMigrate(&post.Post{}) +} + +func Menu(c *gin.Context) { + c.HTML(http.StatusOK, "menu", nil) +} + +func UploadPostInfo(c *gin.Context) { + var post post.Post + err := c.BindJSON(&post) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "无效的json格式"}) + return + } + + //关联发布者id + UseridInterface, exist := c.Get("user_id") + + fmt.Println("UploadPostInfo中接收到的userid", UseridInterface) + if !exist { + c.JSON(http.StatusBadRequest, gin.H{"error": "获取用户id失败"}) + return + } + post.UserID = UseridInterface.(uint) + + //加入上传时间 + post.PostTime = time.Now() + //格式化发布时间 + post.FormattedTime = post.PostTime.Format("2006-01-02 15:04:05") + + gorm.GLOBAL_DB.Create(&post) + + c.JSON(http.StatusOK, gin.H{"msg": "帖子上传成功"}) +} + +func GetPosts(c *gin.Context) { + + //绑定搜索关键词 + var SearchKeyWord struct { + SKW string + } + err := c.ShouldBindJSON(&SearchKeyWord) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "绑定搜索词失败"}) + return + } + fmt.Println("获取到的搜索词为", SearchKeyWord.SKW) + + //获取页码 + var PageIndex = c.Param("index") + PageIndexInt, Err := strconv.Atoi(PageIndex) + if Err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "转换类型失败"}) + return + } + fmt.Println("获取到的页码为:", PageIndexInt) + + var posts []post.Post + if SearchKeyWord.SKW == "没有搜索词" { + gorm.GLOBAL_DB.Table("t_post").Offset((PageIndexInt - 1) * SinglePageSize).Limit(10).Find(&posts) + } else { + gorm.GLOBAL_DB.Table("t_post").Where("headline LIKE ?", "%"+SearchKeyWord.SKW+"%").Offset((PageIndexInt - 1) * SinglePageSize).Limit(10).Find(&posts) + } + fmt.Println("获取到的:", posts) + //if len(posts) > 0 { + // c.JSON(http.StatusOK, gin.H{"posts": posts}) + //} else { + // c.JSON(http.StatusNotFound, gin.H{"error": "还没有人发帖子"}) + //} + + c.JSON(http.StatusOK, gin.H{"posts": posts}) + +} + +// 获取帖子初始化数据 +func GetIdpostInfo(c *gin.Context) { + + var PostId struct { + ID uint `json:"id"` + } + + err := c.BindJSON(&PostId) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "绑定json失败"}) + return + } + + //根据id查找帖子数据 + fmt.Println("后端得到的postid为", PostId.ID) + + var post post.Post + result := gorm.GLOBAL_DB.First(&post, "ID=?", PostId.ID) + //fmt.Println("返回值信息为", result) + if result.RowsAffected == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "没有对应id的帖子"}) + return + } + fmt.Println("帖子id:", post.ID) + fmt.Println("发布帖子的用户id:", post.UserID) + fmt.Println("帖子标题:", post.Headline) + fmt.Println("帖子内容:", post.Content) + + //根据帖子id绑定用户 + var post_user User + result = gorm.GLOBAL_DB.First(&post_user, "ID=?", post.UserID) + if result.RowsAffected == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "此帖子的用户不存在"}) + return + } + + //寻找该帖子下的评论 + TopcommentsJson, err := comment.GetAllComment(PostId.ID) + + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "查找评论信息失败"}) + } + + //找到了,返回数据到前端去渲染 + c.JSON(http.StatusOK, gin.H{"post": post, "post_user": post_user, "comments": TopcommentsJson}) +} + +func Upload_comment(c *gin.Context) { + + fmt.Println("Upload_comment函数执行了") + + var comment_part struct { + Content string `form:"content"` + PostId uint `form:"post_id"` + ParentID uint `form:"parent_id"` + } + //将前端接收的评论数据保存至comment + c.BindJSON(&comment_part) + + //转移到Comment结构体中 + var comment comment.Comment + comment.Content = comment_part.Content + comment.PostID = comment_part.PostId + comment.ParentID = comment_part.ParentID + + userinterface, exist := c.Get("user_id") + if !exist { + c.JSON(http.StatusBadRequest, gin.H{"error": "获取发布评论者id失败"}) + } + userid := userinterface.(uint) + var user User + result := gorm.GLOBAL_DB.First(&user, "ID=?", userid) + if result.RowsAffected == 0 { + c.JSON(http.StatusBadRequest, gin.H{"error": "没有找到对应id的用户名"}) + return + } + comment.UserName = user.Name + comment.UserID = userid + + comment.FormattedTime = time.Now().Format("2006-01-02 15:04:05") + + fmt.Println(comment) + + gorm.GLOBAL_DB.Create(&comment) + c.JSON(http.StatusOK, gin.H{"msg": "评论成功"}) +} + +func Main_page_re(c *gin.Context) { + //c.Redirect(http.StatusFound, "/auth/main") + fmt.Println("主界面") + c.HTML(http.StatusOK, "main", nil) +} + +func Regis_page(c *gin.Context) { + c.HTML(http.StatusOK, "regis", nil) +} + +func Replication(Name string) bool { + if gorm.GLOBAL_DB.First(&User{}, "Name=?", Name).Error == nil { + fmt.Println(Name) + return true + } + return false +} + +func Regis(c *gin.Context) { + var user User + err := c.BindJSON(&user) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "无效的jason格式"}) + return + } + if Replication(user.Name) { + c.JSON(http.StatusConflict, gin.H{"error": "用户名已存在"}) + fmt.Println("冲突+", user.Name) + return + } + gorm.GLOBAL_DB.Create(&user) + c.JSON(http.StatusOK, gin.H{"msg": "注册成功"}) +} + +func Login_page(c *gin.Context) { + c.HTML(http.StatusOK, "login", nil) +} + +func Login(c *gin.Context) { + var user User + var loginData struct { + ID uint + Name string + Psw string + } + err := c.BindJSON(&loginData) + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "无效的jason格式"}) + return + } + error := gorm.GLOBAL_DB.First(&user, "Name=?", loginData.Name) + if error.Error != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": "该账号不存在"}) + return + } + if user.Psw != loginData.Psw { + c.JSON(http.StatusBadRequest, gin.H{"error": "密码错误"}) + return + } + TokenString, err := GenerateToken(user.ID) + if err != nil { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "生成token失败"}) + return + } + + c.Set("user_id", uint(user.ID)) + fmt.Println("login中的userid", uint(user.ID)) + //session := sessions.Default(c) + //session.Set("user_id", user.ID) + //session.Save() + fmt.Println("login中的token") + fmt.Println(TokenString) + c.JSON(http.StatusOK, gin.H{"msg": "登录成功", "token": TokenString, "userid": user.ID}) + +} + +func GenerateToken(userid uint) (string, error) { + + fmt.Println("编进token之前的userid类型为", reflect.TypeOf(userid)) + + claims := &CustomClaims{ + UserId: userid, + StandardClaims: jwt.StandardClaims{ + ExpiresAt: time.Now().Add(time.Hour * 2).Unix(), + }, + } + + token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) + tokenstring, err := token.SignedString([]byte("nozomi")) + if err != nil { + return "", err + } + return tokenstring, nil +} + +func AuthMiddleware() gin.HandlerFunc { + + return func(c *gin.Context) { + + tokenString := c.Request.Header.Get("Authorization") + if tokenString == "" { + //fmt.Println("未提供token") + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "未提供token"}) + return + } + token, err := jwt.ParseWithClaims(tokenString, &CustomClaims{}, func(token *jwt.Token) (interface{}, error) { + + if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { + return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) + } + return []byte("nozomi"), nil + }) + //fmt.Println("中间件接收到的token") + fmt.Println(token, err) + if err != nil { + c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "无效的token"}) + return + } + if claims, ok := token.Claims.(*CustomClaims); ok && token.Valid { + //fmt.Println("中间件在context中保存的userid", claims.UserId) + //fmt.Println("类型为",type(claims["userid"])) + + //存在上下文中,方便以后函数使用 + c.Set("user_id", claims.UserId) + //fmt.Println("next执行了") + c.Next() + } else { + c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "无效的token"}) + return + } + + //session实现失败 + //session := sessions.Default(c) + //userid := session.Get("user_id") + //if userid == nil { + // c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "未授权"}) + // return + //} + //fmt.Println("中间件") + //fmt.Println(userid) + //c.Set("user_id", userid) + //c.Next() + + } +} + +// +//func Main_page_(c *gin.Context) { +// c.Redirect(http.StatusFound, "/auth/main") +// //c.HTML(http.StatusOK, "main", nil) +//} + +func Post_question_page(c *gin.Context) { + c.HTML(http.StatusOK, "postquestion", nil) +} diff --git a/Nozomi9967/post/post.go b/Nozomi9967/post/post.go new file mode 100644 index 0000000..c97f94d --- /dev/null +++ b/Nozomi9967/post/post.go @@ -0,0 +1,12 @@ +package post + +import "time" + +type Post struct { + ID uint `gorm:"primary_key"` + UserID uint `gorm:"index"` + Headline string `gorm:"type:text"` + Content string `gorm:"type:text"` + PostTime time.Time `gorm:"type:datetime"` + FormattedTime string `gorm:"type:text"` +} diff --git a/Nozomi9967/qodana.yaml b/Nozomi9967/qodana.yaml new file mode 100644 index 0000000..215d808 --- /dev/null +++ b/Nozomi9967/qodana.yaml @@ -0,0 +1,29 @@ +#-------------------------------------------------------------------------------# +# Qodana analysis is configured by qodana.yaml file # +# https://www.jetbrains.com/help/qodana/qodana-yaml.html # +#-------------------------------------------------------------------------------# +version: "1.0" + +#Specify inspection profile for code analysis +profile: + name: qodana.starter + +#Enable inspections +#include: +# - name: + +#Disable inspections +#exclude: +# - name: +# paths: +# - + +#Execute shell command before Qodana execution (Applied in CI/CD pipeline) +#bootstrap: sh ./prepare-qodana.sh + +#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) +#plugins: +# - id: #(plugin id can be found at https://plugins.jetbrains.com) + +#Specify Qodana linter for analysis (Applied in CI/CD pipeline) +linter: jetbrains/qodana-go:latest diff --git a/Nozomi9967/templates/css/login_regis_style.css b/Nozomi9967/templates/css/login_regis_style.css new file mode 100644 index 0000000..accb914 --- /dev/null +++ b/Nozomi9967/templates/css/login_regis_style.css @@ -0,0 +1,26 @@ +.main_function{ + font-size: 80px; + margin-top: 200px; +} + +.name, +.psw{ + height: 80px; + vertical-align: middle; + font-size: 50px; +} + +form{ + /*margin: 0 auto;*/ + text-align: center; +} + +.btn{ + width: 80px; + height: 80px; +} + +.alert{ + font-size: 100px; +} + diff --git a/Nozomi9967/templates/css/main_style.css b/Nozomi9967/templates/css/main_style.css new file mode 100644 index 0000000..05a7c03 --- /dev/null +++ b/Nozomi9967/templates/css/main_style.css @@ -0,0 +1,49 @@ +.self_info{ + float: right; + width: 50px; + height: 50px; +} + +.head_section{ + /*text-align: center;*/ + margin: 10px; +} + +.PostQuestion{ + width: 100px; + height: 80px; + float:left; + /*margin: 0 auto;*/ +} + +.search_question{ + height: 50px; + width: 500px; + font-size: 40px; + margin-top: 30px; +} + +.post{ + padding: 40px; + height: 640px; +} + +.has_content{ + font-size: 40px; + border: 1px; + border-style: solid; + margin: 8px; +} + +.page_index_section>a{ + font-size: 30px; + padding: 7px; +} + +body{ + text-align: center; +} + +.middle{ + font-size: 100px; +} diff --git a/Nozomi9967/templates/css/menu_style.css b/Nozomi9967/templates/css/menu_style.css new file mode 100644 index 0000000..9861e30 --- /dev/null +++ b/Nozomi9967/templates/css/menu_style.css @@ -0,0 +1,11 @@ + +.main_function{ + text-align: center; + margin-top: 300px; +} + +.regis, +.login{ + width: 400px; + height: 200px; +} \ No newline at end of file diff --git a/Nozomi9967/templates/css/post_page_style.css b/Nozomi9967/templates/css/post_page_style.css new file mode 100644 index 0000000..0603daa --- /dev/null +++ b/Nozomi9967/templates/css/post_page_style.css @@ -0,0 +1,35 @@ +.post_headline{ + font-size: 100px; +} + +.post_user_name, +.post_date{ + position: absolute; + right: 0px; +} + +.comment_section_name{ + font-size: 80px; +} + +.comment_section{ + width: 1000px; + height: 800px; + border: 2px; + border-style: solid; + margin: 0 auto; +} + +.comment_section_name, +.post_comment_section{ + margin:0 auto; + text-align: center; +} + +.back_main_btn{ + float: right; + width: 100px; + height: 50px; + margin: 50px; +} + diff --git a/Nozomi9967/templates/css/post_question_style.css b/Nozomi9967/templates/css/post_question_style.css new file mode 100644 index 0000000..6d05844 --- /dev/null +++ b/Nozomi9967/templates/css/post_question_style.css @@ -0,0 +1,18 @@ +.headline{ + font-size: 100px; +} + +.btn{ + width: 200px; + height: 100px; +} + +.content{ + font-size: 80px; +} + +.main_function{ + text-align: center; +} + + diff --git a/Nozomi9967/templates/html/login.html b/Nozomi9967/templates/html/login.html new file mode 100644 index 0000000..055916b --- /dev/null +++ b/Nozomi9967/templates/html/login.html @@ -0,0 +1,88 @@ +{{define "login"}} + + + + + 登录页面 + + + + +
+ +
+ +
+ 账号 +
+ +
+ +
密码
+ + +
+ + + + + + +
+ + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/main.html b/Nozomi9967/templates/html/main.html new file mode 100644 index 0000000..472026d --- /dev/null +++ b/Nozomi9967/templates/html/main.html @@ -0,0 +1,261 @@ +{{define "main"}} + + + + + 主界面 + + + + + + +
+ + + + +
+ + + +
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+ +
+ 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 +
+ + + + + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/menu.html b/Nozomi9967/templates/html/menu.html new file mode 100644 index 0000000..4746d58 --- /dev/null +++ b/Nozomi9967/templates/html/menu.html @@ -0,0 +1,33 @@ +{{define "menu"}} + + + + + 主界面 + + + + +
+ + +
+ + + + + + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/modify.html b/Nozomi9967/templates/html/modify.html new file mode 100644 index 0000000..f2fc4ba --- /dev/null +++ b/Nozomi9967/templates/html/modify.html @@ -0,0 +1,111 @@ +{{define "Modif_page"}} + + + + + 修改页面 + + + + + +
+
+ +
+ +
+ +
+
+ +
+
+ + + + + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/postpage.html b/Nozomi9967/templates/html/postpage.html new file mode 100644 index 0000000..7ce2034 --- /dev/null +++ b/Nozomi9967/templates/html/postpage.html @@ -0,0 +1,309 @@ +{{define "Post_page"}} + + + + + 帖子 + + + + + + +
+
+
+
+ +
+
+ +
+ + +
+ +
评论区
+ + +
+ + +
+ + + +
+
    + +
+
+ + + +
+ + + + + +
+ +
+ + +
+ +
+ + + +
+ + + + + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/postquestion.html b/Nozomi9967/templates/html/postquestion.html new file mode 100644 index 0000000..616329d --- /dev/null +++ b/Nozomi9967/templates/html/postquestion.html @@ -0,0 +1,106 @@ +{{define "postquestion"}} + + + + + 问题发布 + + + + + +
+
+ +
+ +
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/regis.html b/Nozomi9967/templates/html/regis.html new file mode 100644 index 0000000..7f23468 --- /dev/null +++ b/Nozomi9967/templates/html/regis.html @@ -0,0 +1,85 @@ +{{define "regis"}} + + + + + 注册页面 + + + + + +
+
+ +
+ 账号 +
+ +
+ +
密码
+ + +
+ + + + + +
+ + +{{end}} \ No newline at end of file diff --git a/Nozomi9967/templates/html/selfinfo.html b/Nozomi9967/templates/html/selfinfo.html new file mode 100644 index 0000000..973860c --- /dev/null +++ b/Nozomi9967/templates/html/selfinfo.html @@ -0,0 +1,14 @@ +{{define "selfinfo"}} + + + + + 个人信息 + + + 这是个人界面 + + + + +{{end}} \ No newline at end of file