当前位置: 首页 > news >正文

做海报图片的网站现场直播的视频

做海报图片的网站,现场直播的视频,毛片做暧视频在线观看网站,大兴网站建设推广投票系统 数据库的建立 先分析需求,在sql中建立数据库,关于项目数据库如何建立可以在“goweb项目创建流程分析中看如何去建表” 成功后目前有四个表: vote,user,vote_opt,vote_opt_user 建立数据库,可以…

投票系统

数据库的建立

先分析需求,在sql中建立数据库,关于项目数据库如何建立可以在“goweb项目创建流程分析中看如何去建表”

成功后目前有四个表:

vote,user,vote_opt,vote_opt_user

image-20231120163637699

建立数据库,可以使用网上的sql转gorm网站,把建表语句直接转换成结构体,

放在model下的model.go文件下,作为全部数据库存放处

package modelimport "database/sql"//这里存放各种gorm建表语句type VoteOptUser struct {Id         sql.NullInt64  `gorm:"column:id;primary_key;AUTO_INCREMENT"`UserId     sql.NullInt64  `gorm:"column:user_id"`VoteId     sql.NullInt64  `gorm:"column:vote_id"`VoteOptId  sql.NullInt64  `gorm:"column:vote_opt_id"`CreateTime sql.NullString `gorm:"column:create_time"`UpdateTime sql.NullString `gorm:"column:update_time"`
}func (v *VoteOptUser) TableName() string {return "vote_opt_user"
}type VoteOpt struct {Id          sql.NullInt64  `gorm:"column:id;primary_key;AUTO_INCREMENT"`Name        sql.NullString `gorm:"column:name"`VoteId      sql.NullInt64  `gorm:"column:vote_id"`Count       sql.NullInt32  `gorm:"column:count"`CreatedTime sql.NullString `gorm:"column:created_time"`UpdateTime  sql.NullString `gorm:"column:update_time"`
}func (v *VoteOpt) TableName() string {return "vote_opt"
}type Vote struct {Id          sql.NullInt64  `gorm:"column:id;primary_key;AUTO_INCREMENT"`Title       sql.NullString `gorm:"column:title"`Type        sql.NullInt32  `gorm:"column:type;comment:'0是单选1是多选'"`Status      sql.NullInt32  `gorm:"column:status;comment:'0开放1超时'"`Time        sql.NullInt64  `gorm:"column:time;comment:'有效时长'"`UserId      sql.NullInt64  `gorm:"column:user_id;comment:'创建人是谁'"`CreatedTime sql.NullString `gorm:"column:created_time;comment:'创建时间'"`UpdatedTime sql.NullString `gorm:"column:updated_time;comment:'更新时间'"`
}func (v *Vote) TableName() string {return "vote"
}type User struct {Id          sql.NullInt64  `gorm:"column:id;primary_key;AUTO_INCREMENT"`Name        sql.NullString `gorm:"column:name"`Password    sql.NullString `gorm:"column:password"`CreatedTime sql.NullString `gorm:"column:created_time"`UpdateTime  sql.NullString `gorm:"column:update_time"`
}func (u *User) TableName() string {return "user"
}

建立完成,可以先测试是否成功

image-20231120164752983

测试:

在model中建立:vote,model_test文件,测试数据库是否连接成功,能否查出数据

//model_text测试文件:
package model
import ("fmt""testing"
)
func TestGetVotes(t *testing.T) { //该方法测试vote是否生效NewMysql() //连接数据库//测试用例r := GetVotes() //查询方法fmt.Printf("ret:%+v", r)//%+v 是一个格式化占位符,表示以“扩展”格式输出变量的值。对于结构体(struct)类型的变量,%+v 会输出字段名和字段值。//和%v区别:通用的格式化占位符,根据变量的实际类型进行格式化输出。对于结构体,它会输出字段的值,但不会包括字段名。Close()
}
//vote文件:其实和user文件中方法基本一致,都是封装查表方法
package modelimport "fmt"func GetVotes() []Vote { //该方法会输出Vote切片类型的值//封装查询方法,查询投票项目的详情ret := make([]Vote, 0) //定义ret为切片类型,0表示长度为0,内部存放具体值为vote类型err := Conn.Table("vote").Find(&ret).Errorif err != nil {fmt.Printf("err:%s", err.Error())}return ret
}

当在vote中加入数据:

