diff --git a/dsBaseRpc/DataEx/DataEx.go b/dsBaseRpc/DataEx/DataEx.go new file mode 100644 index 00000000..daf8e51e --- /dev/null +++ b/dsBaseRpc/DataEx/DataEx.go @@ -0,0 +1,38 @@ +package DataEx + +import ( + "dsBaseRpc/Const" + "dsBaseRpc/Utils/DbUtil" + "dsBaseRpc/Utils/LogUtil" + "fmt" +) + +var db = DbUtil.Engine + +//有同步哪些表 +var sqlDict = []string{"t_base_organization", "t_base_class"} + +/** +功能:数据上报 +作者:黄海 +时间:2020-07-16 +*/ +func DataExchange() { + for { + //本轮上报的数量,如果是0,休息10秒后再继续上传 + count:=0 + //遍历所有的配置节,进行循环 + for i := range sqlDict { + //判断日志目录下的记录是不是存在? + + //存在则读取last_updated_time+id_int进行分页获取 + paramMap := map[string]interface{}{"last_updated_time": "2020-07-15 00:00:00"} + list, err := db.SqlMapClient(sqlDict[i], ¶mMap).Query().List() + if err != nil { + LogUtil.Error(Const.DataBaseActionError, "数据上报时发生了严重错误:"+err.Error()) + break + } + fmt.Println(list) + } + } +} diff --git a/dsBaseRpc/Sql/ds_base.xml b/dsBaseRpc/Sql/ds_base.xml new file mode 100644 index 00000000..6016d265 --- /dev/null +++ b/dsBaseRpc/Sql/ds_base.xml @@ -0,0 +1,79 @@ + + + SELECT + cast( `t_base_organization`.`org_id` AS CHAR ( 36 ) charset utf8 ) AS `org_id`, + `t_base_organization`.`id_int` AS `id_int`, + `t_base_organization`.`org_code` AS `org_code`, + `t_base_organization`.`org_name` AS `org_name`, + cast( `t_base_organization`.`parent_id` AS CHAR ( 36 ) charset utf8 ) AS `parent_id`, + cast( `t_base_organization`.`bureau_id` AS CHAR ( 36 ) charset utf8 ) AS `bureau_id`, + `t_base_organization`.`org_type` AS `org_type`, + `t_base_organization`.`edu_assist_type` AS `edu_assist_type`, + `t_base_organization`.`main_school_type` AS `main_school_type`, + cast( `t_base_organization`.`main_school_id` AS CHAR ( 36 ) charset utf8 ) AS `main_school_id`, + cast( `t_base_organization`.`manage_org_id` AS CHAR ( 36 ) charset utf8 ) AS `manage_org_id`, + `t_base_organization`.`directly_under_type` AS `directly_under_type`, + `t_base_organization`.`xxbbm` AS `xxbbm`, + `t_base_organization`.`xxbxlxm` AS `xxbxlxm`, + `t_base_organization`.`szdcxlxm` AS `szdcxlxm`, + `t_base_organization`.`xxjbzm` AS `xxjbzm`, + cast( `t_base_organization`.`fzr` AS CHAR ( 36 ) charset utf8 ) AS `fzr`, + `t_base_organization`.`fddbr` AS `fddbr`, + `t_base_organization`.`fddbrdh` AS `fddbrdh`, + `t_base_organization`.`address` AS `address`, + `t_base_organization`.`lxdh` AS `lxdh`, + `t_base_organization`.`org_lng` AS `org_lng`, + `t_base_organization`.`org_lat` AS `org_lat`, + `t_base_organization`.`sort_id` AS `sort_id`, + cast( `t_base_organization`.`b_use` AS signed ) AS `b_use`, + `t_base_organization`.`province_code` AS `province_code`, + `t_base_organization`.`city_code` AS `city_code`, + `t_base_organization`.`district_code` AS `district_code`, + `t_base_organization`.`area_code` AS `area_code`, + `t_base_organization`.`last_updated_time` AS `last_updated_time`, + DATE_FORMAT(`t_base_organization`.`create_time`,'%Y/%m/%d %H:%i:%s') AS `create_time`, + case `t_base_organization`.`b_use` when -1 then 1 else 0 end AS `del_flag` + FROM + `t_base_organization` + WHERE + `t_base_organization`.`last_updated_time`>?last_updated_time + ORDER BY + `t_base_organization`.`last_updated_time` + + + + SELECT + cast( `t_base_class`.`class_id` AS CHAR ( 36 ) charset utf8 ) AS `class_id`, + `t_base_class`.`id_int` AS `id_int`, + `t_base_class`.`bh` AS `bh`, + `t_base_class`.`class_code` AS `class_code`, + `t_base_class`.`class_name` AS `class_name`, + `t_base_class`.`class_alias` AS `class_alias`, + `t_base_class`.`rxnf` AS `rxnf`, + `t_base_class`.`rxjj` AS `rxjj`, + `t_base_class`.`schooling_length` AS `schooling_length`, + `t_base_class`.`stage_id` AS `stage_id`, + cast( `t_base_class`.`teacher_id` AS CHAR ( 36 ) charset utf8 ) AS `teacher_id`, + cast( `t_base_class`.`org_id` AS CHAR ( 36 ) charset utf8 ) AS `org_id`, + cast( `t_base_class`.`bureau_id` AS CHAR ( 36 ) charset utf8 ) AS `bureau_id`, + cast( `t_base_class`.`b_use` AS signed ) AS `b_use`, + `t_base_class`.`province_code` AS `province_code`, + `t_base_class`.`city_code` AS `city_code`, + `t_base_class`.`district_code` AS `district_code`, + cast( `t_base_class`.`main_school_id` AS CHAR ( 36 ) charset utf8 ) AS `main_school_id`, + DATE_FORMAT(`t_base_class`.`create_time`,'%Y/%m/%d %H:%i:%s') AS `create_time`, + `t_base_class`.`last_updated_time` AS `last_updated_time`, + `t_dm_stage`.`stage_name` AS `stage_name`, + `t_base_organization`.`org_name` AS `org_name` , + case `t_base_class`.`b_use` when -1 then 1 else 0 end AS `del_flag` + FROM + (( + `t_base_class` + JOIN `t_dm_stage` ON ( `t_base_class`.`stage_id` = `t_dm_stage`.`stage_id` )) + JOIN `t_base_organization` ON ( `t_base_class`.`bureau_id` = `t_base_organization`.`org_id` )) + WHERE + `t_base_class`.`last_updated_time`>?last_updated_time + ORDER BY + `t_base_class`.`last_updated_time` + + diff --git a/dsBaseRpc/Utils/DbUtil/DbUtil.go b/dsBaseRpc/Utils/DbUtil/DbUtil.go index 6ffbd525..a8d1c749 100644 --- a/dsBaseRpc/Utils/DbUtil/DbUtil.go +++ b/dsBaseRpc/Utils/DbUtil/DbUtil.go @@ -26,6 +26,12 @@ func init() { if err != nil { fmt.Println(err) } + //注册SqlMap配置,可选功能,如应用中无需使用SqlMap,可无需初始化 + err =Engine.RegisterSqlMap(xorm.Xml("./Sql", ".xml")) + if err != nil { + fmt.Println(err) + } + //设置数据库连接池 Engine.SetMaxOpenConns(100) //设置打开数据库的最大连接数,包含正在使用的连接和连接池的连接。 Engine.SetMaxIdleConns(10) //设置连接池中的保持连接的最大连接数。 diff --git a/dsBaseRpc/main.go b/dsBaseRpc/main.go index c25e93e7..eaab87ba 100644 --- a/dsBaseRpc/main.go +++ b/dsBaseRpc/main.go @@ -1,6 +1,7 @@ package main import ( + "dsBaseRpc/DataEx" "dsBaseRpc/RpcService/BaseClass/BaseClassProto" "dsBaseRpc/RpcService/BaseClass/BaseClassService" "dsBaseRpc/RpcService/BaseGlobal/BaseGlobalProto" @@ -96,9 +97,13 @@ func main() { //人员角色 BaseRolePersonProto.RegisterBaseRolePersonManageServer(s, &BaseRolePersonService.Rpc{}) - //五、 注册反射服务 这个服务是CLI使用的 跟服务本身没有关系 + //五、开启一个数据上报的协程 + go func() { + DataEx.DataExchange() + }() + //六、 注册反射服务 这个服务是CLI使用的 跟服务本身没有关系 reflection.Register(s) - //六、启动 + //七、启动 fmt.Printf("服务发布成功,端口:%s", ConfigUtil.RpcServerPort) if err := s.Serve(lis); err != nil { fmt.Printf("failed to serve: %v\n", err) diff --git a/dsBaseRpc/一键发布.cmd b/dsBaseRpc/一键发布.cmd index b01a303a..26dd3b0a 100644 --- a/dsBaseRpc/一键发布.cmd +++ b/dsBaseRpc/一键发布.cmd @@ -1,21 +1,22 @@ -:: Windows汾 -ldflags "-s -w" -go build -o ./WinBuild/Distribute.exe ./Tools/Distribute.go -:: .\Tools\upx.exe -9 ./WinBuild/Distribute.exe - -:: Linux汾 -SET GOOS=linux -SET GOARCH=amd64 -go build -o ./build/dsBaseRpc main.go - -:: ѹһ -:: .\Tools\upx.exe -9 ./build/dsBaseRpc - -:: Դļ -xcopy .\Shell\* .\build\ /y /e /i /q -xcopy .\Config\* .\build\Config /y /e /i /q -xcopy .\Xml\* .\build\Xml /y /e /i /q - -:: ϴļ -.\WinBuild\Distribute.exe - +:: Windows汾 -ldflags "-s -w" +go build -o ./WinBuild/Distribute.exe ./Tools/Distribute.go +:: .\Tools\upx.exe -9 ./WinBuild/Distribute.exe + +:: Linux汾 +SET GOOS=linux +SET GOARCH=amd64 +go build -o ./build/dsBaseRpc main.go + +:: ѹһ +:: .\Tools\upx.exe -9 ./build/dsBaseRpc + +:: Դļ +xcopy .\Shell\* .\build\ /y /e /i /q +xcopy .\Config\* .\build\Config /y /e /i /q +xcopy .\Xml\* .\build\Xml /y /e /i /q +xcopy .\Sql\* .\build\Sql /y /e /i /q + +:: ϴļ +.\WinBuild\Distribute.exe + pause \ No newline at end of file diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 4f28deac..b90b4207 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -316,10 +316,19 @@ func authorizePost(context *gin.Context) { if !success { context.JSON(http.StatusOK, Model.Res{ Code: http.StatusNotImplemented, - Msg: "用户名密码不正确!", + Msg: "用户名密码不正确或已禁用!", }) return } + + if CommonUtil.ConvertStringToInt(identityId)>1{ + context.JSON(http.StatusOK, Model.Res{ + Code: http.StatusNotImplemented, + Msg: "非管理员用户暂不能登录,敬请期待!!", + }) + return + } + } else { context.JSON(http.StatusOK, Model.Res{ Code: http.StatusNotImplemented,