| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.vci.ubcs.common.validator.ComprehensiveFileValidator; |
| | | import com.vci.ubcs.system.cache.NacosConfigCache; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.excel.UserExcel; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.AllArgsConstructor; |
| | | import com.vci.ubcs.common.cache.CacheNames; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.hibernate.validator.internal.util.logging.Log; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import com.vci.ubcs.system.user.service.IUserService; |
| | | import com.vci.ubcs.system.user.vo.UserVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import springfox.documentation.annotations.ApiIgnore; |
| | |
| | | @RestController |
| | | @RequestMapping |
| | | @AllArgsConstructor |
| | | @lombok.extern.java.Log |
| | | @Slf4j |
| | | public class UserController { |
| | | |
| | | private final IUserService userService; |
| | | |
| | | private final BladeRedis bladeRedis; |
| | | |
| | | private final NacosConfigCache nacosConfigCache; |
| | | |
| | | /** |
| | | * 文件安全检查 |
| | | */ |
| | | private ComprehensiveFileValidator fileValidator; |
| | | |
| | | /** |
| | | * 查询单条 |
| | |
| | | */ |
| | | @PostMapping("/grant") |
| | | @ApiOperationSupport(order = 7) |
| | | @ApiOperation(value = "权限设置", notes = "传入roleId集合以及menuId集合") |
| | | @ApiOperation(value = "权限设置", notes = "传入userIds集合以及roleIds集合") |
| | | //@PreAuth(RoleConstant.HAS_ROLE_ADMIN) |
| | | public R grant(@ApiParam(value = "userId集合", required = true) @RequestParam String userIds, |
| | | @ApiParam(value = "roleId集合", required = true) @RequestParam String roleIds) { |
| | | boolean temp = userService.grant(userIds, roleIds); |
| | | boolean temp = false; |
| | | try { |
| | | temp = userService.grant(userIds, roleIds); |
| | | // 插入授权日志 |
| | | userService.grantLog(UserWrapper.build().entityVO(userService.getById(userIds)).toString(),false); |
| | | }catch (Exception e){ |
| | | // 插入授权日志 |
| | | userService.grantLog(e.getMessage(),true); |
| | | throw e; |
| | | } |
| | | return R.status(temp); |
| | | } |
| | | |
| | |
| | | @ApiOperationSupport(order = 12) |
| | | @ApiOperation(value = "导入用户", notes = "传入excel") |
| | | public R importUser(MultipartFile file, Integer isCovered) { |
| | | // 使用文件安全验证器 |
| | | ComprehensiveFileValidator.UploadValidationResult result = fileValidator.validateFile(file); |
| | | if (!result.isValid()) { |
| | | return R.fail(result.getMessage()); |
| | | } |
| | | UserImporter userImporter = new UserImporter(userService, isCovered == 1); |
| | | ExcelUtil.save(file, userImporter, UserExcel.class); |
| | | return R.success("操作成功"); |
| | |
| | | ExcelUtil.export(response, "用户数据模板", "用户数据表", list, UserExcel.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 第三方注册用户 |
| | | */ |
| | |
| | | public R registerGuest(User user, Long oauthId) { |
| | | return R.status(userService.registerGuest(user, oauthId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 配置用户平台信息 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取到指定身份权限的用户列表 |
| | | * 修改用户状态 停用/启用 |
| | | * @param userIds userId集合 |
| | | * @param status 停用/启用 true:启用,false:停用 |
| | | * @param status 停用/启用; true:启用,false:停用 |
| | | * @return |
| | | */ |
| | | @PostMapping("/updateUserStatus") |
| | | @ApiOperationSupport(order = 21) |
| | | @ApiOperation(value = "获取到指定身份权限的用户列表", notes = "传入userId集合") |
| | | public R<Boolean> updateUserStatus(String userIds,boolean status){ |
| | | public R<Boolean> updateUserStatus(@Valid @RequestParam("userIds") String userIds,boolean status){ |
| | | if (StringUtil.isBlank(userIds)) { |
| | | return R.fail("请至少选择一个用户"); |
| | | } |
| | | return R.status(userService.updateUserStatus(userIds,status)); |
| | | } |
| | | |
| | | } |