调整
This commit is contained in:
parent
898e8d31f0
commit
d7879c8945
9
bin/adminserver/config/confdb.mysql.json
Normal file
9
bin/adminserver/config/confdb.mysql.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"host": "mysql-test.kingsome.cn",
|
||||||
|
"port": 3306,
|
||||||
|
"user": "root",
|
||||||
|
"passwd": "keji178",
|
||||||
|
"database": "confdb_dev_1",
|
||||||
|
"max_open_conns": 1,
|
||||||
|
"max_idle_conns": 1
|
||||||
|
}
|
@ -36,7 +36,7 @@
|
|||||||
],
|
],
|
||||||
"special": {
|
"special": {
|
||||||
"api": [],
|
"api": [],
|
||||||
"ui": ["-addannouncement", "-editannouncement", "-addaudit", "-editaudit"]
|
"ui": ["addannouncement", "editannouncement", "addaudit", "editaudit"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ func (this *AnncApi) AddAnnc(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.CONF_DB).Table(annc.TableName()).Where("model = ?", annc.Model).Where("type = ?", annc.Type).Count(&count)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
|
db.Table(annc.TableName()).Where("model = ?", annc.Model).Where("type = ?", annc.Type).Count(&count)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
@ -49,7 +50,7 @@ func (this *AnncApi) AddAnnc(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(&annc).Error
|
err := db.Create(&annc).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
@ -67,7 +68,16 @@ func (this *AnncApi) UpdateAnnc(c *gin.Context) {
|
|||||||
idx, _ := strconv.ParseUint(c.Param("idx"), 10, 64)
|
idx, _ := strconv.ParseUint(c.Param("idx"), 10, 64)
|
||||||
var count int64
|
var count int64
|
||||||
annc := system.Annc{}
|
annc := system.Annc{}
|
||||||
f5.GetApp().GetOrmDb(constant.CONF_DB).Table(annc.TableName()).Where("idx = ?", idx).Count(&count)
|
if err := c.ShouldBindJSON(&annc); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"code": 1,
|
||||||
|
"message": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
|
db.Table(annc.TableName()).Where("idx = ?", idx).Count(&count)
|
||||||
if count < 1 {
|
if count < 1 {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
@ -76,14 +86,16 @@ func (this *AnncApi) UpdateAnnc(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.ShouldBindJSON(&annc); err != nil {
|
db.Table(annc.TableName()).Where("idx != ?", idx).Where("model = ?", annc.Model).Where("type = ?", annc.Type).Count(&count)
|
||||||
|
if count > 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": "已有同类型的公告",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := f5.GetApp().GetOrmDb(constant.CONF_DB).Select("*").Omit("idx").Where("idx = ?", idx).Updates(&annc).Error
|
|
||||||
|
err := db.Select("*").Omit("idx").Where("idx = ?", idx).Updates(&annc).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
|
@ -40,7 +40,8 @@ func (this *AuditApi) AddAudit(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.CONF_DB).Table(audit.TableName()).Where("model = ?", audit.Model).Count(&count)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
|
db.Table(audit.TableName()).Where("model = ?", audit.Model).Count(&count)
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
@ -49,7 +50,7 @@ func (this *AuditApi) AddAudit(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := f5.GetApp().GetOrmDb(constant.CONF_DB).Create(&audit).Error
|
err := db.Create(&audit).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
@ -66,8 +67,16 @@ func (this *AuditApi) AddAudit(c *gin.Context) {
|
|||||||
func (this *AuditApi) UpdateAudit(c *gin.Context) {
|
func (this *AuditApi) UpdateAudit(c *gin.Context) {
|
||||||
idx, _ := strconv.ParseUint(c.Param("idx"), 10, 64)
|
idx, _ := strconv.ParseUint(c.Param("idx"), 10, 64)
|
||||||
audit := system.Audit{}
|
audit := system.Audit{}
|
||||||
|
if err := c.ShouldBindJSON(&audit); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"code": 1,
|
||||||
|
"message": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
var count int64
|
var count int64
|
||||||
f5.GetApp().GetOrmDb(constant.CONF_DB).Table(audit.TableName()).Where("idx = ?", idx).Count(&count)
|
db := f5.GetApp().GetOrmDb(constant.CONF_DB)
|
||||||
|
db.Table(audit.TableName()).Where("idx = ?", idx).Count(&count)
|
||||||
if count < 1 {
|
if count < 1 {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
@ -76,14 +85,16 @@ func (this *AuditApi) UpdateAudit(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.ShouldBindJSON(&audit); err != nil {
|
db.Table(audit.TableName()).Where("idx != ?", idx).Where("model = ?", audit.Model).Count(&count)
|
||||||
|
if count > 0 {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
"message": err.Error(),
|
"message": "已有同类型审核",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err := f5.GetApp().GetOrmDb(constant.CONF_DB).Select("*").Omit("idx").Where("idx = ?", idx).Updates(&audit).Error
|
|
||||||
|
err := db.Select("*").Omit("idx").Where("idx = ?", idx).Updates(&audit).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"code": 1,
|
"code": 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user