|
|
package ProtoService
|
|
|
|
|
|
import (
|
|
|
"dsAutoCode/Dao/ProtoDao"
|
|
|
"dsAutoCode/Utils/CommonUtil"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
func GetOperateType(interfaceName string) string {
|
|
|
var operateType string
|
|
|
if strings.HasPrefix(interfaceName, "Add") {
|
|
|
operateType = "Add"
|
|
|
}
|
|
|
if strings.HasPrefix(interfaceName, "Delete") {
|
|
|
operateType = "Delete"
|
|
|
}
|
|
|
if strings.HasPrefix(interfaceName, "Update") {
|
|
|
operateType = "Update"
|
|
|
}
|
|
|
if strings.HasPrefix(interfaceName, "Page") {
|
|
|
operateType = "Page"
|
|
|
}
|
|
|
if strings.HasPrefix(interfaceName, "Get") {
|
|
|
operateType = "Get"
|
|
|
}
|
|
|
return operateType
|
|
|
}
|
|
|
|
|
|
//根据人员ID获取人员信息
|
|
|
func GetPersonInfoById(personId string) map[string]interface{} {
|
|
|
_map := ProtoDao.GetPersonInfoById(personId)
|
|
|
return _map
|
|
|
}
|
|
|
|
|
|
//获取参数名称与参数类型的对应map关系
|
|
|
func GetMapForParameterNameVsParameterType(list []map[string]interface{}) map[string]string {
|
|
|
var _map = make(map[string]string)
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
structParaName := CommonUtil.StrFirstToLower(list[i]["struct_parameter_name"].(string))
|
|
|
structParaType := list[i]["struct_parameter_type"].(string)
|
|
|
_map[structParaName] = structParaType
|
|
|
}
|
|
|
return _map
|
|
|
}
|
|
|
|
|
|
//根据接口ID获取对应的真实表名称
|
|
|
func GetTrueTableNameFromInterfaceId(interfaceId string) string {
|
|
|
var str = "t"
|
|
|
fileName := ProtoDao.GetTrueTableNameFromInterfaceId(interfaceId)
|
|
|
for _, ch := range fileName {
|
|
|
if ch >= 65 && ch <= 90 {
|
|
|
ch = ch + 32
|
|
|
str += "_"
|
|
|
}
|
|
|
str += string(ch)
|
|
|
}
|
|
|
return strings.Replace(str, ".pb.go", "", -1)
|
|
|
}
|
|
|
|
|
|
//获取指定接口对应表的主键描述符
|
|
|
func GetParameterByInterfaceId(interfaceId string) (bool, string, string, string) {
|
|
|
//1、根据接口ID获取FILE_ID
|
|
|
_, fileId := ProtoDao.GetStructIdByInterfaceId(interfaceId)
|
|
|
//2、获取指定 file_id下GetArg的结构体ID
|
|
|
success, message, structId := ProtoDao.GetStructIdByFileId(fileId)
|
|
|
//3、根据 structId获取参数
|
|
|
if success {
|
|
|
structParameterName, structParameterType := ProtoDao.GetStructParametersByStructId(structId)
|
|
|
return true, message, structParameterName, structParameterType
|
|
|
} else {
|
|
|
return false, message, "", ""
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:获取生成文件的位置
|
|
|
作者:黄海
|
|
|
时间:2020-04-23
|
|
|
*/
|
|
|
func GetGenereateCodePath(operateType string, TableName string) string {
|
|
|
var pathPrefix = CommonUtil.GetParentPath(CommonUtil.GetCurrentDirectory())
|
|
|
var CodePath string
|
|
|
if operateType == "ControllerFramework" || operateType == "Controller" || operateType == "Service" {
|
|
|
CodePath = pathPrefix + "\\dsBaseWeb\\Business\\#TableName#\\#TableName##type#\\#TableName##type#.go"
|
|
|
}
|
|
|
if operateType == "RpcService" || operateType == "Dao" {
|
|
|
CodePath = pathPrefix + "\\dsBaseRpc\\RpcService\\#TableName#\\#TableName#Service\\#TableName#ProtoService.go"
|
|
|
}
|
|
|
if operateType == "ControllerFramework" {
|
|
|
operateType = "Controller"
|
|
|
}
|
|
|
CodePath = strings.Replace(CodePath, "#TableName#", TableName, -1)
|
|
|
CodePath = strings.Replace(CodePath, "#type#", operateType, -1)
|
|
|
return CodePath
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:获取开发者名单
|
|
|
作者:黄海
|
|
|
时间:2020-04-23
|
|
|
*/
|
|
|
func ListPerson() []map[string]interface{} {
|
|
|
return ProtoDao.ListPerson()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功用:绑定接口下拉框
|
|
|
作者:黄海
|
|
|
时间:2020-04-23
|
|
|
*/
|
|
|
func BindInterfaceList() []map[string]interface{} {
|
|
|
return ProtoDao.BindInterfaceList()
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:列举出proto的文件有哪些
|
|
|
作者:黄海
|
|
|
时间:2020-04-22
|
|
|
*/
|
|
|
func ListProto(interfaceId string, page int, limit int) ([]map[string]interface{}, int64) {
|
|
|
return ProtoDao.ListProto(interfaceId, page, limit)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
功能:获取指定参数结构体下的参数属性
|
|
|
作者:黄海
|
|
|
时间:2020-04-22
|
|
|
*/
|
|
|
func GetParameterStructInfo(structId string) []map[string]interface{} {
|
|
|
return ProtoDao.GetParameterStructInfo(structId)
|
|
|
}
|