Skip to content

Commit

Permalink
升级代码生成器版本,适配新代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao-Y committed Aug 13, 2021
1 parent a304dd9 commit 52a1290
Show file tree
Hide file tree
Showing 24 changed files with 570 additions and 163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
* @author liuyongtao
* @since 2021-8-12 14:33
*/
public interface HighLevelService<E, V extends BasePage> extends IService<E> {
public interface HighLevelService<E, SP extends BasePage> extends IService<E> {

/**
* 分页查询
*
* @param v 查询条件
* @param sp 查询条件
* @return {@link IPage<E>}
* @author liuyongtao
* @since 2021-8-13 10:35
*/
IPage<E> findListByPage(V v);
IPage<E> findListByPage(SP sp);

/**
* 根据ID禁用数据
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
* @version v1.0
* @since 2021-01-21
*/
public abstract class HighLevelServiceImpl<M extends BaseMapper<E>, E, V extends BasePage> extends ServiceImpl<M, E> implements HighLevelService<E, V> {
public abstract class HighLevelServiceImpl<M extends BaseMapper<E>, E, SP extends BasePage> extends ServiceImpl<M, E> implements HighLevelService<E, SP> {

@Override
public IPage<E> findListByPage(V v) {
IPage<E> page = new Page<>(v.getPageNo(), v.getPageSize());
public IPage<E> findListByPage(SP sp) {
IPage<E> page = new Page<>(sp.getPageNo(), sp.getPageSize());
LambdaQueryWrapper<E> wrapper = Wrappers.lambdaQuery();
// 查询条件
this.genQueryCondition(wrapper, v);
this.genQueryCondition(wrapper, sp);
return baseMapper.selectPage(page, wrapper);
}

Expand All @@ -41,11 +41,11 @@ public boolean prohibitById(Long id) {
* 分页查询的查询条件
*
* @param wrapper
* @param v
* @param sp
* @author liuyongtao
* @since 2021-8-13 10:20
*/
public void genQueryCondition(LambdaQueryWrapper<E> wrapper, V v) {
public void genQueryCondition(LambdaQueryWrapper<E> wrapper, SP sp) {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ private StrategyConfig getStrategyConfig() {
// strategy.setInclude("sk_seckill", "sk_success_killed");
// strategy.setTablePrefix("sk_");

// strategy.setInclude("p_goods_brand", "p_goods_category"
strategy.setInclude("p_goods_brand"
// , "p_goods_category"
// , "p_goods_category_brand"
// , "p_goods_safeguard"
// , "p_goods_sku"
Expand All @@ -250,18 +251,18 @@ private StrategyConfig getStrategyConfig() {
// , "p_goods_specification"
// , "p_goods_spu"
// , "p_goods_spu_detail"
// );
// strategy.setTablePrefix("p_");
);
strategy.setTablePrefix("p_");

strategy.setInclude("sys_apply_info",
"sys_city",
"sys_data_dictionary",
"sys_menu",
"sys_permission",
"sys_role",
"sys_white_list"
);
strategy.setTablePrefix("sys_");
// strategy.setInclude("sys_apply_info",
// "sys_city",
// "sys_data_dictionary",
// "sys_menu",
// "sys_permission",
// "sys_role",
// "sys_white_list"
// );
// strategy.setTablePrefix("sys_");
// strategy.setInclude("r_role_menu",
// "r_role_permission",
// "r_user_role"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
<#assign SC = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sc = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">
<#assign SP = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sp = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">

package com.billow.${package.ModuleName}.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.billow.mybatis.base.HighLevelService;
import com.billow.${package.ModuleName}.pojo.po.${entity};
import com.baomidou.mybatisplus.extension.service.IService;
import com.billow.${package.ModuleName}.pojo.search.${SC};
import com.billow.${package.ModuleName}.pojo.search.${SP};

/**
* <p>
* ${table.comment!} 服务类
* </p>
*
* @author ${author}
* @version v1.0
* @version v2.0
* @since ${date}
*/
public interface ${table.serviceName} extends IService<${entity}> {
public interface ${table.serviceName} extends HighLevelService<${entity},${SP}> {

/**
* 分页查询
*
* @param ${Sc} 查询条件
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.billow.${package.ModuleName}.pojo.po.${entity}>
* @author ${author}
* @since ${date}
*/
IPage<${entity}> findListByPage(${SC} ${Sc});

/**
* 根据ID禁用数据
*
* @param id 主键id
* @return boolean
* @author ${author}
* @since ${date}
*/
boolean prohibitById(String id);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<#assign SC = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sc = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">
<#assign SP = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sp = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">
package com.billow.${package.ModuleName}.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.billow.mybatis.base.HighLevelServiceImpl;
import com.billow.${package.ModuleName}.dao.${table.mapperName};
import com.billow.${package.ModuleName}.pojo.search.${SC};
import com.billow.${package.ModuleName}.pojo.search.${SP};
import com.billow.${package.ModuleName}.pojo.po.${entity};
import com.billow.${package.ModuleName}.service.${table.serviceName};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
Expand All @@ -20,36 +15,11 @@ import org.springframework.stereotype.Service;
* </p>
*
* @author ${author}
* @version v1.0
* @version v2.0
* @since ${date}
*/
@Service
public class ${table.serviceImplName} extends ServiceImpl<${table.mapperName}, ${entity}> implements ${table.serviceName} {
public class ${table.serviceImplName} extends HighLevelServiceImpl<${table.mapperName}, ${entity},${SP}> implements ${table.serviceName} {

@Autowired
private ${table.mapperName} ${table.mapperName?uncap_first};

@Override
public IPage<${entity}> findListByPage(${SC} ${Sc}) {
IPage<${entity}> page = new Page<>(${Sc}.getPageNo(), ${Sc}.getPageSize());
LambdaQueryWrapper<${entity}> wrapper = Wrappers.lambdaQuery();
// 查询条件
IPage<${entity}> selectPage = ${table.mapperName?uncap_first}.selectPage(page, wrapper);
<#if enableCache>
// 查询总条数
Integer total = ${table.mapperName?uncap_first}.selectCount(wrapper);
selectPage.setTotal(total);
</#if>
return selectPage;
}

@Override
public boolean prohibitById(String id) {
${entity} po = new ${entity}();
po.setValidInd(false);
LambdaQueryWrapper<${entity}> wrapper = Wrappers.lambdaQuery();
wrapper.eq(${entity}::getId, id);
return ${table.mapperName?uncap_first}.update(po, wrapper) >= 1;
}
}

Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
<#assign VO = table.entityName?substring(0,(table.entityName)?length-2) + "Vo">
<#assign Vo = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "Vo">
<#assign BD = table.entityName?substring(0,(table.entityName)?length-2) + "BuildParam">
<#assign Bd = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "BuildParam">
<#assign SC = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sc = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">
<#assign BP = table.entityName?substring(0,(table.entityName)?length-2) + "BuildParam">
<#assign Bp = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "BuildParam">
<#assign SP = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sp = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">
package ${package.Controller};

import com.billow.${package.ModuleName}.pojo.build.${BD};
import com.billow.seckill.app.HighLevelApi;
import com.billow.${package.ModuleName}.pojo.build.${BP};
import com.billow.${package.ModuleName}.pojo.vo.${VO};
import com.billow.${package.ModuleName}.pojo.search.${SC};
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.billow.${package.ModuleName}.service.${table.serviceName};
import com.billow.tools.utlis.ConvertUtils;
import com.billow.${package.ModuleName}.pojo.search.${SP};
import com.billow.${package.ModuleName}.pojo.po.${entity};
import com.billow.${package.ModuleName}.service.${table.serviceName};
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
* <p>
Expand All @@ -34,7 +28,7 @@ import ${superControllerClassPackage};
*
* @author ${author}
* @since ${date}
* @version v1.0
* @version v2.0
*/
@Slf4j
<#if restControllerStyle>
Expand All @@ -47,54 +41,7 @@ import ${superControllerClassPackage};
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

@Autowired
private ${table.serviceName} ${table.serviceName?uncap_first};

@ApiOperation(value = "查询分页${table.comment!}数据")
@PostMapping(value = "/findListByPage")
public IPage<${entity}> findListByPage(@RequestBody ${SC} ${Sc}){
return ${table.serviceName?uncap_first}.findListByPage(${Sc});
}

@ApiOperation(value = "根据id查询${table.comment!}数据")
@GetMapping(value = "/findById/{id}")
public ${VO} findById(@PathVariable("id") String id){
${entity} po = ${table.serviceName?uncap_first}.getById(id);
return ConvertUtils.convert(po, ${VO}.class);
}

@ApiOperation(value = "新增${table.comment!}数据")
@PostMapping(value = "/add")
public ${VO} add(@RequestBody ${BD} ${Bd}){
${entity} po = ConvertUtils.convert(${Bd}, ${entity}.class);
${table.serviceName?uncap_first}.save(po);
return ConvertUtils.convert(po, ${VO}.class);
}

@ApiOperation(value = "删除${table.comment!}数据")
@DeleteMapping(value = "/delById/{id}")
public boolean delById(@PathVariable("id") String id){
return ${table.serviceName?uncap_first}.removeById(id);
}

@ApiOperation(value = "更新${table.comment!}数据")
@PutMapping(value = "/update")
public ${VO} update(@RequestBody ${BD} ${Bd}){
${entity} po = ConvertUtils.convert(${Bd}, ${entity}.class);
${table.serviceName?uncap_first}.updateById(po);
return ConvertUtils.convert(po, ${VO}.class);
}
public class ${table.controllerName} extends HighLevelApi<${table.serviceName}, ${entity}, ${VO}, ${BP}, ${SP}> {

@ApiOperation("根据ID禁用${table.comment!}数据")
@PutMapping("/prohibitById/{id}")
public boolean prohibitById(@PathVariable String id) {
return ${table.serviceName?uncap_first}.prohibitById(id);
}
}
</#if>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.billow.mybatis.cache.MybatisRedisCache;
* </p>
*
* @author ${author}
* @version v2.0
* @since ${date}
*/
<#if enableCache>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<#assign SC = (table.entityName?substring(0,(table.entityName)?length-2)) + "SearchParam">
<#assign Sc = (table.entityName?substring(0,(table.entityName)?length-2))?uncap_first + "SearchParam">

package com.billow.${package.ModuleName}.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.billow.${package.ModuleName}.pojo.po.${entity};
import com.baomidou.mybatisplus.extension.service.IService;
import com.billow.${package.ModuleName}.pojo.search.${SC};

/**
* <p>
* ${table.comment!} 服务类
* </p>
*
* @author ${author}
* @version v1.0
* @since ${date}
*/
public interface ${table.serviceName} extends IService<${entity}> {

/**
* 分页查询
*
* @param ${Sc} 查询条件
* @return com.baomidou.mybatisplus.core.metadata.IPage<com.billow.${package.ModuleName}.pojo.po.${entity}>
* @author ${author}
* @since ${date}
*/
IPage<${entity}> findListByPage(${SC} ${Sc});

/**
* 根据ID禁用数据
*
* @param id 主键id
* @return boolean
* @author ${author}
* @since ${date}
*/
boolean prohibitById(String id);
}
Loading

0 comments on commit 52a1290

Please sign in to comment.