| | |
| | | */ |
| | | @GetMapping("/captchaImage") |
| | | public R<Map<String, Object>> getCode() { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | boolean captchaEnabled = configService.selectCaptchaEnabled(); |
| | | ajax.put("captchaEnabled", captchaEnabled); |
| | | if (!captchaEnabled) { |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of("captchaEnabled", false)); |
| | | } |
| | | // 保存验证码信息 |
| | | String uuid = IdUtil.simpleUUID(); |
| | |
| | | code = exp.getValue(String.class); |
| | | } |
| | | RedisUtils.setCacheObject(verifyKey, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION)); |
| | | ajax.put("uuid", uuid); |
| | | ajax.put("img", captcha.getImageBase64()); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of("uuid", uuid, "img", captcha.getImageBase64())); |
| | | } |
| | | |
| | | } |
| | |
| | | import cn.dev33.satoken.annotation.SaIgnore; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.satoken.utils.LoginHelper; |
| | | import com.ruoyi.system.domain.SysMenu; |
| | | import com.ruoyi.system.domain.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginBody; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.domain.model.SmsLoginBody; |
| | | import com.ruoyi.common.satoken.utils.LoginHelper; |
| | | import com.ruoyi.system.domain.SysMenu; |
| | | import com.ruoyi.system.domain.SysUser; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.SysLoginService; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @SaIgnore |
| | | @PostMapping("/login") |
| | | public R<Map<String, Object>> login(@Validated @RequestBody LoginBody loginBody) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | // 生成令牌 |
| | | String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), |
| | | loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, token); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of(Constants.TOKEN, token)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaIgnore |
| | | @PostMapping("/smsLogin") |
| | | public R<Map<String, Object>> smsLogin(@Validated @RequestBody SmsLoginBody smsLoginBody) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | // 生成令牌 |
| | | String token = loginService.smsLogin(smsLoginBody.getPhonenumber(), smsLoginBody.getSmsCode()); |
| | | ajax.put(Constants.TOKEN, token); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of(Constants.TOKEN, token)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaIgnore |
| | | @PostMapping("/xcxLogin") |
| | | public R<Map<String, Object>> xcxLogin(@NotBlank(message = "{xcx.code.not.blank}") String xcxCode) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | // 生成令牌 |
| | | String token = loginService.xcxLogin(xcxCode); |
| | | ajax.put(Constants.TOKEN, token); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of(Constants.TOKEN, token)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R<Map<String, Object>> getInfo() { |
| | | LoginUser loginUser = LoginHelper.getLoginUser(); |
| | | SysUser user = userService.selectUserById(loginUser.getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", loginUser.getRolePermission()); |
| | | ajax.put("permissions", loginUser.getMenuPermission()); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of( |
| | | "user", user, |
| | | "roles", loginUser.getRolePermission(), |
| | | "permissions", loginUser.getMenuPermission() |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @GetMapping("getRouters") |
| | | public R<List<RouterVo>> getRouters() { |
| | | Long userId = LoginHelper.getUserId(); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId); |
| | | List<SysMenu> menus = menuService.selectMenuTreeByUserId(LoginHelper.getUserId()); |
| | | return R.ok(menuService.buildMenus(menus)); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.common.core.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 用户状态 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum UserStatus { |
| | | OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); |
| | | /** |
| | | * 正常 |
| | | */ |
| | | OK("0", "正常"), |
| | | /** |
| | | * 停用 |
| | | */ |
| | | DISABLE("1", "停用"), |
| | | /** |
| | | * 删除 |
| | | */ |
| | | DELETED("2", "删除"); |
| | | |
| | | private final String code; |
| | | private final String info; |
| | | |
| | | UserStatus(String code, String info) { |
| | | this.code = code; |
| | | this.info = info; |
| | | } |
| | | |
| | | public String getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getInfo() { |
| | | return info; |
| | | } |
| | | } |
| | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.extra.servlet.JakartaServletUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import jakarta.servlet.ServletRequest; |
| | | import jakarta.servlet.http.HttpServletRequest; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | |
| | | * @return 编码后的内容 |
| | | */ |
| | | public static String urlEncode(String str) { |
| | | try { |
| | | return URLEncoder.encode(str, Constants.UTF8); |
| | | } catch (UnsupportedEncodingException e) { |
| | | return StringUtils.EMPTY; |
| | | } |
| | | return URLEncoder.encode(str, StandardCharsets.UTF_8); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return 解码后的内容 |
| | | */ |
| | | public static String urlDecode(String str) { |
| | | try { |
| | | return URLDecoder.decode(str, Constants.UTF8); |
| | | } catch (UnsupportedEncodingException e) { |
| | | return StringUtils.EMPTY; |
| | | } |
| | | return URLDecoder.decode(str, StandardCharsets.UTF_8); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true |
| | | * |
| | | * @param name |
| | | * @return boolean |
| | | */ |
| | | public static boolean containsBean(String name) { |
| | | return getBeanFactory().containsBean(name); |
| | |
| | | /** |
| | | * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 |
| | | * 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) |
| | | * |
| | | * @param name |
| | | * @return boolean |
| | | */ |
| | | public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { |
| | | return getBeanFactory().isSingleton(name); |
| | | } |
| | | |
| | | /** |
| | | * @param name |
| | | * @return Class 注册对象的类型 |
| | | */ |
| | | public static Class<?> getType(String name) throws NoSuchBeanDefinitionException { |
| | |
| | | |
| | | /** |
| | | * 如果给定的bean名字在bean定义中有别名,则返回这些别名 |
| | | * |
| | | * @param name |
| | | */ |
| | | public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { |
| | | return getBeanFactory().getAliases(name); |
| | |
| | | |
| | | /** |
| | | * 获取aop代理对象 |
| | | * |
| | | * @param invoker |
| | | * @return |
| | | */ |
| | | @SuppressWarnings("unchecked") |
| | | public static <T> T getAopProxy(T invoker) { |
| | |
| | | * |
| | | * @param pattern 匹配规则 |
| | | * @param url 需要匹配的url |
| | | * @return |
| | | */ |
| | | public static boolean isMatch(String pattern, String url) { |
| | | AntPathMatcher matcher = new AntPathMatcher(); |
| | |
| | | * @param size 字符串指定长度 |
| | | * @return 返回数字的字符串格式,该字符串为指定长度。 |
| | | */ |
| | | public static final String padl(final Number num, final int size) { |
| | | public static String padl(final Number num, final int size) { |
| | | return padl(num.toString(), size, '0'); |
| | | } |
| | | |
| | |
| | | * @param c 用于补齐的字符 |
| | | * @return 返回指定长度的字符串,由原字符串左补齐或截取得到。 |
| | | */ |
| | | public static final String padl(final String s, final int size, final char c) { |
| | | public static String padl(final String s, final int size, final char c) { |
| | | final StringBuilder sb = new StringBuilder(size); |
| | | if (s != null) { |
| | | final int len = s.length(); |
| | | if (s.length() <= size) { |
| | | for (int i = size - len; i > 0; i--) { |
| | | sb.append(c); |
| | | } |
| | | sb.append(String.valueOf(c).repeat(size - len)); |
| | | sb.append(s); |
| | | } else { |
| | | return s.substring(len - size, len); |
| | | } |
| | | } else { |
| | | for (int i = size; i > 0; i--) { |
| | | sb.append(c); |
| | | } |
| | | sb.append(String.valueOf(c).repeat(Math.max(0, size))); |
| | | } |
| | | return sb.toString(); |
| | | } |
| | |
| | | package com.ruoyi.common.core.utils.file; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | |
| | |
| | | * @param response 响应对象 |
| | | * @param realFileName 真实文件名 |
| | | */ |
| | | public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException { |
| | | public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) { |
| | | String percentEncodedFileName = percentEncode(realFileName); |
| | | |
| | | StringBuilder contentDispositionValue = new StringBuilder(); |
| | | contentDispositionValue.append("attachment; filename=") |
| | | .append(percentEncodedFileName) |
| | | .append(";") |
| | | .append("filename*=") |
| | | .append("utf-8''") |
| | | .append(percentEncodedFileName); |
| | | |
| | | String contentDispositionValue = "attachment; filename=%s;filename*=utf-8''%s".formatted(percentEncodedFileName, percentEncodedFileName); |
| | | response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); |
| | | response.setHeader("Content-disposition", contentDispositionValue.toString()); |
| | | response.setHeader("Content-disposition", contentDispositionValue); |
| | | response.setHeader("download-filename", percentEncodedFileName); |
| | | } |
| | | |
| | |
| | | * @param s 需要百分号编码的字符串 |
| | | * @return 百分号编码后的字符串 |
| | | */ |
| | | public static String percentEncode(String s) throws UnsupportedEncodingException { |
| | | String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString()); |
| | | public static String percentEncode(String s) { |
| | | String encode = URLEncoder.encode(s, StandardCharsets.UTF_8); |
| | | return encode.replaceAll("\\+", "%20"); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.common.excel.core.DefaultExcelListener; |
| | | import com.ruoyi.common.excel.core.ExcelListener; |
| | | import com.ruoyi.common.excel.core.ExcelResult; |
| | | import jakarta.servlet.ServletOutputStream; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AccessLevel; |
| | | import lombok.NoArgsConstructor; |
| | | |
| | | import jakarta.servlet.ServletOutputStream; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | /** |
| | | * 重置响应体 |
| | | */ |
| | | private static void resetResponse(String sheetName, HttpServletResponse response) throws UnsupportedEncodingException { |
| | | private static void resetResponse(String sheetName, HttpServletResponse response) { |
| | | String filename = encodingFilename(sheetName); |
| | | FileUtils.setAttachmentResponseHeader(response, filename); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8"); |
| | |
| | | if (StringUtils.containsAny(propertyValue, separator)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[0].equals(value)) { |
| | | propertyString.append(itemArray[1] + separator); |
| | | propertyString.append(itemArray[1]).append(separator); |
| | | break; |
| | | } |
| | | } |
| | |
| | | if (StringUtils.containsAny(propertyValue, separator)) { |
| | | for (String value : propertyValue.split(separator)) { |
| | | if (itemArray[1].equals(value)) { |
| | | propertyString.append(itemArray[0] + separator); |
| | | propertyString.append(itemArray[0]).append(separator); |
| | | break; |
| | | } |
| | | } |
| | |
| | | String var = Convert.toStr(var1); |
| | | if (dataBasyType == DataBaseType.SQL_SERVER) { |
| | | // charindex(',100,' , ',0,100,101,') <> 0 |
| | | return "charindex('," + var + ",' , ','+" + var2 + "+',') <> 0"; |
| | | return "charindex(',%s,' , ','+%s+',') <> 0".formatted(var, var2); |
| | | } else if (dataBasyType == DataBaseType.POSTGRE_SQL) { |
| | | // (select position(',100,' in ',0,100,101,')) <> 0 |
| | | return "(select position('," + var + ",' in ','||" + var2 + "||',')) <> 0"; |
| | | return "(select position(',%s,' in ','||%s||',')) <> 0".formatted(var, var2); |
| | | } else if (dataBasyType == DataBaseType.ORACLE) { |
| | | // instr(',0,100,101,' , ',100,') <> 0 |
| | | return "instr(','||" + var2 + "||',' , '," + var + ",') <> 0"; |
| | | return "instr(','||%s||',' , ',%s,') <> 0".formatted(var2, var); |
| | | } |
| | | // find_in_set(100 , '0,100,101') |
| | | return "find_in_set(" + var + " , " + var2 + ") <> 0"; |
| | | return "find_in_set(%s , %s) <> 0".formatted(var, var2); |
| | | } |
| | | } |
| | |
| | | private static String getPolicy(String bucketName, PolicyType policyType) { |
| | | StringBuilder builder = new StringBuilder(); |
| | | builder.append("{\n\"Statement\": [\n{\n\"Action\": [\n"); |
| | | if (policyType == PolicyType.WRITE) { |
| | | builder.append("\"s3:GetBucketLocation\",\n\"s3:ListBucketMultipartUploads\"\n"); |
| | | } else if (policyType == PolicyType.READ_WRITE) { |
| | | builder.append("\"s3:GetBucketLocation\",\n\"s3:ListBucket\",\n\"s3:ListBucketMultipartUploads\"\n"); |
| | | } else { |
| | | builder.append("\"s3:GetBucketLocation\"\n"); |
| | | } |
| | | builder.append(switch (policyType) { |
| | | case WRITE -> "\"s3:GetBucketLocation\",\n\"s3:ListBucketMultipartUploads\"\n"; |
| | | case READ_WRITE -> "\"s3:GetBucketLocation\",\n\"s3:ListBucket\",\n\"s3:ListBucketMultipartUploads\"\n"; |
| | | default -> "\"s3:GetBucketLocation\"\n"; |
| | | }); |
| | | builder.append("],\n\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::"); |
| | | builder.append(bucketName); |
| | | builder.append("\"\n},\n"); |
| | |
| | | builder.append("\"\n},\n"); |
| | | } |
| | | builder.append("{\n\"Action\": "); |
| | | switch (policyType) { |
| | | case WRITE -> |
| | | builder.append("[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n"); |
| | | case READ_WRITE -> |
| | | builder.append("[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n"); |
| | | default -> |
| | | builder.append("\"s3:GetObject\",\n"); |
| | | } |
| | | builder.append(switch (policyType) { |
| | | case WRITE -> "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n"; |
| | | case READ_WRITE -> "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n"; |
| | | default -> "\"s3:GetObject\",\n"; |
| | | }); |
| | | builder.append("\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::"); |
| | | builder.append(bucketName); |
| | | builder.append("/*\"\n}\n],\n\"Version\": \"2012-10-17\"\n}\n"); |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 缓存监控 |
| | |
| | | @GetMapping() |
| | | public R<Map<String, Object>> getInfo() throws Exception { |
| | | RedisConnection connection = connectionFactory.getConnection(); |
| | | Properties info = connection.commands().info(); |
| | | Properties commandStats = connection.commands().info("commandstats"); |
| | | Long dbSize = connection.commands().dbSize(); |
| | | |
| | | Map<String, Object> result = new HashMap<>(3); |
| | | result.put("info", info); |
| | | result.put("dbSize", dbSize); |
| | | |
| | | List<Map<String, String>> pieList = new ArrayList<>(); |
| | | if (commandStats != null) { |
| | |
| | | pieList.add(data); |
| | | }); |
| | | } |
| | | result.put("commandStats", pieList); |
| | | return R.ok(result); |
| | | return R.ok(Map.of( |
| | | "info", connection.commands().info(), |
| | | "dbSize", connection.commands().dbSize(), |
| | | "commandStats", pieList |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.lang.tree.Tree; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.satoken.utils.LoginHelper; |
| | | import com.ruoyi.system.domain.SysMenu; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @GetMapping(value = "/roleMenuTreeselect/{roleId}") |
| | | public R<Map<String, Object>> roleMenuTreeselect(@PathVariable("roleId") Long roleId) { |
| | | List<SysMenu> menus = menuService.selectMenuList(LoginHelper.getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); |
| | | ajax.put("menus", menuService.buildMenuTreeSelect(menus)); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of( |
| | | "checkedKeys", menuService.selectMenuListByRoleId(roleId), |
| | | "menus", menuService.buildMenuTreeSelect(menus) |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | package com.ruoyi.system.controller.system; |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import com.ruoyi.common.idempotent.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.validate.AddGroup; |
| | | import com.ruoyi.common.core.validate.EditGroup; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.idempotent.annotation.RepeatSubmit; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.bo.SysOssConfigBo; |
| | | import com.ruoyi.system.domain.vo.SysOssConfigVo; |
| | | import com.ruoyi.system.service.ISysOssConfigService; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 对象存储配置 |
| | |
| | | @DeleteMapping("/{ossConfigIds}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossConfigIds) { |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(Arrays.asList(ossConfigIds), true)); |
| | | return toAjax(iSysOssConfigService.deleteWithValidByIds(List.of(ossConfigIds), true)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpException; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.validate.QueryGroup; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.core.utils.file.FileUtils; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.system.domain.bo.SysOssBo; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotEmpty; |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | throw new ServiceException("上传文件不能为空"); |
| | | } |
| | | SysOssVo oss = iSysOssService.upload(file); |
| | | Map<String, String> map = new HashMap<>(2); |
| | | map.put("url", oss.getUrl()); |
| | | map.put("fileName", oss.getOriginalName()); |
| | | map.put("ossId", oss.getOssId().toString()); |
| | | return R.ok(map); |
| | | return R.ok(Map.of( |
| | | "url", oss.getUrl(), |
| | | "fileName", oss.getOriginalName(), |
| | | "ossId", oss.getOssId().toString() |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | @SaCheckPermission("system:oss:download") |
| | | @GetMapping("/download/{ossId}") |
| | | public void download(@PathVariable Long ossId, HttpServletResponse response) throws IOException { |
| | | iSysOssService.download(ossId,response); |
| | | iSysOssService.download(ossId, response); |
| | | } |
| | | |
| | | /** |
| | |
| | | @DeleteMapping("/{ossIds}") |
| | | public R<Void> remove(@NotEmpty(message = "主键不能为空") |
| | | @PathVariable Long[] ossIds) { |
| | | return toAjax(iSysOssService.deleteWithValidByIds(Arrays.asList(ossIds), true)); |
| | | return toAjax(iSysOssService.deleteWithValidByIds(List.of(ossIds), true)); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | import cn.dev33.satoken.secure.BCrypt; |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.satoken.utils.LoginHelper; |
| | | import com.ruoyi.system.domain.SysUser; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.file.MimeTypeUtils; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.satoken.utils.LoginHelper; |
| | | import com.ruoyi.system.domain.SysUser; |
| | | import com.ruoyi.system.domain.vo.SysOssVo; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | @GetMapping |
| | | public R<Map<String, Object>> profile() { |
| | | SysUser user = userService.selectUserById(LoginHelper.getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName())); |
| | | ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName())); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of( |
| | | "user", user, |
| | | "roleGroup", userService.selectUserRoleGroup(user.getUserName()), |
| | | "postGroup", userService.selectUserPostGroup(user.getUserName()) |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping(value = "/avatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public R<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile avatarfile) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | if (!avatarfile.isEmpty()) { |
| | | String extension = FileUtil.extName(avatarfile.getOriginalFilename()); |
| | | if (!StringUtils.equalsAnyIgnoreCase(extension, MimeTypeUtils.IMAGE_EXTENSION)) { |
| | |
| | | SysOssVo oss = iSysOssService.upload(avatarfile); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(LoginHelper.getUsername(), avatar)) { |
| | | ajax.put("imgUrl", avatar); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of("imgUrl", avatar)); |
| | | } |
| | | } |
| | | return R.fail("上传图片异常,请联系管理员"); |
| | |
| | | |
| | | import cn.dev33.satoken.annotation.SaCheckPermission; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.core.constant.UserConstants; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.web.controller.BaseController; |
| | | import com.ruoyi.common.excel.utils.ExcelUtil; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.mybatis.core.page.PageQuery; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.satoken.utils.LoginHelper; |
| | | import com.ruoyi.system.domain.SysDept; |
| | | import com.ruoyi.system.domain.SysRole; |
| | | import com.ruoyi.system.domain.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.mybatis.core.page.TableDataInfo; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.excel.utils.ExcelUtil; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.SysPermissionService; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | @SaCheckPermission("system:role:list") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public R<Map<String, Object>> roleDeptTreeselect(@PathVariable("roleId") Long roleId) { |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of( |
| | | "checkedKeys", deptService.selectDeptListByRoleId(roleId), |
| | | "depts", deptService.selectDeptTreeList(new SysDept()) |
| | | )); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) { |
| | | return R.fail("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return R.fail("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return R.fail("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setPassword(BCrypt.hashpw(user.getPassword())); |
| | |
| | | if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user))) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } else if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | return toAjax(userService.updateUser(user)); |
| | |
| | | public R<Map<String, Object>> authRole(@PathVariable Long userId) { |
| | | SysUser user = userService.selectUserById(userId); |
| | | List<SysRole> roles = roleService.selectRolesByUserId(userId); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roles", LoginHelper.isAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin())); |
| | | return R.ok(ajax); |
| | | return R.ok(Map.of( |
| | | "user", user, |
| | | "roles", LoginHelper.isAdmin(userId) ? roles : StreamUtils.filter(roles, r -> !r.isAdmin()) |
| | | )); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public ExcelResult<SysUserImportVo> getExcelResult() { |
| | | return new ExcelResult<SysUserImportVo>() { |
| | | return new ExcelResult<>() { |
| | | |
| | | @Override |
| | | public String getAnalysis() { |
| | |
| | | |
| | | /** |
| | | * 递归列表 |
| | | * |
| | | * @param list |
| | | * @param t |
| | | */ |
| | | private void recursionFn(List<SysMenu> list, SysMenu t) { |
| | | // 得到子节点列表 |