feat(修改): 代码不要的地方
This commit is contained in:
parent
a5680029ff
commit
c82f6f2757
|
@ -20,7 +20,7 @@ public class NewCodeGet {
|
||||||
public static final String entity = "Bunny";
|
public static final String entity = "Bunny";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Generation("sys_router");
|
Generation("sys_i18n", "sys_i18n_type");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package cn.bunny.dao.entity.i18n;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.BaseEntity;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Schema(name = "I18n对象", title = "多语言表", description = "多语言表")
|
|
||||||
public class I18n extends BaseEntity {
|
|
||||||
|
|
||||||
@Schema(name = "typeId", title = "语言类型id")
|
|
||||||
private Long typeId;
|
|
||||||
|
|
||||||
@Schema(name = "keyName", title = "多语言key")
|
|
||||||
private String keyName;
|
|
||||||
|
|
||||||
@Schema(name = "summary", title = "翻译")
|
|
||||||
private String summary;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package cn.bunny.dao.entity.i18n;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.BaseEntity;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("i18n_type")
|
|
||||||
@Schema(name = "I18nType", title = "多语言类型表", description = "多语言类型表")
|
|
||||||
public class I18nType extends BaseEntity {
|
|
||||||
|
|
||||||
@Schema(name = "languageName", title = "语言名称")
|
|
||||||
private String languageName;
|
|
||||||
|
|
||||||
@Schema(name = "summary", title = "语言名")
|
|
||||||
private String summary;
|
|
||||||
|
|
||||||
@Schema(name = "isDefault", title = "是否作为默认语言")
|
|
||||||
private Byte isDefault;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.bunny.services.controller;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言表 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
@Tag(name = "多语言", description = "多语言相关接口")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/i18n")
|
|
||||||
public class I18nController {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.bunny.services.controller;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言类型表 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
@Tag(name = "多语言类型", description = "多语言类型相关接口")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/i18nType")
|
|
||||||
public class I18nTypeController {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package cn.bunny.services.service.process;
|
package cn.bunny.services.factory;
|
||||||
|
|
||||||
import cn.bunny.dao.vo.common.TreeSelectVo;
|
import cn.bunny.dao.vo.common.TreeSelectVo;
|
||||||
import cn.bunny.dao.vo.router.RouterManageVo;
|
import cn.bunny.dao.vo.router.RouterManageVo;
|
||||||
|
@ -10,7 +10,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class RouterServiceProcess {
|
public class RouterServiceFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 递归调用设置子路由
|
* * 递归调用设置子路由
|
|
@ -1,18 +0,0 @@
|
||||||
package cn.bunny.services.mapper;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.i18n.I18n;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言表 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface I18nMapper extends BaseMapper<I18n> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package cn.bunny.services.mapper;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.i18n.I18nType;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言类型表 Mapper 接口
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface I18nTypeMapper extends BaseMapper<I18nType> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -9,15 +9,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求未认证接口
|
* 请求未认证接口
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SecurityAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
public class SecurityAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||||
@Override
|
@Override
|
||||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException {
|
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
|
||||||
String token = response.getHeader("token");
|
String token = response.getHeader("token");
|
||||||
String message = authException.getMessage();
|
String message = authException.getMessage();
|
||||||
// 创建结果对象
|
// 创建结果对象
|
||||||
|
|
|
@ -2,7 +2,6 @@ package cn.bunny.services.security.handelr;
|
||||||
|
|
||||||
import cn.bunny.dao.pojo.result.Result;
|
import cn.bunny.dao.pojo.result.Result;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import jakarta.servlet.ServletException;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
@ -11,7 +10,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class SecurityAuthenticationFailureHandler implements org.springframework.security.web.authentication.AuthenticationFailureHandler {
|
public class SecurityAuthenticationFailureHandler implements org.springframework.security.web.authentication.AuthenticationFailureHandler {
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
|
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException {
|
||||||
// 错误消息
|
// 错误消息
|
||||||
String localizedMessage = exception.getLocalizedMessage();
|
String localizedMessage = exception.getLocalizedMessage();
|
||||||
Result<String> result = Result.error(localizedMessage);
|
Result<String> result = Result.error(localizedMessage);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package cn.bunny.services.security.service.iml;
|
package cn.bunny.services.security.service.iml;
|
||||||
|
|
||||||
import cn.bunny.common.service.context.BaseContext;
|
import cn.bunny.common.service.context.BaseContext;
|
||||||
import cn.bunny.common.service.utils.JwtHelper;
|
|
||||||
import cn.bunny.dao.entity.system.Power;
|
import cn.bunny.dao.entity.system.Power;
|
||||||
import cn.bunny.services.mapper.PowerMapper;
|
import cn.bunny.services.mapper.PowerMapper;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
@ -36,10 +35,6 @@ public class CustomAuthorizationManagerServiceImpl implements AuthorizationManag
|
||||||
public AuthorizationDecision check(Supplier<Authentication> authentication, RequestAuthorizationContext context) {
|
public AuthorizationDecision check(Supplier<Authentication> authentication, RequestAuthorizationContext context) {
|
||||||
// 用户的token和用户id、请求Url
|
// 用户的token和用户id、请求Url
|
||||||
HttpServletRequest request = context.getRequest();
|
HttpServletRequest request = context.getRequest();
|
||||||
String token = request.getHeader("token");
|
|
||||||
|
|
||||||
// 用户id
|
|
||||||
Long userId = JwtHelper.getUserId(token);
|
|
||||||
|
|
||||||
// 请求地址
|
// 请求地址
|
||||||
String requestURI = request.getRequestURI();
|
String requestURI = request.getRequestURI();
|
||||||
|
@ -74,6 +69,6 @@ public class CustomAuthorizationManagerServiceImpl implements AuthorizationManag
|
||||||
List<Power> powerList = powerMapper.selectListByPowerCodes(powerCodes);
|
List<Power> powerList = powerMapper.selectListByPowerCodes(powerCodes);
|
||||||
|
|
||||||
// 判断是否与请求路径匹配
|
// 判断是否与请求路径匹配
|
||||||
return powerList.stream().anyMatch(power -> power.getRequestUrl().equals(requestURI));
|
return powerList.stream().anyMatch(power -> requestURI.matches(power.getRequestUrl()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.springframework.util.DigestUtils;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CustomUserDetailsService implements cn.bunny.services.security.service.CustomUserDetailsService {
|
public class CustomUserDetailsServiceImpl implements cn.bunny.services.security.service.CustomUserDetailsService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
|
@ -1,16 +0,0 @@
|
||||||
package cn.bunny.services.service;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.i18n.I18n;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言表 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
public interface I18nService extends IService<I18n> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
package cn.bunny.services.service;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.i18n.I18nType;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言类型表 服务类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
public interface I18nTypeService extends IService<I18nType> {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.bunny.services.service.impl;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.i18n.I18n;
|
|
||||||
import cn.bunny.services.mapper.I18nMapper;
|
|
||||||
import cn.bunny.services.service.I18nService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言表 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class I18nServiceImpl extends ServiceImpl<I18nMapper, I18n> implements I18nService {
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.bunny.services.service.impl;
|
|
||||||
|
|
||||||
import cn.bunny.dao.entity.i18n.I18nType;
|
|
||||||
import cn.bunny.services.mapper.I18nTypeMapper;
|
|
||||||
import cn.bunny.services.service.I18nTypeService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 多语言类型表 服务实现类
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Bunny
|
|
||||||
* @since 2024-09-26
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class I18nTypeServiceImpl extends ServiceImpl<I18nTypeMapper, I18nType> implements I18nTypeService {
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,9 +11,9 @@ import cn.bunny.dao.vo.router.RouterManageVo;
|
||||||
import cn.bunny.dao.vo.router.RouterMeta;
|
import cn.bunny.dao.vo.router.RouterMeta;
|
||||||
import cn.bunny.dao.vo.router.UserRouterVo;
|
import cn.bunny.dao.vo.router.UserRouterVo;
|
||||||
import cn.bunny.dao.vo.user.LoginVo;
|
import cn.bunny.dao.vo.user.LoginVo;
|
||||||
|
import cn.bunny.services.factory.RouterServiceFactory;
|
||||||
import cn.bunny.services.mapper.RouterMapper;
|
import cn.bunny.services.mapper.RouterMapper;
|
||||||
import cn.bunny.services.service.RouterService;
|
import cn.bunny.services.service.RouterService;
|
||||||
import cn.bunny.services.service.process.RouterServiceProcess;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
||||||
@Transactional
|
@Transactional
|
||||||
public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> implements RouterService {
|
public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> implements RouterService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RouterServiceProcess routerServiceProcess;
|
private RouterServiceFactory routerServiceFactory;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisTemplate<String, Object> redisTemplate;
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ public class RouterServiceImpl extends ServiceImpl<RouterMapper, Router> impleme
|
||||||
// 构建树形结构
|
// 构建树形结构
|
||||||
routerVoList.forEach(routerVo -> {
|
routerVoList.forEach(routerVo -> {
|
||||||
if (routerVo.getParentId() == 0) {
|
if (routerVo.getParentId() == 0) {
|
||||||
routerVo.setChildren(routerServiceProcess.handleGetChildrenWIthRouter(routerVo.getId(), routerVoList));
|
routerVo.setChildren(routerServiceFactory.handleGetChildrenWIthRouter(routerVo.getId(), routerVoList));
|
||||||
list.add(routerVo);
|
list.add(routerVo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="cn.bunny.services.mapper.I18nMapper">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.i18n.I18n">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="type_id" property="typeId"/>
|
|
||||||
<result column="key_name" property="keyName"/>
|
|
||||||
<result column="summary" property="summary"/>
|
|
||||||
<result column="create_user" property="createUser"/>
|
|
||||||
<result column="create_time" property="createTime"/>
|
|
||||||
<result column="update_time" property="updateTime"/>
|
|
||||||
<result column="update_user" property="updateUser"/>
|
|
||||||
<result column="is_deleted" property="isDeleted"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id, type_id, key_name, summary, create_user, create_time, update_time, update_user, is_deleted
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
</mapper>
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="cn.bunny.services.mapper.I18nTypeMapper">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.i18n.I18nType">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="language_name" property="languageName"/>
|
|
||||||
<result column="summary" property="summary"/>
|
|
||||||
<result column="is_default" property="isDefault"/>
|
|
||||||
<result column="create_user" property="createUser"/>
|
|
||||||
<result column="create_time" property="createTime"/>
|
|
||||||
<result column="update_time" property="updateTime"/>
|
|
||||||
<result column="update_user" property="updateUser"/>
|
|
||||||
<result column="is_deleted" property="isDeleted"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
|
||||||
<sql id="Base_Column_List">
|
|
||||||
id, language_name, summary, is_default, create_user, create_time, update_time, update_user, is_deleted
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue