You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package SyncController
import (
"dsAutoCode/Model"
"dsAutoCode/Service/SyncService"
"github.com/gin-gonic/gin"
"net/http"
)
//模块的路由配置
func Routers ( r * gin . RouterGroup ) {
rr := r . Group ( "/sync" )
//注册get方法
rr . GET ( "/SyncData" , SyncData )
rr . GET ( "/CheckNew" , CheckNew )
return
}
//检查是不是有文件的内容变更
func CheckNew ( c * gin . Context ) {
change := SyncService . CheckNew ( )
if change {
c . JSON ( http . StatusOK , Model . Res {
Code : http . StatusOK ,
Count : 1 ,
Msg : "系统检查到参数文件有变化,将同步到系统,请稍侯..." ,
} )
} else {
c . JSON ( http . StatusOK , Model . Res {
Code : http . StatusOK ,
Count : 0 ,
Msg : "系统检查到参数文件与系统记录的无变化。" ,
} )
}
}
/**
功能:同步数据
作者:黄海
时间: 2020-04-27
*/
func SyncData ( c * gin . Context ) {
//1、清空
SyncService . SwaggerTableClear ( )
SyncService . ProtoTableClear ( )
//2、初始化
SyncService . SwaggerTableToDb ( )
SyncService . ProtoTableToDb ( )
//3、记录最后的修改时间
SyncService . WriteLastUpdateTimeLog ( )
//4、返回回执信息
c . JSON ( http . StatusOK , Model . Res {
Code : http . StatusOK ,
Msg : "同步成功!" ,
} )
}