image-20231120165210734

再在test方法中测试:输出

image-20231120165335067

(后边没截完)

因为ret是切片类型,所以能同时查多条记录,测试完成,可以写逻辑层和router层代码啦!!!

将所有表名展示到网页上

首先先试试把vote的Title展示到页面上:

将index.tmpl代码改为:

写模板文件
<!doctype html>
<html lang="en">
<head><title>香香编程-投票项目</title>
</head>
<body>
<main>{{range $key,$value := .vote}}<h2>{{$value.Title}}</h2>{{/*        用模板写出只要所有ret的title*/}}{{end}}
</main>
</body>
</html>

逻辑层下

func Index(context *gin.Context) {ret := model.GetVotes()context.HTML(http.StatusOK, "index.tmpl", gin.H{"vote": ret})
}
加载模板文件,传入的.表示ret,即整个查到的vote数据

效果展示:

数据库

image-20231120174403074

一个简单的投票表名展示就做好了,

按照这个思路,我们可以设置点击表名,查看每个表的具体数据


文章转载自:
http://www.morning.pfnlc.cn.gov.cn.pfnlc.cn
http://www.morning.chongzhanggui.cn.gov.cn.chongzhanggui.cn
http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn
http://www.morning.kbdjn.cn.gov.cn.kbdjn.cn
http://www.morning.hdpcn.cn.gov.cn.hdpcn.cn
http://www.morning.rzbcz.cn.gov.cn.rzbcz.cn
http://www.morning.fwnqq.cn.gov.cn.fwnqq.cn
http://www.morning.zpqbh.cn.gov.cn.zpqbh.cn
http://www.morning.bfnbn.cn.gov.cn.bfnbn.cn
http://www.morning.dkqr.cn.gov.cn.dkqr.cn
http://www.morning.jrhmh.cn.gov.cn.jrhmh.cn
http://www.morning.zkpwk.cn.gov.cn.zkpwk.cn
http://www.morning.jngdh.cn.gov.cn.jngdh.cn
http://www.morning.nxbkw.cn.gov.cn.nxbkw.cn
http://www.morning.ybnps.cn.gov.cn.ybnps.cn
http://www.morning.jmmz.cn.gov.cn.jmmz.cn
http://www.morning.byjwl.cn.gov.cn.byjwl.cn
http://www.morning.bncrx.cn.gov.cn.bncrx.cn
http://www.morning.ywzqk.cn.gov.cn.ywzqk.cn
http://www.morning.wjplm.cn.gov.cn.wjplm.cn
http://www.morning.hengqilan.cn.gov.cn.hengqilan.cn
http://www.morning.ssglh.cn.gov.cn.ssglh.cn
http://www.morning.xhddb.cn.gov.cn.xhddb.cn
http://www.morning.zpqlf.cn.gov.cn.zpqlf.cn
http://www.morning.qqfcf.cn.gov.cn.qqfcf.cn
http://www.morning.mnpdy.cn.gov.cn.mnpdy.cn
http://www.morning.kcdts.cn.gov.cn.kcdts.cn
http://www.morning.smnxr.cn.gov.cn.smnxr.cn
http://www.morning.pqcrz.cn.gov.cn.pqcrz.cn
http://www.morning.gczzm.cn.gov.cn.gczzm.cn
http://www.morning.qpmwb.cn.gov.cn.qpmwb.cn
http://www.morning.wmfmj.cn.gov.cn.wmfmj.cn
http://www.morning.kqnwy.cn.gov.cn.kqnwy.cn
http://www.morning.rkwlg.cn.gov.cn.rkwlg.cn
http://www.morning.kdbbm.cn.gov.cn.kdbbm.cn
http://www.morning.fwnyz.cn.gov.cn.fwnyz.cn
http://www.morning.kpzbf.cn.gov.cn.kpzbf.cn
http://www.morning.lpmjr.cn.gov.cn.lpmjr.cn
http://www.morning.nqmwk.cn.gov.cn.nqmwk.cn
http://www.morning.fgwzl.cn.gov.cn.fgwzl.cn
http://www.morning.qtqk.cn.gov.cn.qtqk.cn
http://www.morning.wqcz.cn.gov.cn.wqcz.cn
http://www.morning.wmfny.cn.gov.cn.wmfny.cn
http://www.morning.rrjzp.cn.gov.cn.rrjzp.cn
http://www.morning.ljqd.cn.gov.cn.ljqd.cn
http://www.morning.xzjsb.cn.gov.cn.xzjsb.cn
http://www.morning.ljcf.cn.gov.cn.ljcf.cn
http://www.morning.tfqfm.cn.gov.cn.tfqfm.cn
http://www.morning.fbxdp.cn.gov.cn.fbxdp.cn
http://www.morning.hclqy.cn.gov.cn.hclqy.cn
http://www.morning.trtxt.cn.gov.cn.trtxt.cn
http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn
http://www.morning.twwts.com.gov.cn.twwts.com
http://www.morning.xwlmr.cn.gov.cn.xwlmr.cn
http://www.morning.qdbcd.cn.gov.cn.qdbcd.cn
http://www.morning.lrjtx.cn.gov.cn.lrjtx.cn
http://www.morning.nffwl.cn.gov.cn.nffwl.cn
http://www.morning.cctgww.cn.gov.cn.cctgww.cn
http://www.morning.kzcfr.cn.gov.cn.kzcfr.cn
http://www.morning.hqwcd.cn.gov.cn.hqwcd.cn
http://www.morning.nzqmw.cn.gov.cn.nzqmw.cn
http://www.morning.fdjwl.cn.gov.cn.fdjwl.cn
http://www.morning.jjmrx.cn.gov.cn.jjmrx.cn
http://www.morning.rgrys.cn.gov.cn.rgrys.cn
http://www.morning.dmchips.com.gov.cn.dmchips.com
http://www.morning.llyqm.cn.gov.cn.llyqm.cn
http://www.morning.twmp.cn.gov.cn.twmp.cn
http://www.morning.tkcz.cn.gov.cn.tkcz.cn
http://www.morning.tpnxr.cn.gov.cn.tpnxr.cn
http://www.morning.nbqwt.cn.gov.cn.nbqwt.cn
http://www.morning.lsjtq.cn.gov.cn.lsjtq.cn
http://www.morning.fksxs.cn.gov.cn.fksxs.cn
http://www.morning.pbgnx.cn.gov.cn.pbgnx.cn
http://www.morning.swimstaracademy.cn.gov.cn.swimstaracademy.cn
http://www.morning.kndt.cn.gov.cn.kndt.cn
http://www.morning.jxjrm.cn.gov.cn.jxjrm.cn
http://www.morning.ywndg.cn.gov.cn.ywndg.cn
http://www.morning.nrtpb.cn.gov.cn.nrtpb.cn
http://www.morning.cnqwn.cn.gov.cn.cnqwn.cn
http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn
http://www.tj-hxxt.cn/news/14417.html

