【feat】 添加postgresql数据库支持,【修复】pg数据库的代码生成功能

This commit is contained in:
PandaX
2023-11-10 10:07:38 +08:00
parent a37dace97c
commit 72ffbf38c3
15 changed files with 1323 additions and 724 deletions

View File

@@ -237,6 +237,9 @@ func GetDeviceToken(data *entity.Device) *model.DeviceAuth {
// 获取设备数量统计
func (m *deviceModelImpl) FindDeviceCount() (result entity.DeviceCount) {
sql := `SELECT COUNT(*) AS total, (SELECT COUNT(*) FROM devices WHERE DATE(create_time) = CURDATE()) AS today FROM devices`
if global.Conf.Server.DbType == "postgresql" {
sql = `SELECT COUNT(*) AS total, (SELECT COUNT(*) FROM devices WHERE DATE(create_time) = current_date) AS today FROM devices`
}
err := global.Db.Raw(sql).Scan(&result).Error
biz.ErrIsNil(err, "获取设备统计总数失败")
return result