fix: 网元软件包类型字段变更

This commit is contained in:
TsMask
2024-05-27 17:11:09 +08:00
parent 4ac4fb55dc
commit abfe3227f2
6 changed files with 54 additions and 44 deletions

View File

@@ -15,12 +15,12 @@ import (
// 实例化数据层 NewNeSoftware 结构体
var NewNeSoftwareImpl = &NeSoftwareImpl{
selectSql: `select
id, ne_type, name, path, version, description, create_by, create_time, update_by, update_time
id, type, name, path, version, description, create_by, create_time, update_by, update_time
from ne_software`,
resultMap: map[string]string{
"id": "ID",
"ne_type": "NeType",
"type": "Type",
"name": "Name",
"path": "Path",
"version": "Version",
@@ -60,9 +60,18 @@ func (r *NeSoftwareImpl) SelectPage(query map[string]any) map[string]any {
// 查询条件拼接
var conditions []string
var params []any
if v, ok := query["neType"]; ok && v != "" {
conditions = append(conditions, "ne_type = ?")
params = append(params, strings.Trim(v.(string), " "))
if v, ok := query["type"]; ok && v != "" {
softwareType := v.(string)
if strings.Contains(softwareType, ",") {
softwareTypeArr := strings.Split(softwareType, ",")
placeholder := repo.KeyPlaceholderByQuery(len(softwareTypeArr))
conditions = append(conditions, "type in ("+placeholder+")")
parameters := repo.ConvertIdsSlice(softwareTypeArr)
params = append(params, parameters...)
} else {
conditions = append(conditions, "type = ?")
params = append(params, strings.Trim(softwareType, " "))
}
}
if v, ok := query["name"]; ok && v != "" {
conditions = append(conditions, "name like concat(?, '%')")
@@ -122,9 +131,9 @@ func (r *NeSoftwareImpl) SelectList(neSoftware model.NeSoftware) []model.NeSoftw
// 查询条件拼接
var conditions []string
var params []any
if neSoftware.NeType != "" {
conditions = append(conditions, "ne_type = ?")
params = append(params, neSoftware.NeType)
if neSoftware.Type != "" {
conditions = append(conditions, "type = ?")
params = append(params, neSoftware.Type)
}
if neSoftware.Path != "" {
conditions = append(conditions, "path = ?")
@@ -175,9 +184,9 @@ func (r *NeSoftwareImpl) CheckUniqueTypeAndNameAndVersion(neSoftware model.NeSof
// 查询条件拼接
var conditions []string
var params []any
if neSoftware.NeType != "" {
conditions = append(conditions, "ne_type = ?")
params = append(params, neSoftware.NeType)
if neSoftware.Type != "" {
conditions = append(conditions, "type = ?")
params = append(params, neSoftware.Type)
}
if neSoftware.Version != "" {
conditions = append(conditions, "version = ?")
@@ -213,8 +222,8 @@ func (r *NeSoftwareImpl) CheckUniqueTypeAndNameAndVersion(neSoftware model.NeSof
func (r *NeSoftwareImpl) Insert(neSoftware model.NeSoftware) string {
// 参数拼接
params := make(map[string]any)
if neSoftware.NeType != "" {
params["ne_type"] = neSoftware.NeType
if neSoftware.Type != "" {
params["type"] = neSoftware.Type
}
if neSoftware.Name != "" {
params["name"] = neSoftware.Name
@@ -262,8 +271,8 @@ func (r *NeSoftwareImpl) Insert(neSoftware model.NeSoftware) string {
func (r *NeSoftwareImpl) Update(neSoftware model.NeSoftware) int64 {
// 参数拼接
params := make(map[string]any)
if neSoftware.NeType != "" {
params["ne_type"] = neSoftware.NeType
if neSoftware.Type != "" {
params["type"] = neSoftware.Type
}
if neSoftware.Name != "" {
params["name"] = neSoftware.Name