mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-11-01 10:41:52 +08:00
.
This commit is contained in:
+15
-52
@@ -16,12 +16,11 @@
|
||||
|
||||
package com.pnoker.api.center.auth.feign;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.api.center.auth.hystrix.AuthFeignApiHystrix;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.dto.transfer.RtmpDto;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import com.pnoker.common.base.dto.auth.TokenDto;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -34,70 +33,34 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
* @author : pnoker
|
||||
* @email : pnokers@icloud.com
|
||||
*/
|
||||
@FeignClient(path = "/api/v3/center/auth", name = Common.Service.DC3_AUTH, fallbackFactory = AuthFeignApiHystrix.class)
|
||||
@FeignClient(path = Common.Service.DC3_AUTH_URL_PREFIX, name = Common.Service.DC3_AUTH, fallbackFactory = AuthFeignApiHystrix.class)
|
||||
public interface AuthFeignClient {
|
||||
|
||||
/**
|
||||
* 新增 新增 Rtmp 任务记录
|
||||
* 检测用户名是否存在
|
||||
*
|
||||
* @param rtmp
|
||||
* @param username
|
||||
* @return true/false
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
Response<Long> add(@RequestBody Rtmp rtmp);
|
||||
@GetMapping("/check/exist/{username}")
|
||||
Response<Boolean> checkExist(@PathVariable(value = "username") String username);
|
||||
|
||||
/**
|
||||
* 删除 根据 ID 删除 Rtmp
|
||||
* 检测用Token是否有效
|
||||
*
|
||||
* @param id rtmpId
|
||||
* @param token
|
||||
* @return true/false
|
||||
*/
|
||||
@PostMapping("/delete/{id}")
|
||||
Response<Boolean> delete(@PathVariable(value = "id") Long id);
|
||||
@GetMapping("/check/token/{token}")
|
||||
Response<Boolean> checkToken(@PathVariable(value = "token") String token);
|
||||
|
||||
/**
|
||||
* 修改 修改 Rtmp 任务记录
|
||||
* 获取Token
|
||||
*
|
||||
* @param rtmp
|
||||
* @param user
|
||||
* @return true/false
|
||||
*/
|
||||
@PostMapping("/update")
|
||||
Response<Boolean> update(@RequestBody Rtmp rtmp);
|
||||
|
||||
/**
|
||||
* 查询 根据ID查询 Rtmp
|
||||
*
|
||||
* @param id
|
||||
* @return rtmp
|
||||
*/
|
||||
@GetMapping("/id/{id}")
|
||||
Response<Rtmp> selectById(@PathVariable(value = "id") Long id);
|
||||
|
||||
/**
|
||||
* 分页查询 Rtmp
|
||||
*
|
||||
* @param rtmpDto
|
||||
* @return rtmpList
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
Response<Page<Rtmp>> list(@RequestBody(required = false) RtmpDto rtmpDto);
|
||||
|
||||
/**
|
||||
* 启动 Rtmp 转码任务
|
||||
*
|
||||
* @param id
|
||||
* @return true/false
|
||||
*/
|
||||
@PostMapping("/start/{id}")
|
||||
Response<Boolean> start(@PathVariable(value = "id") Long id);
|
||||
|
||||
/**
|
||||
* 停止 Rtmp 转码任务
|
||||
*
|
||||
* @param id
|
||||
* @return true/false
|
||||
*/
|
||||
@PostMapping("/stop/{id}")
|
||||
Response<Boolean> stop(@PathVariable(value = "id") Long id);
|
||||
@PostMapping("/token")
|
||||
Response<TokenDto> token(@RequestBody User user);
|
||||
|
||||
}
|
||||
|
||||
+8
-28
@@ -16,11 +16,10 @@
|
||||
|
||||
package com.pnoker.api.center.auth.hystrix;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.api.center.auth.feign.AuthFeignClient;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.transfer.RtmpDto;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import com.pnoker.common.base.dto.auth.TokenDto;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -37,42 +36,23 @@ public class AuthFeignApiHystrix implements FallbackFactory<AuthFeignClient> {
|
||||
|
||||
@Override
|
||||
public AuthFeignClient create(Throwable throwable) {
|
||||
String message = throwable.getMessage() == null ? "No available server for client: DC3-RTMP" : throwable.getMessage();
|
||||
log.error("RtmpTransferFeignApi:{},hystrix服务降级处理", message, throwable);
|
||||
String message = throwable.getMessage() == null ? "No available server for client: DC3-AUTH" : throwable.getMessage();
|
||||
log.error("AuthTransferFeignApi:{},hystrix服务降级处理", message, throwable);
|
||||
|
||||
return new AuthFeignClient() {
|
||||
|
||||
@Override
|
||||
public Response<Long> add(Rtmp rtmp) {
|
||||
public Response<Boolean> checkExist(String username) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Boolean> delete(Long id) {
|
||||
public Response<Boolean> checkToken(String token) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Boolean> update(Rtmp rtmp) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Rtmp> selectById(Long id) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Page<Rtmp>> list(RtmpDto rtmpDto) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Boolean> start(Long id) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response<Boolean> stop(Long id) {
|
||||
public Response<TokenDto> token(User user) {
|
||||
return Response.fail(message);
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -34,14 +34,14 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
* @author : pnoker
|
||||
* @email : pnokers@icloud.com
|
||||
*/
|
||||
@FeignClient(path = "/api/v3/center/dbs/rtmp", name = Common.Service.DC3_DBS, fallbackFactory = RtmpDbsFeignHystrix.class)
|
||||
@FeignClient(path = Common.Service.DC3_DBS_RTMP_URL_PREFIX, name = Common.Service.DC3_DBS, fallbackFactory = RtmpDbsFeignHystrix.class)
|
||||
public interface RtmpDbsFeignClient {
|
||||
|
||||
/**
|
||||
* 新增 新增 Rtmp 任务记录
|
||||
*
|
||||
* @param rtmp
|
||||
* @return true/false
|
||||
* @return rtmpId
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
Response<Long> add(@RequestBody Rtmp rtmp);
|
||||
|
||||
+4
-4
@@ -19,8 +19,8 @@ package com.pnoker.dbs.api.user.feign;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.dto.UserDto;
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.dto.auth.UserDto;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import com.pnoker.dbs.api.user.hystrix.UserDbsFeignHystrix;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -34,14 +34,14 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
* @author : pnoker
|
||||
* @email : pnokers@icloud.com
|
||||
*/
|
||||
@FeignClient(path = "/api/v3/center/dbs/user", name = Common.Service.DC3_DBS, fallbackFactory = UserDbsFeignHystrix.class)
|
||||
@FeignClient(path = Common.Service.DC3_DBS_USER_URL_PREFIX, name = Common.Service.DC3_DBS, fallbackFactory = UserDbsFeignHystrix.class)
|
||||
public interface UserDbsFeignClient {
|
||||
|
||||
/**
|
||||
* 新增 新增 User 记录
|
||||
*
|
||||
* @param user
|
||||
* @return true/false
|
||||
* @return userId
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
Response<Long> add(@RequestBody User user);
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ package com.pnoker.dbs.api.user.hystrix;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.UserDto;
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.dto.auth.UserDto;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import com.pnoker.dbs.api.user.feign.UserDbsFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
* @author : pnoker
|
||||
* @email : pnokers@icloud.com
|
||||
*/
|
||||
@FeignClient(path = "/api/v3/transfer/rtmp", name = Common.Service.DC3_RTMP, fallbackFactory = RtmpTransferFeignApiHystrix.class)
|
||||
@FeignClient(path = Common.Service.DC3_RTMP_URL_PREFIX, name = Common.Service.DC3_RTMP, fallbackFactory = RtmpTransferFeignApiHystrix.class)
|
||||
public interface RtmpTransferFeignClient {
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,8 @@ package com.pnoker.center.dbs.api;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.center.dbs.service.RtmpService;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.dto.transfer.RtmpDto;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import com.pnoker.dbs.api.rtmp.feign.RtmpDbsFeignClient;
|
||||
@@ -39,7 +40,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/v3/center/dbs/rtmp")
|
||||
@RequestMapping(Common.Service.DC3_DBS_RTMP_URL_PREFIX)
|
||||
public class RtmpDbsApi implements RtmpDbsFeignClient {
|
||||
@Resource
|
||||
private RtmpService rtmpService;
|
||||
|
||||
@@ -19,9 +19,10 @@ package com.pnoker.center.dbs.api;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.center.dbs.service.UserService;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.dto.UserDto;
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.dto.auth.UserDto;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import com.pnoker.dbs.api.user.feign.UserDbsFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -40,7 +41,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/v3/center/dbs/user")
|
||||
@RequestMapping(Common.Service.DC3_DBS_USER_URL_PREFIX)
|
||||
public class UserDbsApi implements UserDbsFeignClient {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.pnoker.center.dbs.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.pnoker.center.dbs.service;
|
||||
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import com.pnoker.common.base.service.BaseService;
|
||||
|
||||
/**
|
||||
|
||||
+9
-9
@@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.center.dbs.mapper.RtmpMapper;
|
||||
import com.pnoker.center.dbs.service.RtmpService;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.BooleanUtils;
|
||||
@@ -54,8 +54,8 @@ public class RtmpServiceImpl implements RtmpService {
|
||||
|
||||
@Override
|
||||
@Caching(
|
||||
put = {@CachePut(value = "rtmpCache", key = "#rtmp.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "rtmpListCache", allEntries = true)}
|
||||
put = {@CachePut(value = "dbs_rtmp", key = "#rtmp.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "dbs_rtmp_list", allEntries = true)}
|
||||
)
|
||||
public Rtmp add(Rtmp rtmp) {
|
||||
return rtmpMapper.insert(rtmp) > 0 ? rtmp : null;
|
||||
@@ -64,8 +64,8 @@ public class RtmpServiceImpl implements RtmpService {
|
||||
@Override
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(value = "rtmpCache", key = "#id"),
|
||||
@CacheEvict(value = "rtmpListCache", allEntries = true)
|
||||
@CacheEvict(value = "dbs_rtmp", key = "#id"),
|
||||
@CacheEvict(value = "dbs_rtmp_list", allEntries = true)
|
||||
}
|
||||
)
|
||||
public boolean delete(Long id) {
|
||||
@@ -74,21 +74,21 @@ public class RtmpServiceImpl implements RtmpService {
|
||||
|
||||
@Override
|
||||
@Caching(
|
||||
put = {@CachePut(value = "rtmpCache", key = "#rtmp.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "rtmpListCache", allEntries = true)}
|
||||
put = {@CachePut(value = "dbs_rtmp", key = "#rtmp.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "dbs_rtmp_list", allEntries = true)}
|
||||
)
|
||||
public Rtmp update(Rtmp rtmp) {
|
||||
return rtmpMapper.updateById(rtmp) > 0 ? rtmp : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "rtmpCache", key = "#id", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_rtmp", key = "#id", unless = "#result==null")
|
||||
public Rtmp selectById(Long id) {
|
||||
return rtmpMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "rtmpListCache", keyGenerator = "commonKeyGenerator", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_rtmp_list", keyGenerator = "commonKeyGenerator", unless = "#result==null")
|
||||
public Page<Rtmp> list(Rtmp rtmp, PageInfo pageInfo) {
|
||||
return rtmpMapper.selectPage(pagination(pageInfo), fuzzyQuery(rtmp));
|
||||
}
|
||||
|
||||
+13
-13
@@ -22,8 +22,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.center.dbs.mapper.UserMapper;
|
||||
import com.pnoker.center.dbs.service.UserService;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -51,8 +51,8 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
@Caching(
|
||||
put = {@CachePut(value = "userCache", key = "#user.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "userListCache", allEntries = true)}
|
||||
put = {@CachePut(value = "dbs_user", key = "#user.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "dbs_user_list", allEntries = true)}
|
||||
)
|
||||
public User add(User user) {
|
||||
return userMapper.insert(user) > 0 ? user : null;
|
||||
@@ -61,8 +61,8 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(value = "userCache", key = "#id"),
|
||||
@CacheEvict(value = "userListCache", allEntries = true)
|
||||
@CacheEvict(value = "dbs_user", key = "#id"),
|
||||
@CacheEvict(value = "dbs_user_list", allEntries = true)
|
||||
}
|
||||
)
|
||||
public boolean delete(Long id) {
|
||||
@@ -71,21 +71,21 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
@Override
|
||||
@Caching(
|
||||
put = {@CachePut(value = "userCache", key = "#user.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "userListCache", allEntries = true)}
|
||||
put = {@CachePut(value = "dbs_user", key = "#user.id", unless = "#result==null")},
|
||||
evict = {@CacheEvict(value = "dbs_user_list", allEntries = true)}
|
||||
)
|
||||
public User update(User user) {
|
||||
return userMapper.updateById(user) > 0 ? user : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "userCache", key = "#id", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_user", key = "#id", unless = "#result==null")
|
||||
public User selectById(Long id) {
|
||||
return userMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "userListCache", keyGenerator = "commonKeyGenerator", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_user_list", keyGenerator = "commonKeyGenerator", unless = "#result==null")
|
||||
public Page<User> list(User user, PageInfo pageInfo) {
|
||||
return userMapper.selectPage(pagination(pageInfo), fuzzyQuery(user));
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "userCache", key = "#usernama", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_user", key = "#usernama", unless = "#result==null")
|
||||
public User selectByUsername(String usernama) {
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(Common.Cloumn.User.USERNAME, usernama);
|
||||
@@ -134,7 +134,7 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "userCache", key = "#phone", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_user", key = "#phone", unless = "#result==null")
|
||||
public User selectByPhone(String phone) {
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(Common.Cloumn.User.PHONE, phone);
|
||||
@@ -142,7 +142,7 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "userCache", key = "#email", unless = "#result==null")
|
||||
@Cacheable(value = "dbs_user", key = "#email", unless = "#result==null")
|
||||
public User selectByEmail(String email) {
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(Common.Cloumn.User.EMAIL, email);
|
||||
|
||||
@@ -10,10 +10,6 @@ spring:
|
||||
name: @project.artifactId@
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
cloud:
|
||||
loadbalancer:
|
||||
ribbon:
|
||||
enabled: false
|
||||
security:
|
||||
user:
|
||||
name: iotdc3
|
||||
@@ -41,7 +37,7 @@ spring:
|
||||
host: iotdc3.redis
|
||||
port: 6379
|
||||
password: ${spring.security.user.password}
|
||||
database: 0
|
||||
database: 2
|
||||
timeout: 15S
|
||||
jedis:
|
||||
pool:
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<module>dc3-register</module>
|
||||
<module>dc3-monitor</module>
|
||||
<module>dc3-dbs</module>
|
||||
<module>dc3-auth</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pnoker.common.base.dto;
|
||||
package com.pnoker.common.base.bean;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -49,12 +49,18 @@ public interface Common {
|
||||
String TIMEZONE = "GMT+8";
|
||||
|
||||
/**
|
||||
* 服务名称
|
||||
* 服务名称 & 服务基地址
|
||||
*/
|
||||
interface Service {
|
||||
String DC3_DBS = "DC3-DBS";
|
||||
String DC3_DBS_RTMP_URL_PREFIX = "/api/v3/center/dbs/rtmp";
|
||||
String DC3_DBS_USER_URL_PREFIX = "/api/v3/center/dbs/user";
|
||||
|
||||
String DC3_RTMP = "DC3-RTMP";
|
||||
String DC3_RTMP_URL_PREFIX = "/api/v3/transfer/rtmp";
|
||||
|
||||
String DC3_AUTH = "DC3-AUTH";
|
||||
String DC3_AUTH_URL_PREFIX = "/api/v3/center/auth";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2019 Pnoker. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pnoker.common.base.dto.auth;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>Token Dto
|
||||
*
|
||||
* @author : pnoker
|
||||
* @email : pnokers@icloud.com
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TokenDto implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Token令牌
|
||||
* <br>
|
||||
* 第一版:使用 用户名(username) + 公钥(publicKey) + 过期时间(expireTime,毫秒) 的字符串通过'私钥对称加密'生成 Token
|
||||
* <br>
|
||||
* 第二版:使用 用户名(username) + 公钥(publicKey) + 过期时间(expireTime,毫秒) 的字符串通过'私钥非对称密'生成 Token
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 公钥
|
||||
*/
|
||||
private String key;
|
||||
}
|
||||
+3
-2
@@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pnoker.common.base.dto;
|
||||
package com.pnoker.common.base.dto.auth;
|
||||
|
||||
import com.pnoker.common.base.entity.User;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.entity.auth.User;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.pnoker.common.base.dto.device;
|
||||
|
||||
import com.pnoker.common.base.entity.device.Device;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.pnoker.common.base.dto.transfer;
|
||||
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
+2
-1
@@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pnoker.common.base.entity;
|
||||
package com.pnoker.common.base.entity.auth;
|
||||
|
||||
import com.pnoker.common.base.entity.Description;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
+3
-2
@@ -5,7 +5,7 @@
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -14,8 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.pnoker.common.base.entity;
|
||||
package com.pnoker.common.base.entity.auth;
|
||||
|
||||
import com.pnoker.common.base.entity.Description;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ package com.pnoker.common.base.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
|
||||
/**
|
||||
* <p>基础 服务类接口
|
||||
|
||||
@@ -71,6 +71,34 @@ public class Dc3Tools {
|
||||
return Base64.getDecoder().decode(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* @return 0:无效用户名,1:用户名,2:手机号,3:邮箱
|
||||
*/
|
||||
public static int usernameType(String username) {
|
||||
if (isUsername(username)) {
|
||||
return 1;
|
||||
}
|
||||
if (isPhone(username)) {
|
||||
return 2;
|
||||
}
|
||||
if (isMail(username)) {
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 用户名格式(3-16)
|
||||
*
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
public static boolean isUsername(String username) {
|
||||
String regex = "^[a-zA-Z]\\w{2,15}$";
|
||||
return ReUtil.isMatch(regex, username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 手机号码格式
|
||||
*
|
||||
@@ -78,7 +106,7 @@ public class Dc3Tools {
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPhone(String phone) {
|
||||
String regex = "^[1][3-9]+\\d{9}$";
|
||||
String regex = "^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$";
|
||||
return ReUtil.isMatch(regex, phone);
|
||||
}
|
||||
|
||||
@@ -93,6 +121,58 @@ public class Dc3Tools {
|
||||
return ReUtil.isMatch(regex, mail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断密码级别
|
||||
*
|
||||
* @param password
|
||||
* @return 0:无效密码,1:弱密码,2:普通密码,3:强密码
|
||||
*/
|
||||
public static int passwordType(String password) {
|
||||
if (isStrongPassword(password)) {
|
||||
return 3;
|
||||
}
|
||||
if (isPassword(password)) {
|
||||
return 2;
|
||||
}
|
||||
if (isWeakPassword(password)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 弱密码格式(8-16)
|
||||
*
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static boolean isWeakPassword(String password) {
|
||||
String regex = "^[a-zA-Z]\\w{7,15}$";
|
||||
return ReUtil.isMatch(regex, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 密码格式(8-16)
|
||||
*
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPassword(String password) {
|
||||
String regex = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$";
|
||||
return ReUtil.isMatch(regex, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为 强密码格式(8-16)
|
||||
*
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public static boolean isStrongPassword(String password) {
|
||||
String regex = "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,16}$";
|
||||
return ReUtil.isMatch(regex, password);
|
||||
}
|
||||
|
||||
/**
|
||||
* 两层循环实现建树
|
||||
*
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.pnoker.common.config.RedisTemplateConfig,\
|
||||
com.pnoker.common.tool.RedisTools
|
||||
com.pnoker.common.config.RedisTemplateConfig
|
||||
|
||||
+3
-2
@@ -19,7 +19,8 @@ package com.pnoker.transfer.rtmp.api;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.api.transfer.rtmp.feign.RtmpTransferFeignClient;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.constant.Common;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.dto.transfer.RtmpDto;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import com.pnoker.transfer.rtmp.service.RtmpService;
|
||||
@@ -39,7 +40,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/v3/transfer/rtmp")
|
||||
@RequestMapping(Common.Service.DC3_RTMP_URL_PREFIX)
|
||||
public class RtmpTransferApi implements RtmpTransferFeignClient {
|
||||
@Resource
|
||||
private RtmpService rtmpService;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.pnoker.transfer.rtmp.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.pnoker.transfer.rtmp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pnoker.common.base.bean.Response;
|
||||
import com.pnoker.common.base.dto.PageInfo;
|
||||
import com.pnoker.common.base.bean.PageInfo;
|
||||
import com.pnoker.common.base.dto.transfer.RtmpDto;
|
||||
import com.pnoker.common.base.entity.rtmp.Rtmp;
|
||||
import com.pnoker.dbs.api.rtmp.feign.RtmpDbsFeignClient;
|
||||
|
||||
@@ -200,6 +200,12 @@
|
||||
</dependency>
|
||||
|
||||
<!-- dc3 Api -->
|
||||
<dependency>
|
||||
<groupId>com.pnoker</groupId>
|
||||
<artifactId>dc3-api-auth</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pnoker</groupId>
|
||||
<artifactId>dc3-api-dbs</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user