Commit da023b59 authored by 刘凯's avatar 刘凯

增加remote remoteImpl等生成文件

parent d6a7578c
......@@ -4,9 +4,11 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="LOCAL" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$USER_HOME$/software/gradle-4.6" />
<option name="gradleHome" value="$USER_HOME$/Downloads/jar/gradle-6.6.1" />
<option name="gradleJvm" value="1.8" />
<option name="modules">
<set>
......
......@@ -3,7 +3,13 @@
<option name="myName" value="Project Default" />
<inspection_tool class="ComparatorNotSerializable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ExternalizableWithSerializationMethods" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonSerializableFieldInSerializableClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonSerializableFieldInSerializableClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignorableAnnotations">
<value />
</option>
<option name="ignoreAnonymousInnerClasses" value="false" />
<option name="superClassString" value="java.awt.Component" />
</inspection_tool>
<inspection_tool class="NonSerializableObjectBoundToHttpSession" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonSerializableObjectPassedToObjectStream" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonSerializableWithSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true" />
......@@ -14,9 +20,18 @@
<inspection_tool class="SerialPersistentFieldsWithWrongSignature" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerialVersionUIDNotStaticFinal" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableHasSerializationMethods" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableInnerClassHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableInnerClassWithNonSerializableOuterClass" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableHasSerializationMethods" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreAnonymousInnerClasses" value="false" />
<option name="superClassString" value="java.io.Externalizable,java.awt.Component" />
</inspection_tool>
<inspection_tool class="SerializableInnerClassHasSerialVersionUIDField" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreAnonymousInnerClasses" value="false" />
<option name="superClassString" value="java.awt.Component" />
</inspection_tool>
<inspection_tool class="SerializableInnerClassWithNonSerializableOuterClass" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoreAnonymousInnerClasses" value="false" />
<option name="superClassString" value="java.awt.Component" />
</inspection_tool>
<inspection_tool class="SerializableStoresNonSerializable" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="SerializableWithUnconstructableAncestor" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TransientFieldInNonSerializableClass" enabled="true" level="WARNING" enabled_by_default="true" />
......
......@@ -18,7 +18,7 @@ apply plugin: "idea"
apply plugin: "eclipse"
group = "cn.com.duiba"
version = "0.2.10"
version = "0.2.12"
sourceCompatibility = 1.8
targetCompatibility = 1.8
......
......@@ -2,6 +2,9 @@ package ${daoPackage};
import ${entityPackage}.${table.className}Entity;
import java.util.List;
import cn.com.duiba.api.bo.page.Page;
import cn.com.duiba.api.bo.page.PageQuery;
import java.util.Map;
public interface ${table.className}Dao {
......@@ -18,6 +21,10 @@ public interface ${table.className}Dao {
List<${table.className}Entity> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s);
Integer findCountByCondition(@Param("dataMap") Map<String, Object> paramMap);
List<${table.className}Entity> findByCondition(@Param("dataMap") Map<String, Object> paramMap,PageQuery page);
</#if>
<#list uks?keys as key>
${table.className}Entity getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>);
......
......@@ -9,6 +9,8 @@ import cn.com.duiba.developer.center.common.dao.DatabaseSchema;
import javax.annotation.PostConstruct;
import java.util.Map;
import com.google.common.collect.Maps;
import cn.com.duiba.api.bo.page.Page;
import cn.com.duiba.api.bo.page.PageQuery;
@Repository
......@@ -59,6 +61,19 @@ public class ${table.className}DaoImpl extends BaseDao implements ${table.classN
return selectList("listBy${pk.attrName}s",data);
}
@Override
public Integer findCountByCondition(Map<String, Object> paramMap){
return selectList("findCountByCondition",paramMap);
}
@Override
public List<${table.className}Entity> findByCondition(Map<String, Object> paramMap,PageQuery page){
paramMap.put("offset", pageQuery.getPageSize() * pageQuery.getPageNo());
paramMap.put("pageSize", pageQuery.getPageSize());
return selectList("findByCondition",paramMap);
}
</#if>
<#list uks?keys as key>
@Override
......
......@@ -4,6 +4,10 @@ import ${dtoPackage}.${table.className}Dto;
import java.util.List;
import cn.com.duiba.boot.exception.BizException;
import cn.com.duiba.boot.netflix.feign.AdvancedFeignClient;
import cn.com.duiba.api.bo.page.Page;
import cn.com.duiba.api.bo.page.PageQuery;
import java.util.Map;
@AdvancedFeignClient
public interface Remote${table.className}Service {
......@@ -21,6 +25,9 @@ public interface Remote${table.className}Service {
List<${table.className}Dto> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s) throws BizException;
Page<${table.className}Dto> findByPage(Map<String, Object> paramMap,PageQuery page) throws BizException;
</#if>
<#list uks?keys as key>
${table.className}Dto getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>) throws BizException;
......
......@@ -8,6 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.duiba.api.bo.page.Page;
import cn.com.duiba.api.bo.page.PageQuery;
import java.util.Map;
import java.util.Date;
@RestController
public class Remote${table.className}ServiceImpl implements Remote${table.className}Service{
......@@ -49,16 +54,21 @@ public class Remote${table.className}ServiceImpl implements Remote${table.classN
return ${table.classname}Service.listBy${pk.attrName}s(${pk.attrname}s);
}
@Override
Page<${table.className}Dto> findByPage(Map<String, Object> paramMap,PageQuery page) throws BizException {
return ${table.classname}Service.findByPage(paramMap,page);
}
</#if>
<#list uks?keys as key>
@Override
public ${table.className}Dto getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
return ${table.classNclassnameame}Service.getBy${key}(${uk.attrname});
return ${table.className}Service.getBy${key}(<#assign idx=0><#list uks[key] as uk> ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>));
}
@Override
public List<${table.className}Dto> listBy${key}s(<#assign idx=0><#list uks[key] as uk>List<${uk.attrType}> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
return ${table.classname}Service.listBy${key}s(${uk.attrname}s);
return ${table.classname}Service.listBy${key}(<#assign idx=0><#list uks[key] as uk> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>);
}
</#list>
......
......@@ -2,6 +2,10 @@ package ${serviceLocation};
import ${dtoPackage}.${table.className}Dto;
import java.util.List;
import cn.com.duiba.api.bo.page.Page;
import cn.com.duiba.api.bo.page.PageQuery;
import java.util.Map;
public interface ${table.className}Service {
......@@ -19,6 +23,8 @@ public interface ${table.className}Service {
List<${table.className}Dto> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s);
Page<${table.className}Dto> findByPage(Map<String, Object> paramMap,PageQuery page);
</#if>
<#list uks?keys as key>
${table.className}Dto getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>);
......
......@@ -12,6 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.com.duiba.wolf.utils.BeanUtils;
import cn.com.duiba.api.bo.page.Page;
import cn.com.duiba.api.bo.page.PageQuery;
import java.util.Map;
import java.util.Date;
@Service
public class ${table.className}ServiceImpl implements ${table.className}Service{
......@@ -49,20 +54,37 @@ public class ${table.className}ServiceImpl implements ${table.className}Service{
}
@Override
public List<${table.className}Dto> listBy${pk.attrName}s(List<${pk.attrType}> ${pk.attrname}s){
return BeanUtils.copyList(${table.classname}Dao.listBy${pk.attrName}s(${pk.attrname}s), ${table.className}Dto.class);
public Page<${table.className}Dto> findByPage(Map<String, Object> paramMap,PageQuery page) {
Integer totalTotal = ${table.classname}Dao.findCountByCondition(paramMap);
Page<${table.className}Dto> result = new Page<>();
result.setPageNo(pageQuery.getPageNo());
result.setPageSize(pageQuery.getPageSize());
if(totalTotal == 0){
result.setTotalCount(0);
result.setTotalPages(0);
result.setList(Lists.newArrayList());
return result;
}
List<${table.className}Dto> data = BeanUtils.copyList(${table.classname}Dao.findByCondition(paramMap,pageQuery), ${table.className}Dto.class);
int totalPages = count % pageQuery.getPageSize() > 0 ? count / pageQuery.getPageSize() + 1 : count / pageQuery.getPageSize();
result.setTotalCount(count);
result.setTotalPages(totalPages);
result.setList(data);
return result;
}
</#if>
<#list uks?keys as key>
@Override
public ${table.className}Dto getBy${key}(<#assign idx=0><#list uks[key] as uk>${uk.attrType} ${uk.attrname}<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
return BeanUtils.copy(${table.classname}Dao.getBy${key}(${uk.attrname}), ${table.className}Dto.class);
return BeanUtils.copy(${table.classname}Dao.getBy${key}(<#assign idx=0><#list uks[key] as uk> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>));
}
@Override
public List<${table.className}Dto> listBy${key}s(<#assign idx=0><#list uks[key] as uk>List<${uk.attrType}> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>){
return BeanUtils.copyList(${table.classname}Dao.listBy${key}s(${uk.attrname}s), ${table.className}Dto.class);
return BeanUtils.copyList(${table.classname}Dao.listBy${key}s(<#assign idx=0><#list uks[key] as uk> ${uk.attrname}s<#assign idx=idx+1><#if (idx<uks[key]?size)>,</#if></#list>));
}
</#list>
......
......@@ -61,6 +61,33 @@
</foreach>
</select>
<select id="findCountByCondition" resultMap="${table.classname}Map" parameterType="map">
SELECT <include refid="columns"/>
FROM ${table.tableSchema}.${table.tableName}
<where>
<foreach item="value" index="key" collection="dataMap" separator=";" >
<if test="key != null and key != 'offset' and key != 'pageSize'">
and ${r"#{key}"} = ${r"#{value}"}
</if>
</foreach>
</where>
</select>
<select id="findByCondition" resultMap="${table.classname}Map" parameterType="map">
SELECT <include refid="columns"/>
FROM ${table.tableSchema}.${table.tableName}
<where>
<foreach item="value" index="key" collection="dataMap" separator=";" >
<if test="key != null and key != 'offset' and key != 'pageSize'">
and ${r"#{key}"} = ${r"#{value}"}
</if>
</foreach>
</where>
LIMIT ${r"#{offset}"},${r"#{pageSize}"}
</select>
<#list uks?keys as key>
<select id="getBy${key}" resultMap="${table.classname}Map">
......
......@@ -6,9 +6,9 @@ public class CodeGeneratorTest {
public static void main(String[] args) {
String DB_URL = "jdbc:mysql://43.142.41.164:3307/ad_project?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&connectTimeout=5000&socketTimeout=60000";
String DB_URL = "jdbc:mysql://localhost:3306/test?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&connectTimeout=5000&socketTimeout=60000";
String user = "root";
String pwd = "liukai6651";
String pwd = "1234567890";
GeneratorConfig config = new GeneratorConfig(DB_URL, user, pwd);
config.setDaoPackage("cn.com.duiba.mysql.generator.test.dao");
......@@ -19,11 +19,11 @@ public class CodeGeneratorTest {
config.setServiceImplLocation("cn.com.duiba.mysql.generator.test.service.impl");
config.setDtoPackage("cn.com.duiba.mysql.generator.test.dto");
config.setRemotePackage("cn.com.duiba.mysql.generator.test.remote");
config.setRemoteImplLocation("cn.com.duiba.mysql.generator.test.remoteImpl");
config.setRemoteImplLocation("cn.com.duiba.mysql.generator.test.remoteimpl");
config.setVoLocation("cn.com.duiba.mysql.generator.test.vo");
config.setTableSchema("ad_project");
config.setTableName("ad_account_of_facebook");
config.setTableSchema("test");
config.setTableName("tb_test");
config.setTablePrefix("tb");
config.setModuleName("");
......
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