master
wangshuai 5 years ago
parent 48c056fb0b
commit bb68ebffdd

@ -336,7 +336,7 @@ func DataexCollect(systemID string,users []MySwagger.User,events []MySwagger.Eve
func DataexSetBatch(systemID string, datas []MySwagger.Data,datasource *models.TDataexDatasource)(bool,string,[]string,[]MySwagger.FailResult) {
//add by zhangjun 2020-07-15
//处理组织机构树同步
if datasource.DatasourceCode=="org_school2" && systemID=="BASE_GO"{
if datasource.DatasourceCode=="org_school" && systemID=="BASE_GO"{
OrgtreeProcBatch(datas)
}
if datasource.DatasourceCode=="org_school_lua" && systemID=="BASE_LUA"{

@ -41,3 +41,6 @@ project_name = dsSupport
ip = 127.0.0.1
port = 8001
[account]
users = admin:dsideal,administrator:dsideal123@321

@ -0,0 +1,23 @@
/**
* @Title:
* @Description:
* @Author: Yuki Wong(iyuki0430@msn.com)
* @Update:
* @Date: 2020/7/20 11:49
* @File: AccountController.go
* @Software: GoLand
**/
package AccountController
import (
"dsSupport/MyModel/Account/AccountOpenAPI"
"github.com/gin-gonic/gin"
)
func Routers(r *gin.RouterGroup) {
rr := r.Group("/openapi")
rr.POST("/account/login", AccountOpenAPI.Login)
return
}

@ -0,0 +1,45 @@
/**
* @Title:
* @Description:
* @Author: Yuki Wong(iyuki0430@msn.com)
* @Update:
* @Date: 2020/7/20 11:49
* @File: AccountDAO.go
* @Software: GoLand
**/
package AccountDAO
import (
"dsSupport/Utils/ConfigUtil"
"dsSupport/Utils/DbUtil"
"strings"
)
//数据库
var db = DbUtil.Engine
func Login(username string, password string) (bool, string) {
var flag bool
var msg string
if username != "" && password != ""{
flag = false
msg = "账号或密码不能为空"
}
if len(ConfigUtil.AccountUsers) > 0 {
for _, v := range ConfigUtil.AccountUsers {
UserPwd := strings.Split(v, ":")
if UserPwd[0] == username && UserPwd[1] == password {
flag = true
msg = "登陆成功"
}
}
} else {
flag = false
msg = "配置文件错误"
}
return flag, msg
}

@ -0,0 +1,62 @@
/**
* @Title:
* @Description:
* @Author: Yuki Wong(iyuki0430@msn.com)
* @Update:
* @Date: 2020/7/20 11:50
* @File: AccountOpenAPI.go
* @Software: GoLand
**/
package AccountOpenAPI
import (
"dsSupport/MyModel/Account/AccountService"
"dsSupport/MyModel/MySwagger"
"github.com/gin-gonic/gin"
"net/http"
)
// 后台登陆 godoc
// @Summary 后台登陆
// @Description json:"username" xorm:"not null comment('账号') VARCHAR(100)" example:"example"
// @Description json:"password" xorm:"not null comment('密码') VARCHAR(100)" example:"123456"
// @Tags account
// @ID loginAccount
// @Accept json
// @Produce json
// @Param input body MySwagger.AccountSwag true "账号密码"
// @Success 200 {object} MySwagger.Result
// @Failure 400 {object} MySwagger.Result
// @Router /v1/openapi/datasource/ReadESDoc [post]
func Login(c *gin.Context) {
var raw MySwagger.AccountSwag
if err := c.ShouldBindJSON(&raw); err != nil {
c.JSON(http.StatusBadRequest, MySwagger.Result{Success: false, Message: "接入系统数据JSON格式错误"})
return
}
username := raw.Username
password := raw.Password
success, _ := AccountService.Login(username, password)
if success {
c.JSON(http.StatusOK, gin.H{
"status" : "ok",
"type" : "account",
"currentAuthority" : username,
})
return
} else {
c.JSON(http.StatusOK, gin.H{
"status" : "error",
"type" : "account",
"currentAuthority" : "guest",
})
return
}
return
}

@ -0,0 +1,21 @@
/**
* @Title:
* @Description:
* @Author: Yuki Wong(iyuki0430@msn.com)
* @Update:
* @Date: 2020/7/20 11:50
* @File: AccountService.go
* @Software: GoLand
**/
package AccountService
import (
"dsSupport/MyModel/Account/AccountDAO"
)
func Login(username string, password string) (bool, string) {
result, message := AccountDAO.Login(username, password)
return result, message
}

@ -12,6 +12,7 @@ func Routers(r *gin.RouterGroup) {
rr := r.Group("/login")
//配置接口
rr.POST("/DoLogin", DoLogin)
return
}

@ -63,3 +63,4 @@ func Login(username string, password string) (bool, string, string, string, erro
}
}
}

@ -0,0 +1,16 @@
/**
* @Title: AccountSwag
* @Description:
* @Author: Yuki Wong(iyuki0430@msn.com)
* @Update:
* @Date: 2020/7/9 10:24
* @File: Jyt2012Swag.go
* @Software: GoLand
**/
package MySwagger
type AccountSwag struct {
Username string `json:"username" xorm:"not null comment('账号') VARCHAR(100)" example:"example"`
Password string `json:"password" xorm:"not null comment('密码') VARCHAR(100)" example:"123456"`
}

@ -47,12 +47,14 @@ var (
//ES Nodes 地址
ESNodes string
ESAddress []string
//rpc服务IP和端口
RpcServerIp string
RpcServerPort string
AccountNodes string
AccountUsers []string
)
func init() {
@ -117,6 +119,10 @@ func init() {
RpcServerIp = iniParser.GetString("rpcServer", "ip")
//rpc服务器的端口
RpcServerPort = iniParser.GetString("rpcServer", "port")
// 数据中心后台登陆账号密码
AccountNodes = iniParser.GetString("account", "users")
AccountUsers = strings.Split(AccountNodes, ",")
}
type IniParser struct {

@ -1227,6 +1227,47 @@ var doc = `{
]
}
},
"/support/login/account": {
"post": {
"description": "json:\"datasource_name\" xorm:\"not null comment('数据源名称') VARCHAR(100)\" example:\"组织机构信息\"\njson:\"datasource_code\" xorm:\"not null comment('数据源编码') VARCHAR(8)\" example:\"org_tree\"",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"登录"
],
"summary": "登录",
"operationId": "Account",
"parameters": [
{
"description": "登录",
"name": "input",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MySwagger.AccountSwag"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/MySwagger.Result"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/MySwagger.Result"
}
}
}
}
},
"/v1/openapi/dataaccess/CreateDataaccess": {
"post": {
"description": "` + "`" + `*` + "`" + `json:\"datasource_id\" xorm:\"not null comment('数据源ID') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\n` + "`" + `*` + "`" + `json:\"datasource_code\" xorm:\"comment('数据源编码') default 'NULL' VARCHAR(255)\"\n` + "`" + `*` + "`" + `json:\"` + "`" + `source_systemid` + "`" + `\" xorm:\"not null comment('源系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\n` + "`" + `*` + "`" + `json:\"` + "`" + `consume_systemid` + "`" + `\" xorm:\"not null comment('数据使用系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"query_flag\" xorm:\"not null default 1 comment('可查【1-1否】') INT(11)\" example:\"1\"\njson:\"set_flag\" xorm:\"not null default -1 comment('可修改【1-1否】') INT(11)\" example:\"1\"\n` + "`" + `*` + "`" + `json:\"consume_type\" xorm:\"not null comment('使用数据范围【1本机构2本机构以及下属机构-1不限制】') INT(11)\" example:\"-1\"\n` + "`" + `*` + "`" + `json:\"consume_orgid\" xorm:\"not null comment('使用数据机构ID【-1不限制】') index VARCHAR(36)\" example:\"-1\"\njson:\"create_time\" xorm:\"default 'NULL' created comment('建立时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"change_time\" xorm:\"default 'NULL' updated comment('最近修改时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_time\" xorm:\"default 'NULL' deleted comment('删除时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_flag\" xorm:\"not null default -1 comment('删除标志【默认-11删除-1正常】') INT(11)\" example:\"1\"\njson:\"enable_flag\" xorm:\"not null default 1 comment('启用标志【默认11启用-1禁用】') INT(11)\" example:\"1\"",
@ -2347,6 +2388,19 @@ var doc = `{
}
}
},
"MySwagger.AccountSwag": {
"type": "object",
"properties": {
"password": {
"type": "string",
"example": "123456"
},
"username": {
"type": "string",
"example": "example"
}
}
},
"MySwagger.DataaccessSwag": {
"type": "object",
"properties": {

@ -1211,6 +1211,47 @@
]
}
},
"/support/login/account": {
"post": {
"description": "json:\"datasource_name\" xorm:\"not null comment('数据源名称') VARCHAR(100)\" example:\"组织机构信息\"\njson:\"datasource_code\" xorm:\"not null comment('数据源编码') VARCHAR(8)\" example:\"org_tree\"",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"登录"
],
"summary": "登录",
"operationId": "Account",
"parameters": [
{
"description": "登录",
"name": "input",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MySwagger.AccountSwag"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/MySwagger.Result"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/MySwagger.Result"
}
}
}
}
},
"/v1/openapi/dataaccess/CreateDataaccess": {
"post": {
"description": "`*`json:\"datasource_id\" xorm:\"not null comment('数据源ID') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\n`*`json:\"datasource_code\" xorm:\"comment('数据源编码') default 'NULL' VARCHAR(255)\"\n`*`json:\"`source_systemid`\" xorm:\"not null comment('源系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\n`*`json:\"`consume_systemid`\" xorm:\"not null comment('数据使用系统编码') index VARCHAR(36)\" example:\"F38BD0DB-0142-4356-8F2B-623813FC2578\"\njson:\"query_flag\" xorm:\"not null default 1 comment('可查【1-1否】') INT(11)\" example:\"1\"\njson:\"set_flag\" xorm:\"not null default -1 comment('可修改【1-1否】') INT(11)\" example:\"1\"\n`*`json:\"consume_type\" xorm:\"not null comment('使用数据范围【1本机构2本机构以及下属机构-1不限制】') INT(11)\" example:\"-1\"\n`*`json:\"consume_orgid\" xorm:\"not null comment('使用数据机构ID【-1不限制】') index VARCHAR(36)\" example:\"-1\"\njson:\"create_time\" xorm:\"default 'NULL' created comment('建立时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"change_time\" xorm:\"default 'NULL' updated comment('最近修改时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_time\" xorm:\"default 'NULL' deleted comment('删除时间') DATETIME\" example:\"2020-06-22 17:26:53\"\njson:\"delete_flag\" xorm:\"not null default -1 comment('删除标志【默认-11删除-1正常】') INT(11)\" example:\"1\"\njson:\"enable_flag\" xorm:\"not null default 1 comment('启用标志【默认11启用-1禁用】') INT(11)\" example:\"1\"",
@ -2331,6 +2372,19 @@
}
}
},
"MySwagger.AccountSwag": {
"type": "object",
"properties": {
"password": {
"type": "string",
"example": "123456"
},
"username": {
"type": "string",
"example": "example"
}
}
},
"MySwagger.DataaccessSwag": {
"type": "object",
"properties": {

@ -28,6 +28,15 @@ definitions:
description: omitempty有值就输出没值则不输出
type: object
type: object
MySwagger.AccountSwag:
properties:
password:
example: "123456"
type: string
username:
example: example
type: string
type: object
MySwagger.DataaccessSwag:
properties:
change_time:
@ -1116,6 +1125,35 @@ paths:
- 2
x-tablename:
- t_app_base
/support/login/account:
post:
consumes:
- application/json
description: |-
json:"datasource_name" xorm:"not null comment('数据源名称') VARCHAR(100)" example:"组织机构信息"
json:"datasource_code" xorm:"not null comment('数据源编码') VARCHAR(8)" example:"org_tree"
operationId: Account
parameters:
- description: 登录
in: body
name: input
required: true
schema:
$ref: '#/definitions/MySwagger.AccountSwag'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/MySwagger.Result'
"400":
description: Bad Request
schema:
$ref: '#/definitions/MySwagger.Result'
summary: 登录
tags:
- 登录
/v1/openapi/dataaccess/CreateDataaccess:
post:
consumes:

@ -1,6 +1,7 @@
package main
import (
"dsSupport/MyModel/Account/AccountController"
"dsSupport/MyModel/DataAccess/DataaccessController"
"dsSupport/MyModel/DataError/DataerrorController"
"dsSupport/MyModel/DataSource/DatasourceController"
@ -41,6 +42,8 @@ import (
// @tag.description 元数据
// @tag.name orgtree
// @tag.description 机构目录
// @tag.name account
// @tag.description 后台登陆
// @host 127.0.0.1:8005
func main() {
// 发布模式
@ -83,6 +86,9 @@ func main() {
// 数据统计
DatastatisticController.Routers(rgroup)
// 后台登陆
AccountController.Routers(rgroup)
//注册swagger
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

Loading…
Cancel
Save