codehelper.properties 配置示例


### config Pojos to generate, split by |
pojos=SamplePojo|AccountPojo

### config use Generic Dao or not
useGenericDao=false

### config expand mybatis xml or not
mapper.expand=true

### Sql File Charset
charset=utf8

### Sql File sqlEngine
sqlEngine=InnoDB

### path directory configuration
mapper.path=src/main/resources/mapper
dao.path=src/main/java/com/codehelper/sample/dao
service.path=src/main/java/com/codehelper/sample/service
sql.path=doc/sql/generator

codehelper.properties 配置说明


 pojos=UserDto|AccountDto|OrderDto

useGenericDao = true | false 默认为 false

使用useGenericDao = false 配置,生成Dao和Service代码示例:


Dao文件代码:

public interface UserDtoDao {

   int insert(@Param("pojo") UserDto pojo);

   int insertList(@Param("pojos") List< UserDto> pojo);

   List<UserDto> select(@Param("pojo") UserDto pojo);

   int update(@Param("pojo") UserDto pojo);

   int delete(@Param("pojo") UserDto pojo);

}

Service文件代码:

@Service
public class UserDtoService {

   @Resource
   private UserDtoDao userDtoDao;

   public int insert(UserDto pojo){
       return userDtoDao.insert(pojo);
   }

   public int insertList(List< UserDto> pojos){
       return userDtoDao.insertList(pojos);
   }

   public List<UserDto> select(UserDto pojo){
       return userDtoDao.select(pojo);
   }

   public int update(UserDto pojo){
       return userDtoDao.update(pojo);
   }

   public int delete(UserDto pojo){
       return userDtoDao.delete(pojo);
   }

}

使用useGenericDao = true配置,在工程中增加GenericDao.java 和GenericService.java,代码见Github

生成Dao和Service代码示例:


Dao文件代码:
public interface UserDtoDao extends GenericDao<UserDto> {

}

Service 文件代码:

@Service
public class UserDtoService extends GenericService<UserDto> {

   @Resource
   private UserDtoDao userDtoDao;

   @Override
   public GenericDao<UserDto> getGenericDao() {
       return userDtoDao;
   }
}

sqlEngine= InnoDB

charset=utf8


  dao.path=src/main/java/com/codehelper/sample/dao

  service.path=src/main/java/com/codehelper/sample/service/dto

  mapper.path=src/main/resources/mappers

  sql.path=doc/sql


<if test="pojo.id != null"> id = #{pojo.id}, </if>

<if test="pojo.id != null">
     id = #{pojo.id},
</if>

< Back