Browse Source

fix

main
cobb 3 years ago
parent
commit
9d1d3d01e4
  1. 14
      src/components/HelloWorld.vue

14
src/components/HelloWorld.vue

@ -193,7 +193,7 @@ export default {
}, },
genCode() { genCode() {
let v = this.schema; let v = this.schema;
this.output["model"] = this.handleModelOutput(v);
this.output["model"] = this.handleModelOutput(v, this.isUnderScoreCase);
this.output["service"] = this.handleServiceOutput(v); this.output["service"] = this.handleServiceOutput(v);
this.output["api"] = this.handleApiOutput(v); this.output["api"] = this.handleApiOutput(v);
this.output["route"] = this.handleRouteOutput(v); this.output["route"] = this.handleRouteOutput(v);
@ -220,7 +220,7 @@ export default {
onSchemaChange(v) { onSchemaChange(v) {
this.jsonformat = v; this.jsonformat = v;
this.schema = JSON.stringify(v, null, 2); this.schema = JSON.stringify(v, null, 2);
this.output["model"] = this.handleModelOutput(v);
this.output["model"] = this.handleModelOutput(v, this.isUnderScoreCase);
this.output["service"] = this.handleServiceOutput(v); this.output["service"] = this.handleServiceOutput(v);
this.output["api"] = this.handleApiOutput(v); this.output["api"] = this.handleApiOutput(v);
this.output["route"] = this.handleRouteOutput(v); this.output["route"] = this.handleRouteOutput(v);
@ -473,7 +473,7 @@ export default {
var result = oReq.responseText; // var result = oReq.responseText; //
return result; return result;
}, },
handleModelOutput(v) {
handleModelOutput(v, isUnderScoreCase) {
const tablePrefix = rmPrefix(v.title).prefix; const tablePrefix = rmPrefix(v.title).prefix;
var struct = this.getMyStruct(tablePrefix); var struct = this.getMyStruct(tablePrefix);
console.log("struct", struct); console.log("struct", struct);
@ -670,7 +670,7 @@ export default {
} }
if (key.indexOf("_time") > -1) { if (key.indexOf("_time") > -1) {
if (this.isUnderScoreCase) {
if (isUnderScoreCase) {
center += `${skey}Interval []interface{} \`json:"${key}|interval,omitempty" form:"${key}|interval"\`\n`; center += `${skey}Interval []interface{} \`json:"${key}|interval,omitempty" form:"${key}|interval"\`\n`;
} else { } else {
center += `${skey}Interval []interface{} \`json:"${caseKey}|interval,omitempty" form:"${caseKey}|interval"\`\n`; center += `${skey}Interval []interface{} \`json:"${caseKey}|interval,omitempty" form:"${caseKey}|interval"\`\n`;
@ -699,7 +699,7 @@ export default {
// idListID // idListID
if (key.indexOf("_id") > -1) { if (key.indexOf("_id") > -1) {
if (this.isUnderScoreCase) {
if (isUnderScoreCase) {
center += `${skey}In []${type} \`json:"${key}|in,omitempty" form:"${key}|in"\`\n`; center += `${skey}In []${type} \`json:"${key}|in,omitempty" form:"${key}|in"\`\n`;
} else { } else {
center += `${skey}In []${type} \`json:"${caseKey}|in,omitempty" form:"${caseKey}|in"\`\n`; center += `${skey}In []${type} \`json:"${caseKey}|in,omitempty" form:"${caseKey}|in"\`\n`;
@ -719,7 +719,7 @@ export default {
} }
if (requires.indexOf(key) > -1) { if (requires.indexOf(key) > -1) {
if (this.isUnderScoreCase) {
if (isUnderScoreCase) {
center += `${skey} ${type} \`json:"${key},omitempty" form:"${key}"\`\n`; center += `${skey} ${type} \`json:"${key},omitempty" form:"${key}"\`\n`;
} else { } else {
center += `${skey} ${type} \`json:"${caseKey},omitempty" form:"${caseKey}"\`\n`; center += `${skey} ${type} \`json:"${caseKey},omitempty" form:"${caseKey}"\`\n`;
@ -746,7 +746,7 @@ export default {
\n \n
`; `;
if (type == "string") { if (type == "string") {
if (this.isUnderScoreCase) {
if (isUnderScoreCase) {
center += `${skey}Like ${type} \`json:"${key}|like,omitempty" form:"${key}|like"\`\n`; center += `${skey}Like ${type} \`json:"${key}|like,omitempty" form:"${key}|like"\`\n`;
} else { } else {
center += `${skey}Like ${type} \`json:"${caseKey}|like,omitempty" form:"${caseKey}|like"\`\n`; center += `${skey}Like ${type} \`json:"${caseKey}|like,omitempty" form:"${caseKey}|like"\`\n`;

Loading…
Cancel
Save