调整网关逻辑
This commit is contained in:
parent
9c28894d5a
commit
4376a53d8e
7
pom.xml
7
pom.xml
@ -33,7 +33,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -44,11 +44,6 @@
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
|
@ -2,8 +2,6 @@ package ink.wgink.gateway.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -15,7 +13,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @Date: 2021/2/5 6:44 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class BeanConfig {
|
||||
|
||||
/**
|
||||
@ -23,7 +20,6 @@ public class BeanConfig {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ObjectMapper objectMapper() {
|
||||
return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
package ink.wgink.gateway.controller.api.route;
|
||||
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.pojo.ListPage;
|
||||
import ink.wgink.gateway.pojo.dtos.route.RouteDTO;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResult;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResultList;
|
||||
import ink.wgink.gateway.pojo.vos.route.RouteVO;
|
||||
import ink.wgink.gateway.service.route.IRouteService;
|
||||
import ink.wgink.gateway.util.ReflectUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteController
|
||||
* @Description: 路由
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 6:41 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController("sys/route")
|
||||
public class RouteController {
|
||||
|
||||
@Autowired
|
||||
private IRouteService routeService;
|
||||
|
||||
@PostMapping("save")
|
||||
public SuccessResult save(@RequestBody RouteVO routeVO) throws ReflectUtil.ReflectException {
|
||||
routeService.save(routeVO);
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public SuccessResultList<List<RouteDTO>> listPage(ListPage page) {
|
||||
return routeService.listPage(page);
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package ink.wgink.gateway.dao;
|
||||
|
||||
import ink.wgink.gateway.pojo.BasePOJO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IBaseDao
|
||||
* @Description:
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 6:29 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IBaseDao<PO extends BasePOJO, DTO extends BasePOJO> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param po
|
||||
*/
|
||||
void save(PO po);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void remote(List<String> ids);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param id
|
||||
* @param po
|
||||
*/
|
||||
void update(String id, PO po);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
<DTO> DTO get(String id);
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param page
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
<DTO> List<DTO> list(int page, int size);
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Long count();
|
||||
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
package ink.wgink.gateway.dao.route;
|
||||
|
||||
import ink.wgink.gateway.dao.IBaseDao;
|
||||
import ink.wgink.gateway.pojo.dtos.route.RouteDTO;
|
||||
import ink.wgink.gateway.pojo.pos.route.RoutePO;
|
||||
import ink.wgink.gateway.pojo.route.Route;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -14,8 +16,12 @@ import ink.wgink.gateway.pojo.pos.route.RoutePO;
|
||||
* @Date: 2021/4/13 5:28 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IRouteDao extends IBaseDao<RoutePO, RouteDTO> {
|
||||
@Repository
|
||||
public interface IRouteDao extends ReactiveMongoRepository<Route, String> {
|
||||
|
||||
String COLLECTION_NAME = "sys_route";
|
||||
|
||||
@Query("db."+ COLLECTION_NAME+ ".find")
|
||||
Mono<Route> list(String uuid);
|
||||
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
package ink.wgink.gateway.dao.route.impl;
|
||||
|
||||
import ink.wgink.gateway.consts.ISystemConst;
|
||||
import ink.wgink.gateway.dao.BaseDao;
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.pojo.dtos.route.RouteDTO;
|
||||
import ink.wgink.gateway.pojo.pos.route.RoutePO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.aggregation.Aggregation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationOperation;
|
||||
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteDaoImpl
|
||||
* @Description: 路由
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 5:32 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class RouteDaoImpl extends BaseDao implements IRouteDao {
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Override
|
||||
public void save(RoutePO routePO) {
|
||||
setSave(routePO);
|
||||
mongoTemplate.save(routePO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remote(List<String> ids) {
|
||||
if (ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Criteria queryCriteria = Criteria.where(ISystemConst.UUID);
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
if (i > 0) {
|
||||
queryCriteria.and(ISystemConst.UUID);
|
||||
}
|
||||
queryCriteria.is(ids.get(i));
|
||||
}
|
||||
|
||||
mongoTemplate.remove(new Query(queryCriteria), RoutePO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String uuid, RoutePO routePO) {
|
||||
Update update = new Update();
|
||||
update.set("system", routePO.getSystem());
|
||||
update.set("summary", routePO.getSummary());
|
||||
update.set("path", routePO.getPath());
|
||||
update.set("uri", routePO.getUri());
|
||||
setUpdate(update);
|
||||
mongoTemplate.updateMulti(new Query(Criteria.where(ISystemConst.UUID).is(uuid)), update, RoutePO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RouteDTO get(String uuid) {
|
||||
return mongoTemplate.findOne(new Query(Criteria.where(ISystemConst.UUID).is(uuid)), RouteDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteDTO> list(int page, int size) {
|
||||
Query query = new Query();
|
||||
query.limit(getLimit(size));
|
||||
query.skip(getSkip(page, size));
|
||||
return mongoTemplate.find(query, RouteDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
List<AggregationOperation> operations = new ArrayList<>();
|
||||
operations.add(Aggregation.group(ISystemConst.UUID).count().as(ISystemConst.COUNT));
|
||||
Aggregation aggregation = Aggregation.newAggregation(operations);
|
||||
AggregationResults<Map> results = mongoTemplate.aggregate(aggregation, COLLECTION_NAME, Map.class);
|
||||
return Long.parseLong(results.getMappedResults().get(0).get(ISystemConst.COUNT).toString());
|
||||
}
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
package ink.wgink.gateway.filter.global;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -1,21 +1,20 @@
|
||||
package ink.wgink.gateway.dao;
|
||||
package ink.wgink.gateway.handler;
|
||||
|
||||
import ink.wgink.gateway.pojo.BasePOJO;
|
||||
import ink.wgink.gateway.util.DateUtil;
|
||||
import ink.wgink.gateway.util.UUIDUtil;
|
||||
import org.springframework.data.mongodb.core.query.Update;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: BaseDao
|
||||
* @Description: dao接口
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 5:56 下午
|
||||
* @ClassName: BaseHandler
|
||||
* @Description:
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/4/19 21:57
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class BaseDao {
|
||||
**/
|
||||
public class BaseHandler {
|
||||
|
||||
public static final String CREATOR = "creator";
|
||||
public static final String MODIFIER = "modifier";
|
||||
@ -31,9 +30,9 @@ public class BaseDao {
|
||||
base.setGmtModified(datetime);
|
||||
}
|
||||
|
||||
protected void setUpdate(Update update) {
|
||||
update.set(GMT_MODIFIED, DateUtil.getTime());
|
||||
update.set(MODIFIER, "1");
|
||||
protected void setUpdate(BasePOJO base) {
|
||||
base.setGmtCreate(DateUtil.getTime());
|
||||
base.setModifier("1");
|
||||
}
|
||||
|
||||
protected int getLimit(int size) {
|
@ -0,0 +1,97 @@
|
||||
package ink.wgink.gateway.handler.route;
|
||||
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.handler.BaseHandler;
|
||||
import ink.wgink.gateway.pojo.route.Route;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteHandler
|
||||
* @Description: 路由
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/4/19 21:40
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
public class RouteHandler extends BaseHandler {
|
||||
|
||||
private IRouteDao routeDao;
|
||||
|
||||
public RouteHandler(IRouteDao routeDao) {
|
||||
this.routeDao = routeDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> save(ServerRequest serverRequest) {
|
||||
Mono<Route> routeMono = serverRequest.bodyToMono(Route.class);
|
||||
return routeMono.flatMap(route -> {
|
||||
setSave(route);
|
||||
return routeDao.save(route);
|
||||
}).then(ServerResponse.ok().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> delete(ServerRequest serverRequest) {
|
||||
String ids = serverRequest.pathVariable("ids");
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
return Mono.from(routeDao.findAllById(idList).flatMap(route -> routeDao.delete(route))).then(ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).build()).switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> update(ServerRequest serverRequest) {
|
||||
String id = serverRequest.pathVariable("id");
|
||||
Mono<Route> routeMono = serverRequest.bodyToMono(Route.class);
|
||||
return routeDao.findById(id).then(routeMono.flatMap(route -> {
|
||||
route.setUuid(id);
|
||||
setUpdate(route);
|
||||
return routeDao.save(route);
|
||||
})).then(ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).build()).switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> list(ServerRequest serverRequest) {
|
||||
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(routeDao.findAll(), Route.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param serverRequest
|
||||
* @return
|
||||
*/
|
||||
public Mono<ServerResponse> get(ServerRequest serverRequest) {
|
||||
String id = serverRequest.pathVariable("id");
|
||||
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(routeDao.findById(id), Route.class).switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package ink.wgink.gateway.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -16,7 +16,7 @@ import org.springframework.data.mongodb.core.index.Indexed;
|
||||
@Data
|
||||
public class BasePOJO {
|
||||
|
||||
@Indexed
|
||||
@Id
|
||||
private String uuid;
|
||||
private String gmtCreate;
|
||||
private String creator;
|
||||
|
@ -1,36 +0,0 @@
|
||||
package ink.wgink.gateway.pojo.pos.route;
|
||||
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.pojo.BasePOJO;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RoutePO
|
||||
* @Description: 路由
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 5:20 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@Document(collection = IRouteDao.COLLECTION_NAME)
|
||||
public class RoutePO extends BasePOJO implements Serializable {
|
||||
private static final long serialVersionUID = 3471850588453134724L;
|
||||
|
||||
@Indexed
|
||||
private String system;
|
||||
private String summary;
|
||||
@Indexed
|
||||
private String path;
|
||||
@Indexed
|
||||
private String uri;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ink.wgink.gateway.pojo.dtos.route;
|
||||
package ink.wgink.gateway.pojo.route;
|
||||
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.pojo.BasePOJO;
|
||||
@ -21,7 +21,7 @@ import java.io.Serializable;
|
||||
@Data
|
||||
@ToString
|
||||
@Document(collection = IRouteDao.COLLECTION_NAME)
|
||||
public class RouteDTO extends BasePOJO implements Serializable {
|
||||
public class Route extends BasePOJO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4892456861969101733L;
|
||||
private String system;
|
@ -1,25 +0,0 @@
|
||||
package ink.wgink.gateway.pojo.vos.route;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteVO
|
||||
* @Description: 路由
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 6:45 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
public class RouteVO {
|
||||
|
||||
private String system;
|
||||
private String summary;
|
||||
private String path;
|
||||
private String uri;
|
||||
|
||||
}
|
40
src/main/java/ink/wgink/gateway/router/AllRoutes.java
Normal file
40
src/main/java/ink/wgink/gateway/router/AllRoutes.java
Normal file
@ -0,0 +1,40 @@
|
||||
package ink.wgink.gateway.router;
|
||||
|
||||
import ink.wgink.gateway.handler.route.RouteHandler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.*;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: AllRoutes
|
||||
* @Description: 总路由
|
||||
* @Author: WangGeng
|
||||
* @Date: 2021/4/19 22:57
|
||||
* @Version: 1.0
|
||||
**/
|
||||
@Component
|
||||
public class AllRoutes {
|
||||
|
||||
/**
|
||||
* 路由管理
|
||||
*
|
||||
* @param routeHandler
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> routeRouter(RouteHandler routeHandler) {
|
||||
// 嵌套
|
||||
return RouterFunctions.nest(RequestPredicates.path("/route"),
|
||||
RouterFunctions
|
||||
.route(RequestPredicates.POST("/save"), routeHandler::save)
|
||||
.andRoute(RequestPredicates.DELETE("/delete/{ids}"), routeHandler::delete)
|
||||
.andRoute(RequestPredicates.PUT("/update/{id}"), routeHandler::update)
|
||||
.andRoute(RequestPredicates.GET("/list"), routeHandler::list)
|
||||
.andRoute(RequestPredicates.GET("get/{id}"), routeHandler::get)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package ink.wgink.gateway.service;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: BaseService
|
||||
* @Description:
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 6:42 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class BaseService {
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package ink.wgink.gateway.service.route;
|
||||
|
||||
import ink.wgink.gateway.pojo.ListPage;
|
||||
import ink.wgink.gateway.pojo.dtos.route.RouteDTO;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResultList;
|
||||
import ink.wgink.gateway.pojo.vos.route.RouteVO;
|
||||
import ink.wgink.gateway.util.ReflectUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: IRouteService
|
||||
* @Description: 路由
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 6:42 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IRouteService {
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
* @param routeVO
|
||||
* @throws ReflectUtil.ReflectException
|
||||
*/
|
||||
void save(RouteVO routeVO) throws ReflectUtil.ReflectException;
|
||||
|
||||
/**
|
||||
* 分页列表
|
||||
*
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<RouteDTO>> listPage(ListPage page);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package ink.wgink.gateway.service.route.impl;
|
||||
|
||||
import ink.wgink.gateway.dao.route.IRouteDao;
|
||||
import ink.wgink.gateway.pojo.ListPage;
|
||||
import ink.wgink.gateway.pojo.dtos.route.RouteDTO;
|
||||
import ink.wgink.gateway.pojo.pos.route.RoutePO;
|
||||
import ink.wgink.gateway.pojo.result.SuccessResultList;
|
||||
import ink.wgink.gateway.pojo.vos.route.RouteVO;
|
||||
import ink.wgink.gateway.service.BaseService;
|
||||
import ink.wgink.gateway.service.route.IRouteService;
|
||||
import ink.wgink.gateway.util.ReflectUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
* 当你想要放弃的时候,想想当初你为何开始
|
||||
*
|
||||
* @ClassName: RouteServiceImpl
|
||||
* @Description: 路由
|
||||
* @Author: wanggeng
|
||||
* @Date: 2021/4/13 6:42 下午
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class RouteServiceImpl extends BaseService implements IRouteService {
|
||||
|
||||
@Autowired
|
||||
private IRouteDao routeDao;
|
||||
|
||||
@Override
|
||||
public void save(RouteVO routeVO) throws ReflectUtil.ReflectException {
|
||||
routeDao.save(ReflectUtil.beanToBean(routeVO, RoutePO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<RouteDTO>> listPage(ListPage page) {
|
||||
List<RouteDTO> routeDTOs = routeDao.list(page.getPage(), page.getSize());
|
||||
Long count = routeDao.count();
|
||||
return new SuccessResultList<>(routeDTOs, page.getPage(), count);
|
||||
}
|
||||
}
|
@ -1,13 +1,10 @@
|
||||
package ink.wgink.gateway.util;
|
||||
|
||||
import ink.wgink.gateway.pojo.pos.route.RoutePO;
|
||||
import ink.wgink.gateway.pojo.vos.route.RouteVO;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
|
Loading…
Reference in New Issue
Block a user