Skip to content

Commit

Permalink
Excel分离
Browse files Browse the repository at this point in the history
  • Loading branch information
twelvet-s committed Aug 5, 2023
1 parent a9661f0 commit 7917a8f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<hutool.version>5.8.19</hutool.version>
<redisson.version>3.18.0</redisson.version>
<qiniu.version>7.12.1</qiniu.version>
<excel-spring-boot-starter.version>1.0.0</excel-spring-boot-starter.version>

<docker.plugin.version>0.32.0</docker.plugin.version>
<spring.checkstyle.plugin>0.0.39</spring.checkstyle.plugin>
Expand Down Expand Up @@ -285,6 +286,13 @@
<version>${twelvet.version}</version>
</dependency>

<!--Excel-->
<dependency>
<groupId>cn.twelvet.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
<version>${excel-spring-boot-starter.version}</version>
</dependency>

<!--job API-->
<dependency>
<groupId>com.twelvet</groupId>
Expand Down
6 changes: 6 additions & 0 deletions twelvet-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<artifactId>twelvet-framework-swagger</artifactId>
</dependency>

<!--Excel-->
<dependency>
<groupId>cn.twelvet.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>

</dependencies>

</project>
6 changes: 6 additions & 0 deletions twelvet-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

<!--Excel-->
<dependency>
<groupId>cn.twelvet.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import com.twelvet.framework.log.annotation.Log;
import com.twelvet.framework.log.enums.BusinessType;
import org.springframework.security.access.prepost.PreAuthorize;
import cn.dev33.satoken.annotation.SaCheckPermission;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.twelvet.framework.core.application.controller.TWTController;
import com.twelvet.framework.core.application.domain.AjaxResult;
import com.twelvet.framework.core.application.domain.JsonResult;
import com.twelvet.framework.utils.poi.ExcelUtils;
import cn.twelvet.excel.annotation.ResponseExcel;
#if($table.crud || $table.sub)
import com.twelvet.framework.jdbc.web.utils.PageUtils;
#elseif($table.tree)
Expand All @@ -37,18 +37,18 @@ import com.twelvet.framework.jdbc.web.utils.PageUtils;
*/
@Tag(description = "${ClassName}Controller", name = "${functionName}")
@RestController
@RequestMapping("/${businessName}")
@RequestMapping("/${moduleName}/${businessName}")
public class ${ClassName}Controller extends TWTController
{
@Autowired
private I${ClassName}Service ${className}Service;

/**
* 查询${functionName}列表
*/
@Operation(summary = "查询${functionName}列表")
@PreAuthorize("@role.hasPermi('${permissionPrefix}:list')")
@GetMapping("/pageQuery")
/**
* 查询${functionName}列表
*/
@Operation(summary = "查询${functionName}列表")
@SaCheckPermission("${permissionPrefix}:list")
@GetMapping("/pageQuery")
#if($table.crud || $table.sub)
public JsonResult<TableDataInfo> pageQuery(${ClassName} ${className})
{
Expand All @@ -67,22 +67,21 @@ public class ${ClassName}Controller extends TWTController
/**
* 导出${functionName}列表
*/
@ResponseExcel(name = "${functionName}")
@Operation(summary = "导出${functionName}列表")
@PreAuthorize("@role.hasPermi('${permissionPrefix}:export')")
@SaCheckPermission("${permissionPrefix}:export")
@Log(service = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className})
public List<${ClassName}> export(${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
ExcelUtils<${ClassName}> util = new ExcelUtils<${ClassName}>(${ClassName}.class);
util.exportExcel(response, list, "${functionName}数据");
return ${className}Service.select${ClassName}List(${className});
}

/**
* 获取${functionName}详细信息
*/
@Operation(summary = "获取${functionName}详细信息")
@PreAuthorize("@role.hasPermi('${permissionPrefix}:query')")
@SaCheckPermission("${permissionPrefix}:query")
@GetMapping(value = "/{${pkColumn.javaField}}")
public JsonResult<${ClassName}> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
{
Expand All @@ -93,7 +92,7 @@ public class ${ClassName}Controller extends TWTController
* 新增${functionName}
*/
@Operation(summary = "新增${functionName}")
@PreAuthorize("@role.hasPermi('${permissionPrefix}:add')")
@SaCheckPermission("${permissionPrefix}:add")
@Log(service = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
public JsonResult<String> add(@RequestBody ${ClassName} ${className})
Expand All @@ -105,7 +104,7 @@ public class ${ClassName}Controller extends TWTController
* 修改${functionName}
*/
@Operation(summary = "修改${functionName}")
@PreAuthorize("@role.hasPermi('${permissionPrefix}:edit')")
@SaCheckPermission("${permissionPrefix}:edit")
@Log(service = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping
public JsonResult<String> edit(@RequestBody ${ClassName} ${className})
Expand All @@ -117,7 +116,7 @@ public class ${ClassName}Controller extends TWTController
* 删除${functionName}
*/
@Operation(summary = "删除${functionName}")
@PreAuthorize("@role.hasPermi('${permissionPrefix}:remove')")
@SaCheckPermission("${permissionPrefix}:remove")
@Log(service = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
public JsonResult<String> remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ${packageName}.domain;
#foreach ($import in $importList)
import ${import};
#end
import com.twelvet.framework.utils.annotation.excel.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.twelvet.framework.core.application.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
Expand Down Expand Up @@ -43,12 +43,12 @@ public class ${ClassName} extends ${Entity} {
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@ExcelProperty(value ="${comment}($column.readConverterExp())")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
@ExcelProperty(value ="${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
@ExcelProperty(value ="${comment}")
#end
#end
private $column.javaType $column.javaField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public class ${subClassName} extends BaseEntity
#set($comment=$column.columnComment)
#end
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@ExcelProperty(value ="${comment}($column.readConverterExp())")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
@ExcelProperty(value ="${comment}", width = 30, dateFormat = "yyyy-MM-dd")
#else
@Excel(name = "${comment}")
@ExcelProperty(value ="${comment}")
#end
#end
private $column.javaType $column.javaField;
Expand Down

0 comments on commit 7917a8f

Please sign in to comment.