|
|
@@ -21,8 +21,12 @@ func (d *BizObjectMappingRepo) GetPage(m map[string]interface{}) (*viewmodels.Pa
|
|
|
limit := m["limit"].(int)
|
|
|
page := m["page"].(int)
|
|
|
|
|
|
- sqlSelect := ` SELECT A.* `
|
|
|
- sqlFrom := ` FROM biz_object_mapping AS A `
|
|
|
+ sqlSelect := ` SELECT A.*,
|
|
|
+ B.model_title as mapping_model_title,
|
|
|
+ C.object_title as mapping_object_title`
|
|
|
+ sqlFrom := ` FROM biz_object_mapping AS A
|
|
|
+ LEFT JOIN ds_model AS B ON (A.mapping_model_id = B.model_id)
|
|
|
+ LEFT JOIN ds_object AS C ON (A.mapping_object_id = C.object_id) `
|
|
|
sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
if keywords, ok := m["keywords"]; ok {
|
|
|
sqlWhere += ` AND A.object_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
|
|
|
@@ -53,9 +57,13 @@ func (d *BizObjectMappingRepo) GetPage(m map[string]interface{}) (*viewmodels.Pa
|
|
|
}
|
|
|
|
|
|
func (d *BizObjectMappingRepo) GetList(m map[string]interface{}) ([]viewmodels.BizObjectMappingInfo, error) {
|
|
|
- sqlSelect := ` SELECT A.* `
|
|
|
- sqlFrom := ` FROM biz_object_mapping AS A `
|
|
|
- sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
+ sqlSelect := ` SELECT A.*,
|
|
|
+ B.model_title as mapping_model_title,
|
|
|
+ C.object_title as mapping_object_title`
|
|
|
+ sqlFrom := ` FROM biz_object_mapping AS A
|
|
|
+ LEFT JOIN ds_model AS B ON (A.mapping_model_id = B.model_id)
|
|
|
+ LEFT JOIN ds_object AS C ON (A.mapping_object_id = C.object_id) `
|
|
|
+ sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
if keywords, ok := m["keywords"]; ok {
|
|
|
sqlWhere += ` AND A.object_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
|
|
|
}
|
|
|
@@ -71,9 +79,13 @@ func (d *BizObjectMappingRepo) GetList(m map[string]interface{}) ([]viewmodels.B
|
|
|
}
|
|
|
|
|
|
func (d *BizObjectMappingRepo) GetAll() ([]viewmodels.BizObjectMappingInfo, error) {
|
|
|
- sqlSelect := ` SELECT A.* `
|
|
|
- sqlFrom := ` FROM biz_object_mapping AS A `
|
|
|
- sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
+ sqlSelect := ` SELECT A.*,
|
|
|
+ B.model_title as mapping_model_title,
|
|
|
+ C.object_title as mapping_object_title`
|
|
|
+ sqlFrom := ` FROM biz_object_mapping AS A
|
|
|
+ LEFT JOIN ds_model AS B ON (A.mapping_model_id = B.model_id)
|
|
|
+ LEFT JOIN ds_object AS C ON (A.mapping_object_id = C.object_id) `
|
|
|
+ sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
sqlOrderBy := ` ORDER BY A.sort_no `
|
|
|
|
|
|
datalist := make([]viewmodels.BizObjectMappingInfo, 0)
|
|
|
@@ -86,9 +98,13 @@ func (d *BizObjectMappingRepo) GetAll() ([]viewmodels.BizObjectMappingInfo, erro
|
|
|
}
|
|
|
|
|
|
func (d *BizObjectMappingRepo) GetListById(bizId, objectId int64) ([]viewmodels.BizObjectMappingInfo, error) {
|
|
|
- sqlSelect := ` SELECT A.* `
|
|
|
- sqlFrom := ` FROM biz_object_mapping AS A `
|
|
|
- sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
+ sqlSelect := ` SELECT A.*,
|
|
|
+ B.model_title as mapping_model_title,
|
|
|
+ C.object_title as mapping_object_title`
|
|
|
+ sqlFrom := ` FROM biz_object_mapping AS A
|
|
|
+ LEFT JOIN ds_model AS B ON (A.mapping_model_id = B.model_id)
|
|
|
+ LEFT JOIN ds_object AS C ON (A.mapping_object_id = C.object_id) `
|
|
|
+ sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
sqlWhere += fmt.Sprintf(" AND A.biz_id = %d", bizId)
|
|
|
sqlWhere += fmt.Sprintf(" AND A.object_id = %d", objectId)
|
|
|
sqlOrderBy := " ORDER BY A.sort_no "
|
|
|
@@ -103,13 +119,20 @@ func (d *BizObjectMappingRepo) GetListById(bizId, objectId int64) ([]viewmodels.
|
|
|
}
|
|
|
|
|
|
func (d *BizObjectMappingRepo) GetById(bizId, objectId, mappingId int64) (*viewmodels.BizObjectMappingInfo, error) {
|
|
|
- data := &viewmodels.BizObjectMappingInfo{}
|
|
|
- ok, err := d.engine.
|
|
|
- Where("biz_id = ?", bizId).
|
|
|
- Where("object_id = ?", objectId).
|
|
|
- Where("mapping_id = ?", mappingId).
|
|
|
- Get(data)
|
|
|
- if !ok && err == nil {
|
|
|
+ sqlSelect := ` SELECT A.*,
|
|
|
+ B.model_title as mapping_model_title,
|
|
|
+ C.object_title as mapping_object_title`
|
|
|
+ sqlFrom := ` FROM biz_object_mapping AS A
|
|
|
+ LEFT JOIN ds_model AS B ON (A.mapping_model_id = B.model_id)
|
|
|
+ LEFT JOIN ds_object AS C ON (A.mapping_object_id = C.object_id) `
|
|
|
+ sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
+ sqlWhere += fmt.Sprintf(" AND A.biz_id = %d", bizId)
|
|
|
+ sqlWhere += fmt.Sprintf(" AND A.object_id = %d", objectId)
|
|
|
+ sqlWhere += fmt.Sprintf(" AND A.mapping_id = %d", mappingId)
|
|
|
+
|
|
|
+ data := &viewmodels.BizObjectMappingInfo{}
|
|
|
+ has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
|
|
|
+ if !has || err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return data, nil
|