mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 13:52:39 +08:00
[UPD]
1.优化注释 2.修改 mybatis模板中 controller注解 3.修改 mybatis模板中 dao文件使用为 mapper文件 4.修改 mybatis模板中 service实现类中的一个 bug 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper
This commit is contained in:
parent
1a4b3017c4
commit
d7cbe49b87
@ -51,16 +51,20 @@ public class ${classInfo.className}Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load查询
|
* [查詢] 根據主鍵 id 查詢
|
||||||
*/
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
@RequestMapping("/load")
|
@RequestMapping("/load")
|
||||||
public ReturnT<String> load(int id){
|
public ReturnT<String> load(int id){
|
||||||
return ${classInfo.className?uncap_first}Service.load(id);
|
return ${classInfo.className?uncap_first}Service.load(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* [查詢] 分頁查詢
|
||||||
*/
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
@RequestMapping("/pageList")
|
@RequestMapping("/pageList")
|
||||||
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int offset,
|
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int offset,
|
||||||
@RequestParam(required = false, defaultValue = "10") int pagesize) {
|
@RequestParam(required = false, defaultValue = "10") int pagesize) {
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ${classInfo.classComment}
|
|
||||||
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
|
||||||
*/
|
|
||||||
@Repository
|
|
||||||
public interface ${classInfo.className}Dao {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
* @param ${classInfo.className}Entity
|
|
||||||
*/
|
|
||||||
public Integer insert(@Param("${classInfo.className?uncap_first}") ${classInfo.className}Entity ${classInfo.className?uncap_first});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
public Integer delete(@Param("id") Integer id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新
|
|
||||||
* @param ${classInfo.className}Entity
|
|
||||||
*/
|
|
||||||
public Integer update(@Param("${classInfo.className?uncap_first}") ${classInfo.className}Entity ${classInfo.className?uncap_first});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据主键查询一个实体
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
public ${classInfo.className}Entity selectByPrimaryKey(@Param("id") Integer id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询Data
|
|
||||||
* @param offset
|
|
||||||
* @param pageSize
|
|
||||||
*/
|
|
||||||
public List<${classInfo.className}Entity> pageList(@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询Count
|
|
||||||
*/
|
|
||||||
public Integer pageListCount();
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${classInfo.classComment}
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface ${classInfo.className}Mapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [新增]
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
|
int insert(@Param("${classInfo.className?uncap_first}") ${classInfo.className} ${classInfo.className?uncap_first});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [刪除]
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
|
int delete(@Param("id") int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [更新]
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
|
int update(@Param("${classInfo.className?uncap_first}") ${classInfo.className} ${classInfo.className?uncap_first});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [查詢] 根據主鍵 id 查詢
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
|
${classInfo.className} load(@Param("id") int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [查詢] 分頁查詢
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
|
List<${classInfo.className}> pageList(@Param("offset") int offset,
|
||||||
|
@Param("pagesize") int pagesize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [查詢] 分頁查詢 count
|
||||||
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
|
**/
|
||||||
|
int pageListCount(@Param("offset") int offset,
|
||||||
|
@Param("pagesize") int pagesize);
|
||||||
|
|
||||||
|
}
|
||||||
@ -2,7 +2,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ${classInfo.classComment}
|
* ${classInfo.classComment}
|
||||||
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
*/
|
*/
|
||||||
public interface ${classInfo.className}Service {
|
public interface ${classInfo.className}Service {
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public interface ${classInfo.className}Service {
|
|||||||
public ReturnT<String> update(${classInfo.className} ${classInfo.className?uncap_first});
|
public ReturnT<String> update(${classInfo.className} ${classInfo.className?uncap_first});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load查询
|
* 根據主鍵 id 查詢
|
||||||
*/
|
*/
|
||||||
public ${classInfo.className} load(int id);
|
public ${classInfo.className} load(int id);
|
||||||
|
|
||||||
|
|||||||
@ -8,17 +8,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* ${classInfo.classComment}
|
* ${classInfo.classComment}
|
||||||
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
* @author ${authorName}
|
||||||
|
* @date ${.now?string('yyyy/MM/dd')}
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ${classInfo.className}ServiceImpl implements ${classInfo.className}Service {
|
public class ${classInfo.className}ServiceImpl implements ${classInfo.className}Service {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ${classInfo.className}Dao ${classInfo.className?uncap_first}Dao;
|
private ${classInfo.className}Mapper ${classInfo.className?uncap_first}Mapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> insert(${classInfo.className} ${classInfo.className?uncap_first}) {
|
public ReturnT<String> insert(${classInfo.className} ${classInfo.className?uncap_first}) {
|
||||||
|
|
||||||
@ -27,49 +26,41 @@ public class ${classInfo.className}ServiceImpl implements ${classInfo.className}
|
|||||||
return new ReturnT<String>(ReturnT.FAIL_CODE, "必要参数缺失");
|
return new ReturnT<String>(ReturnT.FAIL_CODE, "必要参数缺失");
|
||||||
}
|
}
|
||||||
|
|
||||||
${classInfo.className?uncap_first}Dao.insert(${classInfo.className?uncap_first});
|
${classInfo.className?uncap_first}Mapper.insert(${classInfo.className?uncap_first});
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> delete(int id) {
|
public ReturnT<String> delete(int id) {
|
||||||
int ret = ${classInfo.className?uncap_first}Dao.delete(id);
|
int ret = ${classInfo.className?uncap_first}Mapper.delete(id);
|
||||||
return ret>0?ReturnT.SUCCESS:ReturnT.FAIL;
|
return ret>0?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnT<String> update(${classInfo.className} ${classInfo.className?uncap_first}) {
|
public ReturnT<String> update(${classInfo.className} ${classInfo.className?uncap_first}) {
|
||||||
int ret = ${classInfo.className?uncap_first}Dao.update(${classInfo.className?uncap_first});
|
int ret = ${classInfo.className?uncap_first}Mapper.update(${classInfo.className?uncap_first});
|
||||||
return ret>0?ReturnT.SUCCESS:ReturnT.FAIL;
|
return ret>0?ReturnT.SUCCESS:ReturnT.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load查询
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public ${classInfo.className} load(int id) {
|
public ${classInfo.className} load(int id) {
|
||||||
return ${classInfo.className?uncap_first}Dao.load(id);
|
return ${classInfo.className?uncap_first}Mapper.load(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String,Object> pageList(int offset, int pagesize) {
|
public Map<String,Object> pageList(int offset, int pagesize) {
|
||||||
|
|
||||||
List<${classInfo.className}> pageList = ${classInfo.className?uncap_first}Dao.pageList(offset, pagesize);
|
List<${classInfo.className}> pageList = ${classInfo.className?uncap_first}Mapper.pageList(offset, pagesize);
|
||||||
int totalCount = ${classInfo.className?uncap_first}Dao.pageListCount(offset, pagesize);
|
int totalCount = ${classInfo.className?uncap_first}Mapper.pageListCount(offset, pagesize);
|
||||||
|
|
||||||
// result
|
// result
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<String, Object>();
|
||||||
maps.put("pageList", pageList);
|
result.put("pageList", pageList);
|
||||||
maps.put("totalCount", totalCount);
|
result.put("totalCount", totalCount);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,7 +156,7 @@ CREATE TABLE `userinfo` (
|
|||||||
</div>
|
</div>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<button type="button" class="btn btn-default generator" id="mybatis">mybatis</button>
|
<button type="button" class="btn btn-default generator" id="mybatis">mybatis</button>
|
||||||
<button type="button" class="btn btn-default generator" id="dao">dao</button>
|
<button type="button" class="btn btn-default generator" id="dao">mapper</button>
|
||||||
<button type="button" class="btn btn-default generator" id="service">service</button>
|
<button type="button" class="btn btn-default generator" id="service">service</button>
|
||||||
<button type="button" class="btn btn-default generator" id="service_impl">service_impl</button>
|
<button type="button" class="btn btn-default generator" id="service_impl">service_impl</button>
|
||||||
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user