diff --git a/src/main/resources/generate/controller.txt b/src/main/resources/generate/controller.txt new file mode 100644 index 0000000..4e257af --- /dev/null +++ b/src/main/resources/generate/controller.txt @@ -0,0 +1,77 @@ +package {controllerPkgName}; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.boot.security.server.page.table.PageTableRequest; +import com.boot.security.server.page.table.PageTableHandler; +import com.boot.security.server.page.table.PageTableResponse; +import com.boot.security.server.page.table.PageTableHandler.CountHandler; +import com.boot.security.server.page.table.PageTableHandler.ListHandler; +import {daoPackageName}.{daoName}; +import {beanPackageName}.{beanName}; + +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("/{beanParamName}s") +public class {controllerName} { + + @Autowired + private {daoName} {daoParamName}; + + @PostMapping + @ApiOperation(value = "保存") + public {beanName} save(@RequestBody {beanName} {beanParamName}) { + {daoParamName}.save({beanParamName}); + + return {beanParamName}; + } + + @GetMapping("/{id}") + @ApiOperation(value = "根据id获取") + public {beanName} get(@PathVariable Long id) { + return {daoParamName}.getById(id); + } + + @PutMapping + @ApiOperation(value = "修改") + public {beanName} update(@RequestBody {beanName} {beanParamName}) { + {daoParamName}.update({beanParamName}); + + return {beanParamName}; + } + + @GetMapping + @ApiOperation(value = "列表") + public PageTableResponse<{beanName}> list(PageTableRequest request) { + return PageTableHandler.<{beanName}> builder().countHandler(new CountHandler() { + + @Override + public int count(PageTableRequest request) { + return {daoParamName}.count(request.getParams()); + } + }).listHandler(new ListHandler<{beanName}>() { + + @Override + public List<{beanName}> list(PageTableRequest request) { + return {daoParamName}.list(request.getParams(), request.getOffset(), request.getLimit()); + } + }).build().handle(request); + } + + @DeleteMapping("/{id}") + @ApiOperation(value = "删除") + public void delete(@PathVariable Long id) { + {daoParamName}.delete(id); + } +} diff --git a/src/main/resources/generate/dao.txt b/src/main/resources/generate/dao.txt new file mode 100644 index 0000000..c2b1cc4 --- /dev/null +++ b/src/main/resources/generate/dao.txt @@ -0,0 +1,33 @@ +package {daoPackageName}; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import {beanPackageName}.{beanName}; + +@Mapper +public interface {daoName} { + + @Select("select * from {table_name} t where t.id = #{id}") + {beanName} getById(Long id); + + @Delete("delete from {table_name} where id = #{id}") + int delete(Long id); + + int update({beanName} {beanParamName}); + + @Options(useGeneratedKeys = true, keyProperty = "id") + @Insert("insert into {table_name}({insert_columns}) values({insert_values})") + int save({beanName} {beanParamName}); + + int count(@Param("params") Map params); + + List<{beanName}> list(@Param("params") Map params, @Param("offset") Integer offset, @Param("limit") Integer limit); +} diff --git a/src/main/resources/generate/htmlAdd.txt b/src/main/resources/generate/htmlAdd.txt new file mode 100644 index 0000000..92f87cc --- /dev/null +++ b/src/main/resources/generate/htmlAdd.txt @@ -0,0 +1,61 @@ + + + + + + +
+
+
+{addDivs} + +
+
+
+ + +
+
+
+ +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/generate/htmlList.txt b/src/main/resources/generate/htmlList.txt new file mode 100644 index 0000000..4a4488b --- /dev/null +++ b/src/main/resources/generate/htmlList.txt @@ -0,0 +1,129 @@ + + + + +Insert title here + + + + + +
+
+
+
+
+ + + + + +
+
+
+ id: + + +
+
+
+ +
+
+
+ +
+
+ + + + + +{ths} + + + + +
操作
+
+
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/generate/htmlUpdate.txt b/src/main/resources/generate/htmlUpdate.txt new file mode 100644 index 0000000..9733f98 --- /dev/null +++ b/src/main/resources/generate/htmlUpdate.txt @@ -0,0 +1,79 @@ + + + + + + +
+
+
+ +{addDivs} + + +
+
+
+ + +
+
+
+ +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/generate/java.txt b/src/main/resources/generate/java.txt new file mode 100644 index 0000000..743ae93 --- /dev/null +++ b/src/main/resources/generate/java.txt @@ -0,0 +1,13 @@ +package {beanPackageName}; + +{import} + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class {beanName} extends BaseEntity { + +{filelds} +} \ No newline at end of file diff --git a/src/main/resources/generate/mapper.xml b/src/main/resources/generate/mapper.xml new file mode 100644 index 0000000..a24aa56 --- /dev/null +++ b/src/main/resources/generate/mapper.xml @@ -0,0 +1,33 @@ + + + + + + +{where} + + + + + + + + + update {table_name} t + +{update_sets} + + + where t.id = #{id} + + + \ No newline at end of file