6 changed files with 255 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||||||
|
package com.water.watersys.controller; |
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil; |
||||||
|
import com.water.watersys.components.Result; |
||||||
|
import com.water.watersys.mapper.RouteSysMapper; |
||||||
|
import com.water.watersys.model.domain.RoleSys; |
||||||
|
import com.water.watersys.model.domain.RouteSys; |
||||||
|
import com.water.watersys.service.RoleSysService; |
||||||
|
import com.water.watersys.service.RouteSysService; |
||||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin; |
||||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||||
|
import org.springframework.web.bind.annotation.PutMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@RestController |
||||||
|
@CrossOrigin |
||||||
|
@Tag(name = "路由信息", description = "路由信息") |
||||||
|
public class RouteController { |
||||||
|
@Resource |
||||||
|
private RouteSysService routeSysService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RoleSysService roleSysService; |
||||||
|
|
||||||
|
@Operation(summary = "获取路由信息", description = "获取路由信息") |
||||||
|
@GetMapping("/getRoute") |
||||||
|
public Result<List<RouteSys>> getRoute() { |
||||||
|
String loginId = (String) StpUtil.getLoginId(); |
||||||
|
List<RoleSys> role = roleSysService.getRole(loginId); |
||||||
|
ArrayList<RouteSys> roleList = new ArrayList<>(); |
||||||
|
role.forEach(roleSys->{ |
||||||
|
List<RouteSys> route = routeSysService.getRoute(roleSys.getId()); |
||||||
|
roleList.addAll(route); |
||||||
|
}); |
||||||
|
return Result.success(roleList); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.water.watersys.mapper; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import com.water.watersys.model.domain.RouteSys; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
import org.apache.ibatis.annotations.Select; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author mac |
||||||
|
* @description 针对表【route_sys(路由表)】的数据库操作Mapper |
||||||
|
* @createDate 2025-04-13 14:43:46 |
||||||
|
* @Entity generator.domain.RouteSys |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface RouteSysMapper extends BaseMapper<RouteSys> { |
||||||
|
|
||||||
|
@Select("select * from role_route_sys a left join route_sys b on a.route_id = b.id where a.role_id = #{loginId}") |
||||||
|
List<RouteSys> getRoute(Integer loginId); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,115 @@ |
|||||||
|
package com.water.watersys.model.domain; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* 路由表 |
||||||
|
* @TableName route_sys |
||||||
|
*/ |
||||||
|
@Data |
||||||
|
public class RouteSys { |
||||||
|
/** |
||||||
|
* |
||||||
|
*/ |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 子组件id |
||||||
|
*/ |
||||||
|
private Integer parentid; |
||||||
|
|
||||||
|
/** |
||||||
|
* 路由路径 |
||||||
|
*/ |
||||||
|
private String path; |
||||||
|
|
||||||
|
/** |
||||||
|
* 路由名称 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 重定向 |
||||||
|
*/ |
||||||
|
private String redirect; |
||||||
|
|
||||||
|
/** |
||||||
|
* 路由组件 |
||||||
|
*/ |
||||||
|
private String component; |
||||||
|
|
||||||
|
/** |
||||||
|
* 路由源信息 |
||||||
|
*/ |
||||||
|
private Object meta; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
private Date createTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
private Date updateTime; |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object that) { |
||||||
|
if (this == that) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
if (that == null) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
if (getClass() != that.getClass()) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
RouteSys other = (RouteSys) that; |
||||||
|
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) |
||||||
|
&& (this.getParentid() == null ? other.getParentid() == null : this.getParentid().equals(other.getParentid())) |
||||||
|
&& (this.getPath() == null ? other.getPath() == null : this.getPath().equals(other.getPath())) |
||||||
|
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName())) |
||||||
|
&& (this.getRedirect() == null ? other.getRedirect() == null : this.getRedirect().equals(other.getRedirect())) |
||||||
|
&& (this.getComponent() == null ? other.getComponent() == null : this.getComponent().equals(other.getComponent())) |
||||||
|
&& (this.getMeta() == null ? other.getMeta() == null : this.getMeta().equals(other.getMeta())) |
||||||
|
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) |
||||||
|
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
final int prime = 31; |
||||||
|
int result = 1; |
||||||
|
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); |
||||||
|
result = prime * result + ((getParentid() == null) ? 0 : getParentid().hashCode()); |
||||||
|
result = prime * result + ((getPath() == null) ? 0 : getPath().hashCode()); |
||||||
|
result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); |
||||||
|
result = prime * result + ((getRedirect() == null) ? 0 : getRedirect().hashCode()); |
||||||
|
result = prime * result + ((getComponent() == null) ? 0 : getComponent().hashCode()); |
||||||
|
result = prime * result + ((getMeta() == null) ? 0 : getMeta().hashCode()); |
||||||
|
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); |
||||||
|
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
StringBuilder sb = new StringBuilder(); |
||||||
|
sb.append(getClass().getSimpleName()); |
||||||
|
sb.append(" ["); |
||||||
|
sb.append("Hash = ").append(hashCode()); |
||||||
|
sb.append(", id=").append(id); |
||||||
|
sb.append(", parentid=").append(parentid); |
||||||
|
sb.append(", path=").append(path); |
||||||
|
sb.append(", name=").append(name); |
||||||
|
sb.append(", redirect=").append(redirect); |
||||||
|
sb.append(", component=").append(component); |
||||||
|
sb.append(", meta=").append(meta); |
||||||
|
sb.append(", createTime=").append(createTime); |
||||||
|
sb.append(", updateTime=").append(updateTime); |
||||||
|
sb.append("]"); |
||||||
|
return sb.toString(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package com.water.watersys.service; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
import com.water.watersys.model.domain.RouteSys; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author mac |
||||||
|
* @description 针对表【route_sys(路由表)】的数据库操作Service |
||||||
|
* @createDate 2025-04-13 14:43:46 |
||||||
|
*/ |
||||||
|
|
||||||
|
public interface RouteSysService extends IService<RouteSys> { |
||||||
|
|
||||||
|
List<RouteSys> getRoute(Integer loginId); |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.water.watersys.service.impl; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import com.water.watersys.mapper.RouteSysMapper; |
||||||
|
import com.water.watersys.model.domain.RouteSys; |
||||||
|
import com.water.watersys.service.RouteSysService; |
||||||
|
import jakarta.annotation.Resource; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author mac |
||||||
|
* @description 针对表【route_sys(路由表)】的数据库操作Service实现 |
||||||
|
* @createDate 2025-04-13 14:43:46 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class RouteSysServiceImpl extends ServiceImpl<RouteSysMapper, RouteSys> |
||||||
|
implements RouteSysService { |
||||||
|
|
||||||
|
@Resource |
||||||
|
private RouteSysMapper routeSysMapper; |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<RouteSys> getRoute(Integer loginId) { |
||||||
|
return routeSysMapper.getRoute(loginId); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,23 @@ |
|||||||
|
<?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="com.water.watersys.mapper.RouteSysMapper"> |
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.water.watersys.model.domain.RouteSys"> |
||||||
|
<id property="id" column="id" /> |
||||||
|
<result property="parentid" column="parentId" /> |
||||||
|
<result property="path" column="path" /> |
||||||
|
<result property="name" column="name" /> |
||||||
|
<result property="redirect" column="redirect" /> |
||||||
|
<result property="component" column="component" /> |
||||||
|
<result property="meta" column="meta" /> |
||||||
|
<result property="createTime" column="create_time" /> |
||||||
|
<result property="updateTime" column="update_time" /> |
||||||
|
</resultMap> |
||||||
|
|
||||||
|
<sql id="Base_Column_List"> |
||||||
|
id,parentId,path,name,redirect,component, |
||||||
|
meta,create_time,update_time |
||||||
|
</sql> |
||||||
|
</mapper> |
Loading…
Reference in new issue