Git Product home page Git Product logo

Comments (2)

zhaoyangkun avatar zhaoyangkun commented on August 28, 2024

很抱歉,该部分代码存在问题,我会在下一个版本中修复。

出现问题的原因为:gorm 设置 mysql 时区参数 loc 的值时需进行 UrlEncode

解决办法为:对时区参数 loc 的值进行 Url 编码,需要手动修改项目路径下的 config/db/db.go 中的相关代码:

import "net/url"

// 获取数据库连接
func getDataSource() string {
	dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?parseTime=true&loc=%s",
		setting.Config.Database.UserName,
		setting.Config.Database.Password,
		setting.Config.Database.Host,
		setting.Config.Database.Port,
		setting.Config.Database.Database,
		url.QueryEscape(setting.Config.Database.TimeZone), // 对时区进行 Url 编码
	)
	return dataSource
}

from aries.

zhaoyangkun avatar zhaoyangkun commented on August 28, 2024

修改完代码之后,在 develop.yaml 配置文件中将时区 timezone 设置为 Asia/Shanghai 即可。

from aries.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.