|
|
@@ -6,22 +6,22 @@ import (
|
|
|
"xps/cmd/cache"
|
|
|
"xps/cmd/constant"
|
|
|
"xps/cmd/datasource"
|
|
|
- "xps/pkg/base"
|
|
|
bizViewModel "xps/pkg/biz/viewmodel"
|
|
|
+ "xps/pkg/common"
|
|
|
"xps/pkg/dataway"
|
|
|
)
|
|
|
|
|
|
type HttpHandler interface {
|
|
|
- Get(objectCode, oamCode string, params []base.QueryParam) (map[string]interface{}, error)
|
|
|
- GetPage(objectCode, oamCode string, params []base.QueryParam, page int, limit int) (*base.PageResult, error)
|
|
|
- GetList(objectCode, oamCode string, params []base.QueryParam) ([]map[string]interface{}, error)
|
|
|
+ Get(objectCode, oamCode string, params []common.QueryParam) (map[string]interface{}, error)
|
|
|
+ GetPage(objectCode, oamCode string, params []common.QueryParam, page int, limit int) (*common.PageResult, error)
|
|
|
+ GetList(objectCode, oamCode string, params []common.QueryParam) ([]map[string]interface{}, error)
|
|
|
|
|
|
GenerateParams(objectCode, oamCode string) (map[string]interface{}, error)
|
|
|
|
|
|
- Create(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error
|
|
|
- Update(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error
|
|
|
- Patch(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error
|
|
|
- Delete(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error
|
|
|
+ Create(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error
|
|
|
+ Update(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error
|
|
|
+ Patch(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error
|
|
|
+ Delete(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error
|
|
|
}
|
|
|
|
|
|
type httpHandler struct {
|
|
|
@@ -59,7 +59,7 @@ func (a *httpHandler) GenerateParams(objectCode, oamCode string) (map[string]int
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) Get(objectCode, oamCode string, params []base.QueryParam) (map[string]interface{}, error) {
|
|
|
+func (a *httpHandler) Get(objectCode, oamCode string, params []common.QueryParam) (map[string]interface{}, error) {
|
|
|
oam, err1 := cache.GetBizObjectOAM(objectCode, oamCode)
|
|
|
if err1 != nil {
|
|
|
return nil, err1
|
|
|
@@ -74,7 +74,7 @@ func (a *httpHandler) Get(objectCode, oamCode string, params []base.QueryParam)
|
|
|
return a.Mapping2BizObjectAttr(objectCode, data)
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) GetList(objectCode, oamCode string, params []base.QueryParam) ([]map[string]interface{}, error) {
|
|
|
+func (a *httpHandler) GetList(objectCode, oamCode string, params []common.QueryParam) ([]map[string]interface{}, error) {
|
|
|
oam, err1 := cache.GetBizObjectOAM(objectCode, oamCode)
|
|
|
if err1 != nil {
|
|
|
return nil, err1
|
|
|
@@ -87,14 +87,14 @@ func (a *httpHandler) GetList(objectCode, oamCode string, params []base.QueryPar
|
|
|
return a.Mapping2BizObjectList(objectCode, dataList)
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) GetPage(objectCode, oamCode string, params []base.QueryParam, page int, limit int) (*base.PageResult, error) {
|
|
|
+func (a *httpHandler) GetPage(objectCode, oamCode string, params []common.QueryParam, page int, limit int) (*common.PageResult, error) {
|
|
|
oam, err1 := cache.GetBizObjectOAM(objectCode, oamCode)
|
|
|
if err1 != nil {
|
|
|
return nil, err1
|
|
|
}
|
|
|
|
|
|
sqlStatement := oam.SqlStatement
|
|
|
- sqlCount := oam.SqlCount
|
|
|
+ sqlCount := oam.SqlCount
|
|
|
pageData, err2 := a.xBus.GetPage(sqlStatement, sqlCount, params, page, limit)
|
|
|
if err2 != nil {
|
|
|
return nil, err2
|
|
|
@@ -102,7 +102,7 @@ func (a *httpHandler) GetPage(objectCode, oamCode string, params []base.QueryPar
|
|
|
return a.Mapping2BizPageObject(objectCode, pageData)
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) Create(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error {
|
|
|
+func (a *httpHandler) Create(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error {
|
|
|
err1 := a.HandleOAMRuleList(objectCode, oamCode, m, user)
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
@@ -128,7 +128,7 @@ func (a *httpHandler) Create(objectCode, oamCode string, m map[string]interface{
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) Update(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error {
|
|
|
+func (a *httpHandler) Update(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error {
|
|
|
err1 := a.HandleOAMRuleList(objectCode, oamCode, m, user)
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
@@ -155,7 +155,7 @@ func (a *httpHandler) Update(objectCode, oamCode string, m map[string]interface{
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) Patch(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error {
|
|
|
+func (a *httpHandler) Patch(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error {
|
|
|
err1 := a.HandleOAMRuleList(objectCode, oamCode, m, user)
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
@@ -180,7 +180,7 @@ func (a *httpHandler) Patch(objectCode, oamCode string, m map[string]interface{}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) Delete(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error {
|
|
|
+func (a *httpHandler) Delete(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error {
|
|
|
err1 := a.HandleOAMRuleList(objectCode, oamCode, m, user)
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
@@ -206,7 +206,7 @@ func (a *httpHandler) Delete(objectCode, oamCode string, m map[string]interface{
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) HandleOAMRuleList(objectCode, oamCode string, m map[string]interface{}, user *base.CurUserInfo) error {
|
|
|
+func (a *httpHandler) HandleOAMRuleList(objectCode, oamCode string, m map[string]interface{}, user *common.CurUserInfo) error {
|
|
|
oamRules, err1 := cache.GetBizObjectOAMRules(objectCode, oamCode)
|
|
|
if err1 != nil {
|
|
|
return err1
|
|
|
@@ -221,7 +221,7 @@ func (a *httpHandler) HandleOAMRuleList(objectCode, oamCode string, m map[string
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) HandleOAMRule(oamRule *bizViewModel.BizObjectOAMRuleInfo, m map[string]interface{}, user *base.CurUserInfo) error {
|
|
|
+func (a *httpHandler) HandleOAMRule(oamRule *bizViewModel.BizObjectOAMRuleInfo, m map[string]interface{}, user *common.CurUserInfo) error {
|
|
|
if oamRule.RuleId == constant.BIZ_RULE_NEW_ID {
|
|
|
m[oamRule.TargetAttrCode] = NewID()
|
|
|
} else if oamRule.RuleId == constant.BIZ_RULE_CUR_DATETIME {
|
|
|
@@ -269,8 +269,8 @@ func (a *httpHandler) Mapping2BizObjectAttr(objectCode string, m map[string]inte
|
|
|
|
|
|
params := make(map[string]interface{}, 0)
|
|
|
for _, bzAttr := range bizObjectAttrs {
|
|
|
- bzAttrCode := bzAttr.AttrCode
|
|
|
- bzMappingCode := bzAttr.MappingCode
|
|
|
+ bzAttrCode := bzAttr.AttrCode
|
|
|
+ bzMappingCode := bzAttr.MappingCode
|
|
|
if bzAttrValue, ok := m[bzMappingCode]; ok {
|
|
|
params[bzAttrCode] = bzAttrValue
|
|
|
}
|
|
|
@@ -299,7 +299,7 @@ func (a *httpHandler) Mapping2BizObjectList(objectCode string, dataList []map[st
|
|
|
return targetDataList, nil
|
|
|
}
|
|
|
|
|
|
-func (a *httpHandler) Mapping2BizPageObject(objectCode string, pageData *base.PageResult) (*base.PageResult, error) {
|
|
|
+func (a *httpHandler) Mapping2BizPageObject(objectCode string, pageData *common.PageResult) (*common.PageResult, error) {
|
|
|
bizObjectAttrs, err := cache.GetBizObjectAttrs(objectCode)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
@@ -323,7 +323,7 @@ func (a *httpHandler) Mapping2BizPageObject(objectCode string, pageData *base.Pa
|
|
|
targetDataList = append(targetDataList, targetData)
|
|
|
}
|
|
|
|
|
|
- targetPageData := &base.PageResult{
|
|
|
+ targetPageData := &common.PageResult{
|
|
|
Total: pageData.Total,
|
|
|
PageSize: pageData.PageSize,
|
|
|
Page: pageData.Page,
|