diff --git a/generator-web/src/main/resources/statics/js/common.js b/generator-web/src/main/resources/statics/js/common.js index 48030c1..8900e5f 100644 --- a/generator-web/src/main/resources/statics/js/common.js +++ b/generator-web/src/main/resources/statics/js/common.js @@ -41,4 +41,29 @@ window.confirm = function(msg, callback){ //判断是否为空 function isBlank(value) { return !value || !/\S/.test(value) +} + +function setCookie(key, val, expire_second) { + var d = new Date(); + var expires =""; + if (expire_second){ + d.setDate(d.getTime()+(expire_second*1000)); + expires='; expires=' + d.toGMTSring(); + } + document.cookie = key + "="+ val + expires; +} + +function getCookie(name) { + var data = ""; + if (document.cookie){ + var arr = document.cookie.split(';'); + for (var str of arr) { + var temp = str.split("=") + if (temp[0].replace(/(^\s*)/g,'') === name){ + data = unescape(temp[1]); + break + } + } + } + return data; } \ No newline at end of file diff --git a/generator-web/src/main/resources/statics/js/main.js b/generator-web/src/main/resources/statics/js/main.js index aab5880..fd01eb0 100644 --- a/generator-web/src/main/resources/statics/js/main.js +++ b/generator-web/src/main/resources/statics/js/main.js @@ -123,6 +123,7 @@ const vm = new Vue({ error("生成失败"); return; } + setAllCookie(); //console.log(res.outputJson); vm.outputJson=res.outputJson; // console.log(vm.outputJson["bootstrap-ui"]); @@ -154,3 +155,41 @@ const vm = new Vue({ } }); +/** + * 将所有 需要 保留历史纪录的字段写入Cookie中 + */ +function setAllCookie() { + var arr = list_key_need_load(); + for (var str of arr){ + setOneCookie(str); + } +} + +function setOneCookie(key) { + setCookie(key, vm.formData.options[key]); +} + +/** + * 将所有 历史纪录 重加载回页面 + */ +function loadAllCookie() { + //console.log(vm); + var arr = list_key_need_load(); + for (var str of arr){ + loadOneCookie(str); + } +} + +function loadOneCookie(key) { + if (getCookie(key)!==""){ + vm.formData.options[key] = getCookie(key); + } +} + +/** + * 将 所有 需要 纪录的 字段写入数组 + * @returns {[string]} + */ +function list_key_need_load() { + return ["authorName","packageName","returnUtilSuccess","returnUtilFailure","ignorePrefix","tinyintTransType","timeTransType"]; +} diff --git a/generator-web/src/main/resources/templates/code-generator/jpa/jpacontroller.ftl b/generator-web/src/main/resources/templates/code-generator/jpa/jpacontroller.ftl index c6c9829..b783035 100644 --- a/generator-web/src/main/resources/templates/code-generator/jpa/jpacontroller.ftl +++ b/generator-web/src/main/resources/templates/code-generator/jpa/jpacontroller.ftl @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; +import java.util.Optional; + /** * @description ${classInfo.classComment} diff --git a/generator-web/src/main/resources/templates/code-generator/jpa/repository.ftl b/generator-web/src/main/resources/templates/code-generator/jpa/repository.ftl index c2a8aff..c3643a2 100644 --- a/generator-web/src/main/resources/templates/code-generator/jpa/repository.ftl +++ b/generator-web/src/main/resources/templates/code-generator/jpa/repository.ftl @@ -1,4 +1,4 @@ -<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.mapper; +<#if isWithPackage?exists && isWithPackage==true>package ${packageName}.repository; <#if isAutoImport?exists && isAutoImport==true>import ${packageName}.entity.${classInfo.className}; <#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0> diff --git a/generator-web/src/main/resources/templates/main.html b/generator-web/src/main/resources/templates/main.html index c87313b..4ed0486 100644 --- a/generator-web/src/main/resources/templates/main.html +++ b/generator-web/src/main/resources/templates/main.html @@ -140,6 +140,7 @@ vm.formData.options.returnUtilSuccess="${(value.returnUtilSuccess)!!}"; vm.formData.options.returnUtilFailure="${(value.returnUtilFailure)!!}"; vm.outputStr="${(value.outputStr)!!}"; + loadAllCookie() \ No newline at end of file