Commit 5c4cb6c1 by xxlv

Fix tpl

parent b001e2b3
...@@ -5,6 +5,7 @@ import os ...@@ -5,6 +5,7 @@ import os
import shutil import shutil
import argparse import argparse
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import re
DIR = "./template" DIR = "./template"
TMP = "./tmp" TMP = "./tmp"
...@@ -189,7 +190,7 @@ def gen_po(res_name, project_target_path): ...@@ -189,7 +190,7 @@ def gen_po(res_name, project_target_path):
print("Mybatis 路径有误") print("Mybatis 路径有误")
exit(-1) exit(-1)
tables_name = res_name tables_name = get_table_name(res_name)
local_mybatis_config = config_mybatis(res_name, tables_name, mybatis_config_path) local_mybatis_config = config_mybatis(res_name, tables_name, mybatis_config_path)
...@@ -279,6 +280,25 @@ def clean_tmp(): ...@@ -279,6 +280,25 @@ def clean_tmp():
print("清空目录 {}".format(TMP)) print("清空目录 {}".format(TMP))
def get_res_name(res_name):
# TODO
# 转化为驼峰
pass
def get_table_name(res_name):
table_name = ""
res_name = res_name[0:1].lower() + res_name[1:]
for i in range(0, len(res_name)):
t = res_name[i]
if (t.isupper()):
t = "".join(["_", t.lower()])
table_name = "".join([table_name, t])
return table_name
def gen(res_name, look_path): def gen(res_name, look_path):
""" """
核心逻辑 核心逻辑
...@@ -288,8 +308,7 @@ def gen(res_name, look_path): ...@@ -288,8 +308,7 @@ def gen(res_name, look_path):
:return: :return:
""" """
clean_tmp() clean_tmp()
res_name = get_res_name(res_name)
res_name = res_name[0].upper() + res_name[1:]
print("----------------------------------") print("----------------------------------")
print("你的资源名称为 {}".format(res_name)) print("你的资源名称为 {}".format(res_name))
print("----------------------------------") print("----------------------------------")
...@@ -308,7 +327,6 @@ def gen(res_name, look_path): ...@@ -308,7 +327,6 @@ def gen(res_name, look_path):
compile_table['${PLACE}'] = "{}{}".format(res_name[0].upper(), res_name[1:]) compile_table['${PLACE}'] = "{}{}".format(res_name[0].upper(), res_name[1:])
compile_table['${PLACE_VAR}'] = "{}{}".format(res_name[0].lower(), res_name[1:]) compile_table['${PLACE_VAR}'] = "{}{}".format(res_name[0].lower(), res_name[1:])
import re
intf = PROJECT_TARGET_PATH["intf_po_path"] intf = PROJECT_TARGET_PATH["intf_po_path"]
p = re.compile("[\s\S]*\/(.+)\-intf\/[\s\S]*") p = re.compile("[\s\S]*\/(.+)\-intf\/[\s\S]*")
...@@ -344,6 +362,10 @@ def gen(res_name, look_path): ...@@ -344,6 +362,10 @@ def gen(res_name, look_path):
PROJECT_TARGET_PATH) PROJECT_TARGET_PATH)
safe_cpfile(compiled_file, PROJECT_TARGET_PATH, res_name) safe_cpfile(compiled_file, PROJECT_TARGET_PATH, res_name)
print("---------------------------------------------")
print("你已经成功的生成了代码")
print("---------------------------------------------")
if __name__ == "__main__": if __name__ == "__main__":
print("-------------------------") print("-------------------------")
...@@ -354,7 +376,6 @@ if __name__ == "__main__": ...@@ -354,7 +376,6 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auto create Resource for ydl java project") parser = argparse.ArgumentParser(description="Auto create Resource for ydl java project")
parser.add_argument('--verbose', '-v', action='store_true', help='debug mode') parser.add_argument('--verbose', '-v', action='store_true', help='debug mode')
parser.add_argument("resource_name") parser.add_argument("resource_name")
parser.add_argument("package")
parser.add_argument("project_path") parser.add_argument("project_path")
args = parser.parse_args() args = parser.parse_args()
......
package com.ydl.user.intf.po; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL1}.intf.po;
public class ${PLACE} { public class ${PLACE} {
......
package com.ydl.user.service.biz; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.biz;
import com.ydl.common.service.IService; import com.${PACKAGE_LEVEL1}.common.service.IService;
import com.ydl.user.intf.po.${PLACE}; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.po.${PLACE};
public interface ${PLACE}Biz extends IService<${PLACE}> { public interface ${PLACE}Biz extends IService<${PLACE}> {
......
package com.ydl.user.service.biz.impl; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.biz.impl;
import com.ydl.user.intf.po.${PLACE}; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.po.${PLACE};
import com.ydl.user.service.biz.${PLACE}Biz; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.biz.${PLACE}Biz;
import com.ydl.user.service.dao.${PLACE}Mapper; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.dao.${PLACE}Mapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ydl.common.service.impl.BaseService; import com.ydl.common.service.impl.BaseService;
......
package com.ydl.user.intf.facade; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.facade;
import com.ydl.common.dto.BaseDtoResponse; import com.${PACKAGE_LEVEL1}.common.dto.BaseDtoResponse;
import com.ydl.user.intf.dto.request.{PLACE}ReqDto; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.dto.request.{PLACE}ReqDto;
import com.ydl.user.intf.dto.response.{PLACE}RespDto; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.dto.response.{PLACE}RespDto;
public interface ${PLACE}Facade { public interface ${PLACE}Facade {
BaseDtoResponse<${PLACE}RespDto> create${PLACE}(${PLACE}ReqDto ${PLACE_VAR}ReqDto); BaseDtoResponse<${PLACE}RespDto> create${PLACE}(${PLACE}ReqDto ${PLACE_VAR}ReqDto);
......
package com.ydl.user.service.facade; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.facade;
import com.ydl.common.dto.BaseDtoResponse; import com.${PACKAGE_LEVEL1}.common.dto.BaseDtoResponse;
import com.ydl.common.helper.ResponseFormatterHelper; import com.${PACKAGE_LEVEL1}.common.helper.ResponseFormatterHelper;
import com.ydl.common.utils.ModelMapperUtil; import com.${PACKAGE_LEVEL1}.common.utils.ModelMapperUtil;
import com.ydl.user.intf.facade.${PLACE}Facade; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.facade.${PLACE}Facade;
import com.ydl.user.service.biz.${PLACE}Biz; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.biz.${PLACE}Biz;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
......
package com.ydl.user.service.dao; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.service.dao;
import com.ydl.common.service.BaseMapper; import com.${PACKAGE_LEVEL1}.common.service.BaseMapper;
import com.ydl.user.intf.po.${PLACE}; import com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.po.${PLACE};
public interface ${PLACE}Mapper extends BaseMapper<${PLACE}> { public interface ${PLACE}Mapper extends BaseMapper<${PLACE}> {
} }
package com.ydl.user.intf.dto.request; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.dto.request;
import java.io.Serializable; import java.io.Serializable;
......
package com.ydl.user.intf.dto.response; package com.${PACKAGE_LEVEL1}.${PACKAGE_LEVEL2}.intf.dto.response;
public class ${PLACE}RespDto { public class ${PLACE}RespDto {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment