@@ -149,34 +149,60 @@ func GetColumn(tableName string, dbName string) (err error, Columns []request.Co
149149 return err , Columns
150150}
151151
152+ //func addAutoMoveFile(data *tplData) {
153+ // if strings.Contains(data.autoCodePath, "server") {
154+ // if strings.Contains(data.autoCodePath, "router") {
155+ // apiList := strings.Split(data.autoCodePath, "/")
156+ // data.autoMoveFilePath = filepath.Join(apiList[len(apiList)-2], apiList[len(apiList)-1])
157+ // } else if strings.Contains(data.autoCodePath, "api") {
158+ // apiList := strings.Split(data.autoCodePath, "/")
159+ // data.autoMoveFilePath = filepath.Join(apiList[len(apiList)-2], "v1", apiList[len(apiList)-1])
160+ // } else if strings.Contains(data.autoCodePath, "service") {
161+ // serviceList := strings.Split(data.autoCodePath, "/")
162+ // data.autoMoveFilePath = filepath.Join(serviceList[len(serviceList)-2], serviceList[len(serviceList)-1])
163+ // } else if strings.Contains(data.autoCodePath, "model") {
164+ // modelList := strings.Split(data.autoCodePath, "/")
165+ // data.autoMoveFilePath = filepath.Join(modelList[len(modelList)-2], modelList[len(modelList)-1])
166+ // } else if strings.Contains(data.autoCodePath, "request") {
167+ // requestList := strings.Split(data.autoCodePath, "/")
168+ // data.autoMoveFilePath = filepath.Join("model", requestList[len(requestList)-2], requestList[len(requestList)-1])
169+ // }
170+ // } else if strings.Contains(data.autoCodePath, "web") {
171+ // if strings.Contains(data.autoCodePath, "js") {
172+ // jsList := strings.Split(data.autoCodePath, "/")
173+ // data.autoMoveFilePath = filepath.Join("../", "web", "src", jsList[len(jsList)-2], jsList[len(jsList)-1])
174+ // } else if strings.Contains(data.autoCodePath, "form") {
175+ // formList := strings.Split(data.autoCodePath, "/")
176+ // data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", formList[len(formList)-3], strings.Split(formList[len(formList)-1], ".")[0]+"From.vue")
177+ // } else if strings.Contains(data.autoCodePath, "table") {
178+ // vueList := strings.Split(data.autoCodePath, "/")
179+ // data.autoMoveFilePath = filepath.Join("../", "web", "src", "view", vueList[len(vueList)-3], vueList[len(vueList)-1])
180+ // }
181+ // }
182+ //}
183+
152184func addAutoMoveFile (data * tplData ) {
185+ dir := filepath .Dir (data .autoCodePath )
186+ base := filepath .Base (data .autoCodePath )
153187 if strings .Contains (data .autoCodePath , "server" ) {
154188 if strings .Contains (data .autoCodePath , "router" ) {
155- apiList := strings .Split (data .autoCodePath , "/" )
156- data .autoMoveFilePath = filepath .Join (apiList [len (apiList )- 2 ], apiList [len (apiList )- 1 ])
189+ data .autoMoveFilePath = filepath .Join (dir , base )
157190 } else if strings .Contains (data .autoCodePath , "api" ) {
158- apiList := strings .Split (data .autoCodePath , "/" )
159- data .autoMoveFilePath = filepath .Join (apiList [len (apiList )- 2 ], "v1" , apiList [len (apiList )- 1 ])
191+ data .autoMoveFilePath = filepath .Join (dir , "v1" , base )
160192 } else if strings .Contains (data .autoCodePath , "service" ) {
161- serviceList := strings .Split (data .autoCodePath , "/" )
162- data .autoMoveFilePath = filepath .Join (serviceList [len (serviceList )- 2 ], serviceList [len (serviceList )- 1 ])
193+ data .autoMoveFilePath = filepath .Join (dir , base )
163194 } else if strings .Contains (data .autoCodePath , "model" ) {
164- modelList := strings .Split (data .autoCodePath , "/" )
165- data .autoMoveFilePath = filepath .Join (modelList [len (modelList )- 2 ], modelList [len (modelList )- 1 ])
195+ data .autoMoveFilePath = filepath .Join (dir , base )
166196 } else if strings .Contains (data .autoCodePath , "request" ) {
167- requestList := strings .Split (data .autoCodePath , "/" )
168- data .autoMoveFilePath = filepath .Join ("model" , requestList [len (requestList )- 2 ], requestList [len (requestList )- 1 ])
197+ data .autoMoveFilePath = filepath .Join ("model" , dir , base )
169198 }
170199 } else if strings .Contains (data .autoCodePath , "web" ) {
171200 if strings .Contains (data .autoCodePath , "js" ) {
172- jsList := strings .Split (data .autoCodePath , "/" )
173- data .autoMoveFilePath = filepath .Join ("../" , "web" , "src" , jsList [len (jsList )- 2 ], jsList [len (jsList )- 1 ])
201+ data .autoMoveFilePath = filepath .Join ("../" , "web" , "src" , dir , base )
174202 } else if strings .Contains (data .autoCodePath , "form" ) {
175- formList := strings .Split (data .autoCodePath , "/" )
176- data .autoMoveFilePath = filepath .Join ("../" , "web" , "src" , "view" , formList [len (formList )- 3 ], strings .Split (formList [len (formList )- 1 ], "." )[0 ]+ "From.vue" )
203+ data .autoMoveFilePath = filepath .Join ("../" , "web" , "src" , "view" , filepath .Dir (dir ), strings .TrimSuffix (base , filepath .Ext (base ))+ "From.vue" )
177204 } else if strings .Contains (data .autoCodePath , "table" ) {
178- vueList := strings .Split (data .autoCodePath , "/" )
179- data .autoMoveFilePath = filepath .Join ("../" , "web" , "src" , "view" , vueList [len (vueList )- 3 ], vueList [len (vueList )- 1 ])
205+ data .autoMoveFilePath = filepath .Join ("../" , "web" , "src" , "view" , filepath .Dir (dir ), base )
180206 }
181207 }
182208}
0 commit comments