-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat($auth-center): download and export role info
- Loading branch information
1 parent
bce0cf4
commit b6640ce
Showing
5 changed files
with
139 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 32 additions & 1 deletion
33
auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/controller/RoleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
package com.jmsoftware.maf.authcenter.role.controller; | ||
|
||
import com.jmsoftware.maf.authcenter.role.entity.RoleExcelImport; | ||
import com.jmsoftware.maf.authcenter.role.service.RoleService; | ||
import com.jmsoftware.maf.springcloudstarter.controller.AbstractExcelImportController; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Description: RoleController, change description here. | ||
* | ||
* @author 钟俊(zhongjun), email: zhongjun@toguide.cn, date: 12/17/2020 4:44 PM | ||
**/ | ||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
public class RoleController { | ||
@RequestMapping("/roles") | ||
public class RoleController extends AbstractExcelImportController<RoleExcelImport> { | ||
private final RoleService roleService; | ||
|
||
@GetMapping("/stat/excel") | ||
public ResponseEntity<StreamingResponseBody> downloadRoleStat() { | ||
return this.roleService.downloadRoleStat(); | ||
} | ||
|
||
@Override | ||
public void onExceptionOccurred() { | ||
log.error("Exception occurred when uploading excel for role."); | ||
} | ||
|
||
@Override | ||
protected void executeDatabaseOperation(List<RoleExcelImport> beanList) throws Exception { | ||
|
||
} | ||
|
||
@Override | ||
protected boolean validateBeforeAddToBeanList(List<RoleExcelImport> beanList, RoleExcelImport bean, int index) throws IllegalArgumentException { | ||
return false; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
auth-center/src/main/java/com/jmsoftware/maf/authcenter/role/entity/RoleExcelImport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.jmsoftware.maf.authcenter.role.entity; | ||
|
||
import com.jmsoftware.maf.authcenter.role.entity.persistence.Role; | ||
import com.jmsoftware.maf.springcloudstarter.annotation.ExcelColumn; | ||
import lombok.Data; | ||
import lombok.val; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
|
||
/** | ||
* Description: RoleExcelImport, change description here. | ||
* | ||
* @author Johnny Miller (锺俊), email: johnnysviva@outlook.com, date: 8/22/2021 10:52 AM | ||
**/ | ||
@Data | ||
public class RoleExcelImport { | ||
/** | ||
* Role name | ||
*/ | ||
@NotBlank | ||
@ExcelColumn(description = "Name") | ||
private String name; | ||
/** | ||
* Role description | ||
*/ | ||
@NotBlank | ||
@ExcelColumn(description = "Description") | ||
private String description; | ||
|
||
/** | ||
* Transform by role. | ||
* | ||
* @param role the role | ||
* @return the role excel import | ||
*/ | ||
public static RoleExcelImport transformBy(Role role) { | ||
val roleExcelImport = new RoleExcelImport(); | ||
roleExcelImport.setName(role.getName()); | ||
roleExcelImport.setDescription(role.getDescription()); | ||
return roleExcelImport; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters