|
@@ -1,11 +1,11 @@
|
|
package cross_variety
|
|
package cross_variety
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "eta_gn/eta_api/global"
|
|
"eta_gn/eta_api/models/data_manage"
|
|
"eta_gn/eta_api/models/data_manage"
|
|
"eta_gn/eta_api/models/data_manage/cross_variety/request"
|
|
"eta_gn/eta_api/models/data_manage/cross_variety/request"
|
|
"eta_gn/eta_api/utils"
|
|
"eta_gn/eta_api/utils"
|
|
"fmt"
|
|
"fmt"
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
@@ -31,12 +31,16 @@ type ChartInfoCrossVariety struct {
|
|
// @return total int64
|
|
// @return total int64
|
|
// @return err error
|
|
// @return err error
|
|
func GetCountChartByTagId(tagId int) (total int64, err error) {
|
|
func GetCountChartByTagId(tagId int) (total int64, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- sql := `SELECT count(1) total FROM chart_info AS a JOIN
|
|
|
|
- chart_info_cross_variety AS b on a.chart_info_id = b.chart_info_id
|
|
|
|
- WHERE b.chart_x_tag_id = ? or b.chart_y_tag_id=?`
|
|
|
|
- err = o.Raw(sql, tagId, tagId).QueryRow(&total)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //sql := `SELECT count(1) total FROM chart_info AS a JOIN
|
|
|
|
+ //chart_info_cross_variety AS b on a.chart_info_id = b.chart_info_id
|
|
|
|
+ //WHERE b.chart_x_tag_id = ? or b.chart_y_tag_id=?`
|
|
|
|
+ //err = o.Raw(sql, tagId, tagId).QueryRow(&total)
|
|
|
|
|
|
|
|
+ sql := `SELECT count(1) total FROM chart_info AS a JOIN
|
|
|
|
+ chart_info_cross_variety AS b on a.chart_info_id = b.chart_info_id
|
|
|
|
+ WHERE b.chart_x_tag_id = ? or b.chart_y_tag_id=?`
|
|
|
|
+ err = global.DmSQL["data"].Raw(sql, tagId, tagId).Scan(&total).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -48,11 +52,16 @@ func GetCountChartByTagId(tagId int) (total int64, err error) {
|
|
// @return items []*ChartInfoCrossVariety
|
|
// @return items []*ChartInfoCrossVariety
|
|
// @return err error
|
|
// @return err error
|
|
func GeChartInfoCrossVarietyListByTagId(tagId int) (items []*ChartInfoCrossVariety, err error) {
|
|
func GeChartInfoCrossVarietyListByTagId(tagId int) (items []*ChartInfoCrossVariety, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //sql := `SELECT b.* FROM chart_info AS a JOIN
|
|
|
|
+ //chart_info_cross_variety AS b on a.chart_info_id = b.chart_info_id
|
|
|
|
+ //WHERE b.chart_x_tag_id = ? or b.chart_y_tag_id=?`
|
|
|
|
+ //_, err = o.Raw(sql, tagId, tagId).QueryRows(&items)
|
|
|
|
+
|
|
sql := `SELECT b.* FROM chart_info AS a JOIN
|
|
sql := `SELECT b.* FROM chart_info AS a JOIN
|
|
- chart_info_cross_variety AS b on a.chart_info_id = b.chart_info_id
|
|
|
|
- WHERE b.chart_x_tag_id = ? or b.chart_y_tag_id=?`
|
|
|
|
- _, err = o.Raw(sql, tagId, tagId).QueryRows(&items)
|
|
|
|
|
|
+ chart_info_cross_variety AS b on a.chart_info_id = b.chart_info_id
|
|
|
|
+ WHERE b.chart_x_tag_id = ? or b.chart_y_tag_id=?`
|
|
|
|
+ err = global.DmSQL["data"].Raw(sql, tagId, tagId).Find(&items).Error
|
|
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -65,26 +74,36 @@ func GeChartInfoCrossVarietyListByTagId(tagId int) (items []*ChartInfoCrossVarie
|
|
// @return item *ChartInfoCrossVariety
|
|
// @return item *ChartInfoCrossVariety
|
|
// @return err error
|
|
// @return err error
|
|
func GetChartInfoCrossVarietyByChartInfoId(id int) (item *ChartInfoCrossVariety, err error) {
|
|
func GetChartInfoCrossVarietyByChartInfoId(id int) (item *ChartInfoCrossVariety, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- sql := `SELECT * FROM chart_info_cross_variety WHERE chart_info_id = ?`
|
|
|
|
- err = o.Raw(sql, id).QueryRow(&item)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //sql := `SELECT * FROM chart_info_cross_variety WHERE chart_info_id = ?`
|
|
|
|
+ //err = o.Raw(sql, id).QueryRow(&item)
|
|
|
|
|
|
|
|
+ sql := `SELECT * FROM chart_info_cross_variety WHERE chart_info_id = ?`
|
|
|
|
+ err = global.DmSQL["data"].Raw(sql, id).First(&item).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetChartInfoCrossVarietyByXEdbInfoId(edbInfoId int) (items []*ChartInfoCrossVariety, err error) {
|
|
func GetChartInfoCrossVarietyByXEdbInfoId(edbInfoId int) (items []*ChartInfoCrossVariety, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- sql := `SELECT a.* FROM chart_info_cross_variety a
|
|
|
|
- join chart_tag_variety b on a.chart_x_tag_id=b.chart_tag_id WHERE b.edb_info_id = ? `
|
|
|
|
- _, err = o.Raw(sql, edbInfoId).QueryRows(&items)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //sql := `SELECT a.* FROM chart_info_cross_variety a
|
|
|
|
+ // join chart_tag_variety b on a.chart_x_tag_id=b.chart_tag_id WHERE b.edb_info_id = ? `
|
|
|
|
+ //_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
|
|
|
|
+
|
|
|
|
+ sql := `SELECT a.* FROM chart_info_cross_variety a
|
|
|
|
+ join chart_tag_variety b on a.chart_x_tag_id=b.chart_tag_id WHERE b.edb_info_id = ? `
|
|
|
|
+ err = global.DmSQL["data"].Raw(sql, edbInfoId).Find(&items).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
func GetChartInfoCrossVarietyByYEdbInfoId(edbInfoId int) (items []*ChartInfoCrossVariety, err error) {
|
|
func GetChartInfoCrossVarietyByYEdbInfoId(edbInfoId int) (items []*ChartInfoCrossVariety, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- sql := `SELECT a.* FROM chart_info_cross_variety a
|
|
|
|
- join chart_tag_variety b on a.chart_y_tag_id=b.chart_tag_id WHERE b.edb_info_id = ? `
|
|
|
|
- _, err = o.Raw(sql, edbInfoId).QueryRows(&items)
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //sql := `SELECT a.* FROM chart_info_cross_variety a
|
|
|
|
+ // join chart_tag_variety b on a.chart_y_tag_id=b.chart_tag_id WHERE b.edb_info_id = ? `
|
|
|
|
+ //_, err = o.Raw(sql, edbInfoId).QueryRows(&items)
|
|
|
|
+ //return
|
|
|
|
+ sql := `SELECT a.* FROM chart_info_cross_variety a
|
|
|
|
+ join chart_tag_variety b on a.chart_y_tag_id=b.chart_tag_id WHERE b.edb_info_id = ? `
|
|
|
|
+ err = global.DmSQL["data"].Raw(sql, edbInfoId).Find(&items).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -99,44 +118,52 @@ func GetChartInfoCrossVarietyByYEdbInfoId(edbInfoId int) (items []*ChartInfoCros
|
|
// @return chartInfoId int
|
|
// @return chartInfoId int
|
|
// @return err error
|
|
// @return err error
|
|
func CreateChart(chartInfo *data_manage.ChartInfo, classify *data_manage.ChartClassify, chartVarietyMappingList []*ChartVarietyMapping, chartInfoCrossVariety *ChartInfoCrossVariety) (chartInfoId int, err error) {
|
|
func CreateChart(chartInfo *data_manage.ChartInfo, classify *data_manage.ChartClassify, chartVarietyMappingList []*ChartVarietyMapping, chartInfoCrossVariety *ChartInfoCrossVariety) (chartInfoId int, err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- tx, err := o.Begin()
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ ////o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //tx, err := o.Begin()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //defer func() {
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // _ = tx.Rollback()
|
|
|
|
+ // } else {
|
|
|
|
+ // _ = tx.Commit()
|
|
|
|
+ // }
|
|
|
|
+ //}()
|
|
|
|
+
|
|
|
|
+ to := global.DmSQL["data"].Begin()
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
- _ = tx.Rollback()
|
|
|
|
|
|
+ _ = to.Rollback()
|
|
} else {
|
|
} else {
|
|
- _ = tx.Commit()
|
|
|
|
|
|
+ _ = to.Commit()
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
|
|
|
|
// 判断是否分类已存在,不存在的话,先添加分类
|
|
// 判断是否分类已存在,不存在的话,先添加分类
|
|
if classify.ChartClassifyId <= 0 {
|
|
if classify.ChartClassifyId <= 0 {
|
|
- newId, tmpErr := tx.Insert(classify)
|
|
|
|
|
|
+ tmpErr := to.Create(classify).Error
|
|
if tmpErr != nil {
|
|
if tmpErr != nil {
|
|
err = tmpErr
|
|
err = tmpErr
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- classify.ChartClassifyId = int(newId)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// 新增图表信息
|
|
// 新增图表信息
|
|
chartInfo.ChartClassifyId = classify.ChartClassifyId
|
|
chartInfo.ChartClassifyId = classify.ChartClassifyId
|
|
- newId, err := tx.Insert(chartInfo)
|
|
|
|
|
|
+ err = to.Create(chartInfo).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
// 品种列表
|
|
// 品种列表
|
|
- chartInfo.ChartInfoId = int(newId)
|
|
|
|
- chartInfoId = int(newId)
|
|
|
|
|
|
+ //chartInfo.ChartInfoId = int(newId)
|
|
|
|
+ chartInfoId = chartInfo.ChartInfoId
|
|
|
|
|
|
if len(chartVarietyMappingList) > 0 {
|
|
if len(chartVarietyMappingList) > 0 {
|
|
for i := range chartVarietyMappingList {
|
|
for i := range chartVarietyMappingList {
|
|
chartVarietyMappingList[i].ChartInfoId = chartInfoId
|
|
chartVarietyMappingList[i].ChartInfoId = chartInfoId
|
|
}
|
|
}
|
|
- _, err = tx.InsertMulti(len(chartVarietyMappingList), chartVarietyMappingList)
|
|
|
|
|
|
+ err = to.CreateInBatches(chartVarietyMappingList, len(chartVarietyMappingList)).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -144,7 +171,7 @@ func CreateChart(chartInfo *data_manage.ChartInfo, classify *data_manage.ChartCl
|
|
|
|
|
|
// 图表配置
|
|
// 图表配置
|
|
chartInfoCrossVariety.ChartInfoId = chartInfoId
|
|
chartInfoCrossVariety.ChartInfoId = chartInfoId
|
|
- if _, err = tx.Insert(chartInfoCrossVariety); err != nil {
|
|
|
|
|
|
+ if err = to.Create(chartInfoCrossVariety).Error; err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -153,11 +180,21 @@ func CreateChart(chartInfo *data_manage.ChartInfo, classify *data_manage.ChartCl
|
|
|
|
|
|
// EditChart 修改相关性图表的 图表与指标 的关系
|
|
// EditChart 修改相关性图表的 图表与指标 的关系
|
|
func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*ChartVarietyMapping, chartInfoCrossVariety *ChartInfoCrossVariety, chartUpdateCols, chartInfoCrossVarietyUpdateCols []string) (err error) {
|
|
func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*ChartVarietyMapping, chartInfoCrossVariety *ChartInfoCrossVariety, chartUpdateCols, chartInfoCrossVarietyUpdateCols []string) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- to, err := o.Begin()
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //to, err := o.Begin()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //defer func() {
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // _ = to.Rollback()
|
|
|
|
+ // } else {
|
|
|
|
+ // _ = to.Commit()
|
|
|
|
+ // }
|
|
|
|
+ //}()
|
|
|
|
+
|
|
|
|
+ to := global.DmSQL["data"].Begin()
|
|
|
|
+
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
_ = to.Rollback()
|
|
_ = to.Rollback()
|
|
@@ -167,7 +204,7 @@ func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*Char
|
|
}()
|
|
}()
|
|
|
|
|
|
// 更新图表信息
|
|
// 更新图表信息
|
|
- _, err = to.Update(chartInfo, chartUpdateCols...)
|
|
|
|
|
|
+ err = to.Select(chartUpdateCols).Updates(chartInfo).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
return err
|
|
return err
|
|
@@ -175,8 +212,9 @@ func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*Char
|
|
|
|
|
|
// 查找现有的品种列表
|
|
// 查找现有的品种列表
|
|
currVarietyMappingList := make([]*ChartVarietyMapping, 0)
|
|
currVarietyMappingList := make([]*ChartVarietyMapping, 0)
|
|
|
|
+ //sql := `SELECT * FROM chart_variety_mapping WHERE chart_info_id = ? `
|
|
sql := `SELECT * FROM chart_variety_mapping WHERE chart_info_id = ? `
|
|
sql := `SELECT * FROM chart_variety_mapping WHERE chart_info_id = ? `
|
|
- _, err = to.Raw(sql, chartInfo.ChartInfoId).QueryRows(&currVarietyMappingList)
|
|
|
|
|
|
+ err = to.Raw(sql, chartInfo.ChartInfoId).Find(currVarietyMappingList).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -203,7 +241,7 @@ func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*Char
|
|
|
|
|
|
// 添加品种
|
|
// 添加品种
|
|
if len(addVarietyMappingList) > 0 {
|
|
if len(addVarietyMappingList) > 0 {
|
|
- _, err = to.InsertMulti(len(addVarietyMappingList), addVarietyMappingList)
|
|
|
|
|
|
+ err = to.CreateInBatches(addVarietyMappingList, len(addVarietyMappingList)).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -216,16 +254,18 @@ func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*Char
|
|
idStrList = append(idStrList, fmt.Sprint(id))
|
|
idStrList = append(idStrList, fmt.Sprint(id))
|
|
}
|
|
}
|
|
removeIdStr := strings.Join(idStrList, `,`)
|
|
removeIdStr := strings.Join(idStrList, `,`)
|
|
|
|
+ //sql = fmt.Sprintf(` DELETE FROM chart_variety_mapping WHERE id in (%s) `, removeIdStr)
|
|
sql = fmt.Sprintf(` DELETE FROM chart_variety_mapping WHERE id in (%s) `, removeIdStr)
|
|
sql = fmt.Sprintf(` DELETE FROM chart_variety_mapping WHERE id in (%s) `, removeIdStr)
|
|
- _, err = to.Raw(sql).Exec()
|
|
|
|
|
|
+ err = to.Exec(sql).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 跨品种分析图表配置
|
|
// 跨品种分析图表配置
|
|
- _, err = to.Update(chartInfoCrossVariety, chartInfoCrossVarietyUpdateCols...)
|
|
|
|
|
|
+ //_, err = to.Update(chartInfoCrossVariety, chartInfoCrossVarietyUpdateCols...)
|
|
|
|
|
|
|
|
+ err = to.Select(chartInfoCrossVarietyUpdateCols).Updates(chartInfoCrossVariety).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -237,11 +277,21 @@ func EditChart(chartInfo *data_manage.ChartInfo, chartVarietyMappingList []*Char
|
|
// @param req request.EditChartEnInfoReq
|
|
// @param req request.EditChartEnInfoReq
|
|
// @return err error
|
|
// @return err error
|
|
func EditChartEn(chartInfo *data_manage.ChartInfo, req request.EditChartEnInfoReq) (err error) {
|
|
func EditChartEn(chartInfo *data_manage.ChartInfo, req request.EditChartEnInfoReq) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- to, err := o.Begin()
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //to, err := o.Begin()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //defer func() {
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // _ = to.Rollback()
|
|
|
|
+ // } else {
|
|
|
|
+ // _ = to.Commit()
|
|
|
|
+ // }
|
|
|
|
+ //}()
|
|
|
|
+
|
|
|
|
+ to := global.DmSQL["data"].Begin()
|
|
|
|
+
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
_ = to.Rollback()
|
|
_ = to.Rollback()
|
|
@@ -253,16 +303,22 @@ func EditChartEn(chartInfo *data_manage.ChartInfo, req request.EditChartEnInfoRe
|
|
// 更新图表信息
|
|
// 更新图表信息
|
|
chartInfo.ChartNameEn = req.ChartNameEn
|
|
chartInfo.ChartNameEn = req.ChartNameEn
|
|
chartInfo.ModifyTime = time.Now().Local()
|
|
chartInfo.ModifyTime = time.Now().Local()
|
|
- _, err = to.Update(chartInfo, "ChartNameEn", "ModifyTime")
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
|
|
+ //_, err = to.Update(chartInfo, "ChartNameEn", "ModifyTime")
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
|
|
+ // return err
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ err = to.Select("ChartNameEn", "ModifyTime").Updates(chartInfo).Error
|
|
|
|
|
|
// 更新标签英文名
|
|
// 更新标签英文名
|
|
for _, v := range req.TagList {
|
|
for _, v := range req.TagList {
|
|
|
|
+ //sql := `UPDATE chart_tag SET chart_tag_name_en = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
|
|
+ //_, err = o.Raw(sql, v.TagNameEn, v.ChartTagId).Exec()
|
|
|
|
+
|
|
sql := `UPDATE chart_tag SET chart_tag_name_en = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
sql := `UPDATE chart_tag SET chart_tag_name_en = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
- _, err = o.Raw(sql, v.TagNameEn, v.ChartTagId).Exec()
|
|
|
|
|
|
+
|
|
|
|
+ err = to.Exec(sql, v.TagNameEn, v.ChartTagId).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -270,8 +326,14 @@ func EditChartEn(chartInfo *data_manage.ChartInfo, req request.EditChartEnInfoRe
|
|
|
|
|
|
// 更新品种英文名
|
|
// 更新品种英文名
|
|
for _, v := range req.VarietyList {
|
|
for _, v := range req.VarietyList {
|
|
|
|
+ //sql := `UPDATE chart_variety SET chart_variety_name_en = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
|
|
+ //_, err = o.Raw(sql, v.VarietyNameEn, v.ChartVarietyId).Exec()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+
|
|
sql := `UPDATE chart_variety SET chart_variety_name_en = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
sql := `UPDATE chart_variety SET chart_variety_name_en = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
- _, err = o.Raw(sql, v.VarietyNameEn, v.ChartVarietyId).Exec()
|
|
|
|
|
|
+ err = to.Exec(sql, v.VarietyNameEn, v.ChartVarietyId).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -289,11 +351,21 @@ func EditChartEn(chartInfo *data_manage.ChartInfo, req request.EditChartEnInfoRe
|
|
// @param lang string
|
|
// @param lang string
|
|
// @return err error
|
|
// @return err error
|
|
func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseInfoReq, lang string) (err error) {
|
|
func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseInfoReq, lang string) (err error) {
|
|
- o := orm.NewOrmUsingDB("data")
|
|
|
|
- to, err := o.Begin()
|
|
|
|
- if err != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+ //o := orm.NewOrmUsingDB("data")
|
|
|
|
+ //to, err := o.Begin()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+ //defer func() {
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // _ = to.Rollback()
|
|
|
|
+ // } else {
|
|
|
|
+ // _ = to.Commit()
|
|
|
|
+ // }
|
|
|
|
+ //}()
|
|
|
|
+
|
|
|
|
+ to := global.DmSQL["data"].Begin()
|
|
|
|
+
|
|
defer func() {
|
|
defer func() {
|
|
if err != nil {
|
|
if err != nil {
|
|
_ = to.Rollback()
|
|
_ = to.Rollback()
|
|
@@ -310,7 +382,13 @@ func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseIn
|
|
chartInfo.ChartName = req.ChartName
|
|
chartInfo.ChartName = req.ChartName
|
|
}
|
|
}
|
|
chartInfo.ModifyTime = time.Now().Local()
|
|
chartInfo.ModifyTime = time.Now().Local()
|
|
- _, err = to.Update(chartInfo, "ChartName", "ChartNameEn", "ModifyTime")
|
|
|
|
|
|
+ //_, err = to.Update(chartInfo, "ChartName", "ChartNameEn", "ModifyTime")
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
|
|
+ // return err
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ err = to.Select("ChartName", "ChartNameEn", "ModifyTime").Updates(chartInfo).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
fmt.Println("UPDATE chart_info Err:", err.Error())
|
|
return err
|
|
return err
|
|
@@ -318,6 +396,20 @@ func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseIn
|
|
|
|
|
|
// 更新标签名
|
|
// 更新标签名
|
|
for _, v := range req.TagList {
|
|
for _, v := range req.TagList {
|
|
|
|
+ //var sql string
|
|
|
|
+ //switch lang {
|
|
|
|
+ //case utils.EnLangVersion:
|
|
|
|
+ // sql = `UPDATE chart_tag SET chart_tag_name_en = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
|
|
+ //default:
|
|
|
|
+ // sql = `UPDATE chart_tag SET chart_tag_name = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
|
|
+ //}
|
|
|
|
+ //if sql != `` {
|
|
|
|
+ // _, err = o.Raw(sql, v.TagName, v.ChartTagId).Exec()
|
|
|
|
+ // if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+
|
|
var sql string
|
|
var sql string
|
|
switch lang {
|
|
switch lang {
|
|
case utils.EnLangVersion:
|
|
case utils.EnLangVersion:
|
|
@@ -326,7 +418,12 @@ func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseIn
|
|
sql = `UPDATE chart_tag SET chart_tag_name = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
sql = `UPDATE chart_tag SET chart_tag_name = ?,modify_time= NOW() WHERE chart_tag_id = ? `
|
|
}
|
|
}
|
|
if sql != `` {
|
|
if sql != `` {
|
|
- _, err = o.Raw(sql, v.TagName, v.ChartTagId).Exec()
|
|
|
|
|
|
+ //_, err = o.Raw(sql, v.TagName, v.ChartTagId).Exec()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ err = to.Exec(sql, v.TagName, v.ChartTagId).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -335,6 +432,18 @@ func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseIn
|
|
|
|
|
|
// 更新品种名
|
|
// 更新品种名
|
|
for _, v := range req.VarietyList {
|
|
for _, v := range req.VarietyList {
|
|
|
|
+ //var sql string
|
|
|
|
+ //switch lang {
|
|
|
|
+ //case utils.EnLangVersion:
|
|
|
|
+ // sql = `UPDATE chart_variety SET chart_variety_name_en = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
|
|
+ //default:
|
|
|
|
+ // sql = `UPDATE chart_variety SET chart_variety_name = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
|
|
+ //}
|
|
|
|
+ //_, err = o.Raw(sql, v.VarietyName, v.ChartVarietyId).Exec()
|
|
|
|
+ //if err != nil {
|
|
|
|
+ // return
|
|
|
|
+ //}
|
|
|
|
+
|
|
var sql string
|
|
var sql string
|
|
switch lang {
|
|
switch lang {
|
|
case utils.EnLangVersion:
|
|
case utils.EnLangVersion:
|
|
@@ -342,7 +451,7 @@ func EditChartBase(chartInfo *data_manage.ChartInfo, req request.EditChartBaseIn
|
|
default:
|
|
default:
|
|
sql = `UPDATE chart_variety SET chart_variety_name = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
sql = `UPDATE chart_variety SET chart_variety_name = ?,modify_time= NOW() WHERE chart_variety_id = ? `
|
|
}
|
|
}
|
|
- _, err = o.Raw(sql, v.VarietyName, v.ChartVarietyId).Exec()
|
|
|
|
|
|
+ err = to.Exec(sql, v.VarietyName, v.ChartVarietyId).Error
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|