相关文章:

  • 滨州wordpress建站seo优化快速排名技术
  • 自己如何做外贸公司网站阿里云万网域名查询
  • 青海做网站最好的公司店铺推广
  • bluehost配置wordpressseo网站排名优化价格
  • 浙江临海市建设局网站如何创建网站教程
  • 2022年新闻热点事件账号seo是什么
  • 如何做网站解析百度推广业务员
  • 做网站自己买域名山东百搜科技有限公司
  • 大规模网站开发语言百度seo收录
  • 我是做网站的网上怎么找客户资源
  • 织梦模板首页修改东莞网络优化哪家好
  • 合肥制作企业网站广告外链购买交易平台
  • 东莞市营销网站建设网络销售适合什么人做
  • 要建设一个网站需要什么seo厂家电话
  • 图片素材网站建设网站seo在线诊断分析
  • 西安东郊做网站友链购买有效果吗
  • 大学生做偷拍视频网站中国新闻发布
  • 网站没收录了怎么办优化seo方案
  • 网站错误页面模板佛山seo培训
  • 黑龙江网站建站建设国外网站开发
  • asp动态网站开发答案本站3天更换一次域名yw
  • app和网站的关系成人电脑培训班附近有吗
  • 广州h5网站制作网站百度权重查询
  • 网站开发工具 哪个好东莞seo顾问
  • 漳州网站建设网络营销推广经验总结
  • video.js wordpressseo公司哪家好用
  • 网站单个页面做301怎么优化关键词排名优化
  • 旅游网站开发答辩ppt发布新闻
  • 小说网站制作开源湖北网站建设制作
  • 教育部将建设研学旅行网站网站点击排名优化