| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupImportExcelVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupImportReqVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupImportRespVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupRespVO; |
| | | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupSaveReqVO; |
| | |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得用户组") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") |
| | | public CommonResult<BpmUserGroupRespVO> getUserGroup(@RequestParam("id") Long id) { |
| | | BpmUserGroupDO userGroup = userGroupService.getUserGroup(id); |
| | | return success(BeanUtils.toBean(userGroup, BpmUserGroupRespVO.class)); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得用户组分页") |
| | | @PreAuthorize("@ss.hasPermission('bpm:user-group:query')") |
| | | public CommonResult<PageResult<BpmUserGroupRespVO>> getUserGroupPage(@Valid BpmUserGroupPageReqVO pageVO) { |
| | | PageResult<BpmUserGroupDO> pageResult = userGroupService.getUserGroupPage(pageVO); |
| | | return success(BeanUtils.toBean(pageResult, BpmUserGroupRespVO.class)); |
| | |
| | | return success(convertList(list, group -> new BpmUserGroupRespVO().setId(group.getId()).setName(group.getName()))); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入用户组模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<BpmUserGroupImportExcelVO> list = Arrays.asList( |
| | | BpmUserGroupImportExcelVO.builder().name("示例用户组").description("示例用户组") |
| | | .userNames("示例用户A,示例用户B") |
| | | .status(CommonStatusEnum.ENABLE.getStatus()).build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "用户组导入模板.xls", "用户组列表", BpmUserGroupImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入用户组") |
| | | @PreAuthorize("@ss.hasPermission('bpm:user-group:import')") |
| | | public CommonResult<BpmUserGroupImportRespVO> importExcel(@Valid BpmUserGroupImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<BpmUserGroupImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), BpmUserGroupImportExcelVO.class); |
| | | return success(userGroupService.importUserGroupList(list, importReqVO)); |
| | | } |
| | | |
| | | } |