
372 changed files with 29395 additions and 33170 deletions
@ -0,0 +1,95 @@ |
|||
package com.genersoft.iot.vmp.common; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
public class MyPageInfo<T> { |
|||
//当前页
|
|||
private int pageNo; |
|||
//每页的数量
|
|||
private int pageSize; |
|||
//当前页的数量
|
|||
private int size; |
|||
//总页数
|
|||
private int pages; |
|||
//总数
|
|||
private int total; |
|||
|
|||
private List<T> resultData; |
|||
|
|||
private List<T> list; |
|||
|
|||
public MyPageInfo(List<T> resultData) { |
|||
this.resultData = resultData; |
|||
} |
|||
|
|||
public void startPage(int page, int count) { |
|||
if (page <= 0) page = 1; |
|||
this.pageNo = page; |
|||
this.pageSize = count; |
|||
this.total = resultData.size(); |
|||
|
|||
this.pages = total%count == 0 ? total/count : total/count + 1; |
|||
int fromIndx = (page - 1) * count; |
|||
if ( fromIndx > this.total - 1) { |
|||
this.list = new ArrayList<>(); |
|||
this.size = 0; |
|||
return; |
|||
} |
|||
|
|||
int toIndx = page * count; |
|||
if (toIndx > this.total) { |
|||
toIndx = this.total; |
|||
} |
|||
this.list = this.resultData.subList(fromIndx, toIndx); |
|||
this.size = this.list.size(); |
|||
} |
|||
|
|||
public int getPageNo() { |
|||
return pageNo; |
|||
} |
|||
|
|||
public void setPageNo(int pageNo) { |
|||
this.pageNo = pageNo; |
|||
} |
|||
|
|||
public int getPageSize() { |
|||
return pageSize; |
|||
} |
|||
|
|||
public void setPageSize(int pageSize) { |
|||
this.pageSize = pageSize; |
|||
} |
|||
|
|||
public int getSize() { |
|||
return size; |
|||
} |
|||
|
|||
public void setSize(int size) { |
|||
this.size = size; |
|||
} |
|||
|
|||
public int getPages() { |
|||
return pages; |
|||
} |
|||
|
|||
public void setPages(int pages) { |
|||
this.pages = pages; |
|||
} |
|||
|
|||
public int getTotal() { |
|||
return total; |
|||
} |
|||
|
|||
public void setTotal(int total) { |
|||
this.total = total; |
|||
} |
|||
|
|||
public List<T> getList() { |
|||
return list; |
|||
} |
|||
|
|||
public void setList(List<T> list) { |
|||
this.list = list; |
|||
} |
|||
} |
@ -0,0 +1,95 @@ |
|||
package com.genersoft.iot.vmp.common; |
|||
|
|||
import com.github.pagehelper.PageInfo; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class Page<T> { |
|||
|
|||
private Integer pageSize; |
|||
|
|||
private Integer pageNo; |
|||
|
|||
private Integer totalPage; |
|||
|
|||
private Long totalCount; |
|||
|
|||
private List<T> data; |
|||
|
|||
public Page() { |
|||
} |
|||
|
|||
public Page(Integer pageSize, Integer pageNo, Integer totalPage, Long totalCount, List<T> data) { |
|||
this.pageSize = pageSize; |
|||
this.pageNo = pageNo; |
|||
this.totalPage = totalPage; |
|||
this.totalCount = totalCount; |
|||
this.data = data; |
|||
} |
|||
|
|||
public Page(PageInfo<T> pageInfo) { |
|||
Integer pageNo = pageInfo.getPageNum(); |
|||
Integer pageSize = pageInfo.getPageSize(); |
|||
Integer totalPage = pageInfo.getPages(); |
|||
Long totalCount = pageInfo.getTotal(); |
|||
List<T> data = pageInfo.getList(); |
|||
setPageNo(pageNo); |
|||
setPageSize(pageSize); |
|||
setTotalPage(totalPage); |
|||
setTotalCount(totalCount); |
|||
setData(data); |
|||
} |
|||
|
|||
public Page(MyPageInfo<T> myPageInfo){ |
|||
Integer pageNo = myPageInfo.getPageNo(); |
|||
Integer pageSize = myPageInfo.getPageSize(); |
|||
Integer totalPage = myPageInfo.getPages(); |
|||
int totalCount = myPageInfo.getTotal(); |
|||
List<T> data = myPageInfo.getList(); |
|||
setPageNo(pageNo); |
|||
setPageSize(pageSize); |
|||
setTotalPage(totalPage); |
|||
setTotalCount((long) totalCount); |
|||
setData(data); |
|||
} |
|||
|
|||
public Integer getPageSize() { |
|||
return pageSize; |
|||
} |
|||
|
|||
public void setPageSize(Integer pageSize) { |
|||
this.pageSize = pageSize; |
|||
} |
|||
|
|||
public Integer getPageNo() { |
|||
return pageNo; |
|||
} |
|||
|
|||
public void setPageNo(Integer pageNo) { |
|||
this.pageNo = pageNo; |
|||
} |
|||
|
|||
public Integer getTotalPage() { |
|||
return totalPage; |
|||
} |
|||
|
|||
public void setTotalPage(Integer totalPage) { |
|||
this.totalPage = totalPage; |
|||
} |
|||
|
|||
public Long getTotalCount() { |
|||
return totalCount; |
|||
} |
|||
|
|||
public void setTotalCount(Long totalCount) { |
|||
this.totalCount = totalCount; |
|||
} |
|||
|
|||
public List<T> getData() { |
|||
return data; |
|||
} |
|||
|
|||
public void setData(List<T> data) { |
|||
this.data = data; |
|||
} |
|||
} |
@ -1,136 +0,0 @@ |
|||
package com.genersoft.iot.vmp.common; |
|||
|
|||
import com.alibaba.fastjson.annotation.JSONField; |
|||
|
|||
public class VersionPo { |
|||
/** |
|||
* git的全版本号 |
|||
*/ |
|||
@JSONField(name="GIT-Revision") |
|||
private String GIT_Revision; |
|||
/** |
|||
* maven版本 |
|||
*/ |
|||
@JSONField(name = "Create-By") |
|||
private String Create_By; |
|||
/** |
|||
* git的分支 |
|||
*/ |
|||
@JSONField(name = "GIT-BRANCH") |
|||
private String GIT_BRANCH; |
|||
/** |
|||
* git的url |
|||
*/ |
|||
@JSONField(name = "GIT-URL") |
|||
private String GIT_URL; |
|||
/** |
|||
* 构建日期 |
|||
*/ |
|||
@JSONField(name = "BUILD-DATE") |
|||
private String BUILD_DATE; |
|||
/** |
|||
* 项目名称 配合pom使用 |
|||
*/ |
|||
@JSONField(name = "artifactId") |
|||
private String artifactId; |
|||
/** |
|||
* git局部版本号 |
|||
*/ |
|||
@JSONField(name = "GIT-Revision-SHORT") |
|||
private String GIT_Revision_SHORT; |
|||
/** |
|||
* 项目的版本如2.0.1.0 配合pom使用 |
|||
*/ |
|||
@JSONField(name = "version") |
|||
private String version; |
|||
/** |
|||
* 子系统名称 |
|||
*/ |
|||
@JSONField(name = "project") |
|||
private String project; |
|||
/** |
|||
* jdk版本 |
|||
*/ |
|||
@JSONField(name="Build_Jdk") |
|||
private String Build_Jdk; |
|||
|
|||
public void setGIT_Revision(String GIT_Revision) { |
|||
this.GIT_Revision = GIT_Revision; |
|||
} |
|||
|
|||
public void setCreate_By(String create_By) { |
|||
Create_By = create_By; |
|||
} |
|||
|
|||
public void setGIT_BRANCH(String GIT_BRANCH) { |
|||
this.GIT_BRANCH = GIT_BRANCH; |
|||
} |
|||
|
|||
public void setGIT_URL(String GIT_URL) { |
|||
this.GIT_URL = GIT_URL; |
|||
} |
|||
|
|||
public void setBUILD_DATE(String BUILD_DATE) { |
|||
this.BUILD_DATE = BUILD_DATE; |
|||
} |
|||
|
|||
public void setArtifactId(String artifactId) { |
|||
this.artifactId = artifactId; |
|||
} |
|||
|
|||
public void setGIT_Revision_SHORT(String GIT_Revision_SHORT) { |
|||
this.GIT_Revision_SHORT = GIT_Revision_SHORT; |
|||
} |
|||
|
|||
public void setVersion(String version) { |
|||
this.version = version; |
|||
} |
|||
|
|||
public void setProject(String project) { |
|||
this.project = project; |
|||
} |
|||
|
|||
public void setBuild_Jdk(String build_Jdk) { |
|||
Build_Jdk = build_Jdk; |
|||
} |
|||
|
|||
public String getGIT_Revision() { |
|||
return GIT_Revision; |
|||
} |
|||
|
|||
public String getCreate_By() { |
|||
return Create_By; |
|||
} |
|||
|
|||
public String getGIT_BRANCH() { |
|||
return GIT_BRANCH; |
|||
} |
|||
|
|||
public String getGIT_URL() { |
|||
return GIT_URL; |
|||
} |
|||
|
|||
public String getBUILD_DATE() { |
|||
return BUILD_DATE; |
|||
} |
|||
|
|||
public String getArtifactId() { |
|||
return artifactId; |
|||
} |
|||
|
|||
public String getGIT_Revision_SHORT() { |
|||
return GIT_Revision_SHORT; |
|||
} |
|||
|
|||
public String getVersion() { |
|||
return version; |
|||
} |
|||
|
|||
public String getProject() { |
|||
return project; |
|||
} |
|||
|
|||
public String getBuild_Jdk() { |
|||
return Build_Jdk; |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.genersoft.iot.vmp.common.reponse; |
|||
|
|||
public class ErrorResponseData extends ResponseData{ |
|||
/** |
|||
* 异常的具体类名称 |
|||
*/ |
|||
private String exceptionClazz; |
|||
|
|||
public String getExceptionClazz() { |
|||
return exceptionClazz; |
|||
} |
|||
|
|||
public void setExceptionClazz(String exceptionClazz) { |
|||
this.exceptionClazz = exceptionClazz; |
|||
} |
|||
|
|||
ErrorResponseData(String message) { |
|||
super(false, DEFAULT_ERROR_CODE, message, null); |
|||
} |
|||
|
|||
public ErrorResponseData(Integer code, String message) { |
|||
super(false, code, message, null); |
|||
} |
|||
|
|||
ErrorResponseData(Integer code, String message, Object object) { |
|||
super(false, code, message, object); |
|||
} |
|||
} |
@ -0,0 +1,98 @@ |
|||
package com.genersoft.iot.vmp.common.reponse; |
|||
|
|||
public class ResponseData { |
|||
|
|||
public static final String DEFAULT_SUCCESS_MESSAGE = "请求成功"; |
|||
|
|||
public static final String DEFAULT_ERROR_MESSAGE = "网络异常"; |
|||
|
|||
public static final Integer DEFAULT_SUCCESS_CODE = 200; |
|||
|
|||
public static final Integer DEFAULT_ERROR_CODE = 500; |
|||
|
|||
/** |
|||
* 请求是否成功 |
|||
*/ |
|||
private Boolean success; |
|||
|
|||
/** |
|||
* 响应状态码 |
|||
*/ |
|||
private Integer code; |
|||
|
|||
/** |
|||
* 响应信息 |
|||
*/ |
|||
private String message; |
|||
|
|||
/** |
|||
* 响应对象 |
|||
*/ |
|||
private Object data; |
|||
|
|||
public ResponseData() { |
|||
} |
|||
|
|||
public ResponseData(Boolean success, Integer code, String message, Object data) { |
|||
this.success = success; |
|||
this.code = code; |
|||
this.message = message; |
|||
this.data = data; |
|||
} |
|||
|
|||
public static SuccessResponseData success() { |
|||
return new SuccessResponseData(); |
|||
} |
|||
|
|||
public static SuccessResponseData success(Object object) { |
|||
return new SuccessResponseData(object); |
|||
} |
|||
|
|||
public static SuccessResponseData success(Integer code, String message, Object object) { |
|||
return new SuccessResponseData(code, message, object); |
|||
} |
|||
|
|||
public static ErrorResponseData error(String message) { |
|||
return new ErrorResponseData(message); |
|||
} |
|||
|
|||
public static ErrorResponseData error(Integer code, String message) { |
|||
return new ErrorResponseData(code, message); |
|||
} |
|||
|
|||
public static ErrorResponseData error(Integer code, String message, Object object) { |
|||
return new ErrorResponseData(code, message, object); |
|||
} |
|||
|
|||
public Boolean getSuccess() { |
|||
return success; |
|||
} |
|||
|
|||
public void setSuccess(Boolean success) { |
|||
this.success = success; |
|||
} |
|||
|
|||
public Integer getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(Integer code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getMessage() { |
|||
return message; |
|||
} |
|||
|
|||
public void setMessage(String message) { |
|||
this.message = message; |
|||
} |
|||
|
|||
public Object getData() { |
|||
return data; |
|||
} |
|||
|
|||
public void setData(Object data) { |
|||
this.data = data; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.genersoft.iot.vmp.common.reponse; |
|||
|
|||
public class SuccessResponseData extends ResponseData { |
|||
public SuccessResponseData() { |
|||
super(true, DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MESSAGE, null); |
|||
} |
|||
|
|||
public SuccessResponseData(Object object) { |
|||
super(true, DEFAULT_SUCCESS_CODE, DEFAULT_SUCCESS_MESSAGE, object); |
|||
} |
|||
|
|||
public SuccessResponseData(Integer code, String message, Object object) { |
|||
super(true, code, message, object); |
|||
} |
|||
} |
@ -1,25 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf; |
|||
|
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* @description: 获取数据库配置 |
|||
* @author: swwheihei |
|||
* @date: 2020年5月6日 下午2:46:00 |
|||
*/ |
|||
@Configuration("vmConfig") |
|||
public class VManagerConfig { |
|||
|
|||
@Value("${spring.application.database:redis}") |
|||
private String database; |
|||
|
|||
|
|||
public String getDatabase() { |
|||
return database; |
|||
} |
|||
|
|||
public void setDatabase(String database) { |
|||
this.database = database; |
|||
} |
|||
} |
@ -1,37 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf; |
|||
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
@Component |
|||
@ConfigurationProperties(prefix = "version") |
|||
public class VersionConfig { |
|||
|
|||
private String version; |
|||
private String artifactId; |
|||
private String description; |
|||
|
|||
public void setVersion(String version) { |
|||
this.version = version; |
|||
} |
|||
|
|||
public void setArtifactId(String artifactId) { |
|||
this.artifactId = artifactId; |
|||
} |
|||
|
|||
public void setDescription(String description) { |
|||
this.description = description; |
|||
} |
|||
|
|||
public String getVersion() { |
|||
return version; |
|||
} |
|||
|
|||
public String getArtifactId() { |
|||
return artifactId; |
|||
} |
|||
|
|||
public String getDescription() { |
|||
return description; |
|||
} |
|||
} |
@ -1,37 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf; |
|||
|
|||
import com.genersoft.iot.vmp.common.VersionPo; |
|||
import com.genersoft.iot.vmp.utils.GitUtil; |
|||
import com.genersoft.iot.vmp.utils.JarFileUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@Component |
|||
public class VersionInfo { |
|||
|
|||
@Autowired |
|||
VersionConfig config; |
|||
@Autowired |
|||
GitUtil gitUtil; |
|||
@Autowired |
|||
JarFileUtils jarFileUtils; |
|||
|
|||
public VersionPo getVersion() { |
|||
VersionPo versionPo = new VersionPo(); |
|||
Map<String,String> map=jarFileUtils.readJarFile(); |
|||
versionPo.setGIT_Revision(gitUtil.getGitCommitId()); |
|||
versionPo.setCreate_By(map.get("Created-By")); |
|||
versionPo.setGIT_BRANCH(gitUtil.getBranch()); |
|||
versionPo.setGIT_URL(gitUtil.getGitUrl()); |
|||
versionPo.setBUILD_DATE(gitUtil.getBuildDate()); |
|||
versionPo.setArtifactId(config.getArtifactId()); |
|||
versionPo.setGIT_Revision_SHORT(gitUtil.getCommitIdShort()); |
|||
versionPo.setVersion(config.getVersion()); |
|||
versionPo.setProject(config.getDescription()); |
|||
versionPo.setBuild_Jdk(map.get("Build-Jdk")); |
|||
|
|||
return versionPo; |
|||
} |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.genersoft.iot.vmp.conf; |
|||
|
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.web.servlet.config.annotation.CorsRegistry; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
|
|||
@Configuration |
|||
public class WebConfig implements WebMvcConfigurer { |
|||
|
|||
// 设置允许跨域请求
|
|||
@Bean |
|||
public WebMvcConfigurer corsConfigurer() { |
|||
return new WebMvcConfigurer() { |
|||
@Override |
|||
public void addCorsMappings(CorsRegistry registry) { |
|||
registry.addMapping("/**") |
|||
.allowedOrigins("*") // 允许所有域
|
|||
.allowedMethods("*") // 允许任何方法(post、get等)
|
|||
.allowedHeaders("*") // 允许任何请求头
|
|||
.allowCredentials(true) // 允许证书、cookie
|
|||
.exposedHeaders(HttpHeaders.SET_COOKIE) |
|||
.maxAge(3600L); // maxAge(3600)表明在3600秒内,不需要再发送预检验请求,可以缓存该结果
|
|||
} |
|||
}; |
|||
} |
|||
} |
@ -1,43 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.security.core.AuthenticationException; |
|||
import org.springframework.security.web.AuthenticationEntryPoint; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* 处理匿名用户访问逻辑 |
|||
*/ |
|||
@Component |
|||
public class AnonymousAuthenticationEntryPoint implements AuthenticationEntryPoint { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(DefaultUserDetailsServiceImpl.class); |
|||
|
|||
@Override |
|||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { |
|||
logger.debug("用户需要登录,访问[{}]失败,AuthenticationException=[{}]", request.getRequestURI(), e.getMessage()); |
|||
// 允许跨域
|
|||
response.setHeader("Access-Control-Allow-Origin", "*"); |
|||
// 允许自定义请求头token(允许head跨域)
|
|||
response.setHeader("Access-Control-Allow-Headers", "token, Accept, Origin, X-Requested-With, Content-Type, Last-Modified"); |
|||
response.setHeader("Content-type", "application/json;charset=UTF-8"); |
|||
JSONObject jsonObject = new JSONObject(); |
|||
jsonObject.put("code", "-1"); |
|||
jsonObject.put("msg", "请登录后重新请求"); |
|||
if (request.getRequestURI().contains("api/user/login")){ |
|||
jsonObject.put("msg", e.getMessage()); |
|||
} |
|||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); |
|||
try { |
|||
response.getWriter().print(jsonObject.toJSONString()); |
|||
} catch (IOException ioException) { |
|||
ioException.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -1,47 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import com.genersoft.iot.vmp.conf.security.dto.LoginUser; |
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import com.github.xiaoymin.knife4j.core.util.StrUtil; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
import org.springframework.security.core.userdetails.UserDetailsService; |
|||
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
/** |
|||
* 用户登录认证逻辑 |
|||
*/ |
|||
@Component |
|||
public class DefaultUserDetailsServiceImpl implements UserDetailsService { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(DefaultUserDetailsServiceImpl.class); |
|||
|
|||
@Autowired |
|||
private IUserService userService; |
|||
|
|||
@Override |
|||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
|||
if (StrUtil.isBlank(username)) { |
|||
logger.info("登录用户:{} 不存在", username); |
|||
throw new UsernameNotFoundException("登录用户:" + username + " 不存在"); |
|||
} |
|||
|
|||
// 查出密码
|
|||
User user = userService.getUserByUsername(username); |
|||
if (user == null) { |
|||
logger.info("登录用户:{} 不存在", username); |
|||
throw new UsernameNotFoundException("登录用户:" + username + " 不存在"); |
|||
} |
|||
String password = SecurityUtils.encryptPassword(user.getPassword()); |
|||
user.setPassword(password); |
|||
return new LoginUser(user, LocalDateTime.now()); |
|||
} |
|||
|
|||
|
|||
} |
@ -1,24 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.security.web.session.InvalidSessionStrategy; |
|||
|
|||
import javax.servlet.ServletException; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* 登录超时的处理 |
|||
*/ |
|||
public class InvalidSessionHandler implements InvalidSessionStrategy { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(InvalidSessionHandler.class); |
|||
|
|||
@Override |
|||
public void onInvalidSessionDetected(HttpServletRequest request, HttpServletResponse httpServletResponse) throws IOException, ServletException { |
|||
String username = request.getParameter("username"); |
|||
logger.info("[登录超时] - [{}]", username); |
|||
} |
|||
} |
@ -1,65 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.security.authentication.*; |
|||
import org.springframework.security.core.AuthenticationException; |
|||
import org.springframework.security.web.authentication.AuthenticationFailureHandler; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.servlet.ServletException; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Component |
|||
public class LoginFailureHandler implements AuthenticationFailureHandler { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(LoginFailureHandler.class); |
|||
|
|||
@Autowired |
|||
private ObjectMapper objectMapper; |
|||
|
|||
@Override |
|||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException { |
|||
|
|||
String username = request.getParameter("username"); |
|||
if (e instanceof AccountExpiredException) { |
|||
// 账号过期
|
|||
logger.info("[登录失败] - 用户[{}]账号过期", username); |
|||
|
|||
} else if (e instanceof BadCredentialsException) { |
|||
// 密码错误
|
|||
logger.info("[登录失败] - 用户[{}]密码/SIP服务器ID 错误", username); |
|||
|
|||
} else if (e instanceof CredentialsExpiredException) { |
|||
// 密码过期
|
|||
logger.info("[登录失败] - 用户[{}]密码过期", username); |
|||
|
|||
} else if (e instanceof DisabledException) { |
|||
// 用户被禁用
|
|||
logger.info("[登录失败] - 用户[{}]被禁用", username); |
|||
|
|||
} else if (e instanceof LockedException) { |
|||
// 用户被锁定
|
|||
logger.info("[登录失败] - 用户[{}]被锁定", username); |
|||
|
|||
} else if (e instanceof InternalAuthenticationServiceException) { |
|||
// 内部错误
|
|||
logger.error(String.format("[登录失败] - [%s]内部错误", username), e); |
|||
|
|||
} else { |
|||
// 其他错误
|
|||
logger.error(String.format("[登录失败] - [%s]其他错误", username), e); |
|||
} |
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("code","0"); |
|||
map.put("msg","登录失败"); |
|||
response.setContentType("application/json;charset=UTF-8"); |
|||
response.getWriter().write(objectMapper.writeValueAsString(map)); |
|||
} |
|||
} |
@ -1,24 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.security.core.Authentication; |
|||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.servlet.ServletException; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
|
|||
@Component |
|||
public class LoginSuccessHandler implements AuthenticationSuccessHandler { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(LoginSuccessHandler.class); |
|||
|
|||
@Override |
|||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { |
|||
String username = request.getParameter("username"); |
|||
logger.info("[登录成功] - [{}]", username); |
|||
} |
|||
} |
@ -1,27 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.security.core.Authentication; |
|||
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.servlet.ServletException; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
|
|||
/** |
|||
* 退出登录成功 |
|||
*/ |
|||
@Component |
|||
public class LogoutHandler implements LogoutSuccessHandler { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(LogoutHandler.class); |
|||
|
|||
@Override |
|||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException { |
|||
String username = request.getParameter("username"); |
|||
logger.info("[退出登录成功] - [{}]", username); |
|||
} |
|||
} |
@ -1,78 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import com.genersoft.iot.vmp.conf.security.dto.LoginUser; |
|||
import org.springframework.security.authentication.AuthenticationManager; |
|||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
|||
import org.springframework.security.core.Authentication; |
|||
import org.springframework.security.core.context.SecurityContext; |
|||
import org.springframework.security.core.context.SecurityContextHolder; |
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|||
|
|||
import javax.security.sasl.AuthenticationException; |
|||
|
|||
public class SecurityUtils { |
|||
|
|||
/** |
|||
* 描述根据账号密码进行调用security进行认证授权 主动调 |
|||
* 用AuthenticationManager的authenticate方法实现 |
|||
* 授权成功后将用户信息存入SecurityContext当中 |
|||
* @param username 用户名 |
|||
* @param password 密码 |
|||
* @param authenticationManager 认证授权管理器, |
|||
* @see AuthenticationManager |
|||
* @return UserInfo 用户信息 |
|||
*/ |
|||
public static LoginUser login(String username, String password, AuthenticationManager authenticationManager) throws AuthenticationException { |
|||
//使用security框架自带的验证token生成器 也可以自定义。
|
|||
UsernamePasswordAuthenticationToken token =new UsernamePasswordAuthenticationToken(username,password); |
|||
Authentication authenticate = authenticationManager.authenticate(token); |
|||
SecurityContextHolder.getContext().setAuthentication(authenticate); |
|||
LoginUser user = (LoginUser) authenticate.getPrincipal(); |
|||
return user; |
|||
} |
|||
|
|||
/** |
|||
* 获取当前登录的所有认证信息 |
|||
* @return |
|||
*/ |
|||
public static Authentication getAuthentication(){ |
|||
SecurityContext context = SecurityContextHolder.getContext(); |
|||
return context.getAuthentication(); |
|||
} |
|||
|
|||
/** |
|||
* 获取当前登录用户信息 |
|||
* @return |
|||
*/ |
|||
public static LoginUser getUserInfo(){ |
|||
Authentication authentication = getAuthentication(); |
|||
if(authentication!=null){ |
|||
Object principal = authentication.getPrincipal(); |
|||
if(principal!=null && !"anonymousUser".equals(principal)){ |
|||
LoginUser user = (LoginUser) authentication.getPrincipal(); |
|||
return user; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 获取当前登录用户ID |
|||
* @return |
|||
*/ |
|||
public static int getUserId(){ |
|||
LoginUser user = getUserInfo(); |
|||
return user.getId(); |
|||
} |
|||
|
|||
/** |
|||
* 生成BCryptPasswordEncoder密码 |
|||
* |
|||
* @param password 密码 |
|||
* @return 加密字符串 |
|||
*/ |
|||
public static String encryptPassword(String password) { |
|||
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|||
return passwordEncoder.encode(password); |
|||
} |
|||
} |
@ -1,169 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security; |
|||
|
|||
import com.genersoft.iot.vmp.conf.UserSetup; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.security.authentication.AuthenticationManager; |
|||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider; |
|||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
|||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |
|||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|||
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
|||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 配置Spring Security |
|||
*/ |
|||
@Configuration |
|||
@EnableWebSecurity |
|||
@EnableGlobalMethodSecurity(prePostEnabled = true) |
|||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
|||
|
|||
private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class); |
|||
|
|||
@Autowired |
|||
private UserSetup userSetup; |
|||
|
|||
@Autowired |
|||
private DefaultUserDetailsServiceImpl userDetailsService; |
|||
/** |
|||
* 登出成功的处理 |
|||
*/ |
|||
@Autowired |
|||
private LoginFailureHandler loginFailureHandler; |
|||
/** |
|||
* 登录成功的处理 |
|||
*/ |
|||
@Autowired |
|||
private LoginSuccessHandler loginSuccessHandler; |
|||
/** |
|||
* 登出成功的处理 |
|||
*/ |
|||
@Autowired |
|||
private LogoutHandler logoutHandler; |
|||
/** |
|||
* 未登录的处理 |
|||
*/ |
|||
@Autowired |
|||
private AnonymousAuthenticationEntryPoint anonymousAuthenticationEntryPoint; |
|||
// /**
|
|||
// * 超时处理
|
|||
// */
|
|||
// @Autowired
|
|||
// private InvalidSessionHandler invalidSessionHandler;
|
|||
|
|||
// /**
|
|||
// * 顶号处理
|
|||
// */
|
|||
// @Autowired
|
|||
// private SessionInformationExpiredHandler sessionInformationExpiredHandler;
|
|||
// /**
|
|||
// * 登录用户没有权限访问资源
|
|||
// */
|
|||
// @Autowired
|
|||
// private LoginUserAccessDeniedHandler accessDeniedHandler;
|
|||
|
|||
|
|||
/** |
|||
* 描述: 静态资源放行,这里的放行,是不走 Spring Security 过滤器链 |
|||
**/ |
|||
@Override |
|||
public void configure(WebSecurity web) { |
|||
|
|||
if (!userSetup.isInterfaceAuthentication()) { |
|||
web.ignoring().antMatchers("**"); |
|||
}else { |
|||
// 可以直接访问的静态数据
|
|||
web.ignoring() |
|||
.antMatchers("/") |
|||
.antMatchers("/#/**") |
|||
.antMatchers("/static/**") |
|||
.antMatchers("/index.html") |
|||
.antMatchers("/doc.html") // "/webjars/**", "/swagger-resources/**", "/v3/api-docs/**"
|
|||
.antMatchers("/webjars/**") |
|||
.antMatchers("/swagger-resources/**") |
|||
.antMatchers("/v3/api-docs/**") |
|||
.antMatchers("/js/**"); |
|||
List<String> interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes(); |
|||
for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) { |
|||
if (interfaceAuthenticationExclude.split("/").length < 4 ) { |
|||
logger.warn("{}不满足两级目录,已忽略", interfaceAuthenticationExclude); |
|||
}else { |
|||
web.ignoring().antMatchers(interfaceAuthenticationExclude); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 配置认证方式 |
|||
* @param auth |
|||
* @throws Exception |
|||
*/ |
|||
@Override |
|||
protected void configure(AuthenticationManagerBuilder auth) throws Exception { |
|||
DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); |
|||
// 设置不隐藏 未找到用户异常
|
|||
provider.setHideUserNotFoundExceptions(true); |
|||
// 用户认证service - 查询数据库的逻辑
|
|||
provider.setUserDetailsService(userDetailsService); |
|||
// 设置密码加密算法
|
|||
provider.setPasswordEncoder(passwordEncoder()); |
|||
auth.authenticationProvider(provider); |
|||
} |
|||
|
|||
@Override |
|||
protected void configure(HttpSecurity http) throws Exception { |
|||
http.cors().and().csrf().disable(); |
|||
// 设置允许添加静态文件
|
|||
http.headers().contentTypeOptions().disable(); |
|||
http.authorizeRequests() |
|||
// 放行接口
|
|||
.antMatchers("/api/user/login","/index/hook/**").permitAll() |
|||
// 除上面外的所有请求全部需要鉴权认证
|
|||
.anyRequest().authenticated() |
|||
// 异常处理(权限拒绝、登录失效等)
|
|||
.and().exceptionHandling() |
|||
.authenticationEntryPoint(anonymousAuthenticationEntryPoint)//匿名用户访问无权限资源时的异常处理
|
|||
// .accessDeniedHandler(accessDeniedHandler)//登录用户没有权限访问资源
|
|||
// 登入
|
|||
.and().formLogin().permitAll()//允许所有用户
|
|||
.successHandler(loginSuccessHandler)//登录成功处理逻辑
|
|||
.failureHandler(loginFailureHandler)//登录失败处理逻辑
|
|||
// 登出
|
|||
.and().logout().logoutUrl("/api/user/logout").permitAll()//允许所有用户
|
|||
.logoutSuccessHandler(logoutHandler)//登出成功处理逻辑
|
|||
.deleteCookies("JSESSIONID") |
|||
// 会话管理
|
|||
// .and().sessionManagement().invalidSessionStrategy(invalidSessionHandler) // 超时处理
|
|||
// .maximumSessions(1)//同一账号同时登录最大用户数
|
|||
// .expiredSessionStrategy(sessionInformationExpiredHandler) // 顶号处理
|
|||
; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 描述: 密码加密算法 BCrypt 推荐使用 |
|||
**/ |
|||
@Bean |
|||
public BCryptPasswordEncoder passwordEncoder() { |
|||
return new BCryptPasswordEncoder(); |
|||
} |
|||
|
|||
/** |
|||
* 描述: 注入AuthenticationManager管理器 |
|||
**/ |
|||
@Override |
|||
@Bean |
|||
public AuthenticationManager authenticationManager() throws Exception { |
|||
return super.authenticationManager(); |
|||
} |
|||
} |
@ -1,102 +0,0 @@ |
|||
package com.genersoft.iot.vmp.conf.security.dto; |
|||
|
|||
import com.genersoft.iot.vmp.storager.dao.dto.Role; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import org.springframework.security.core.CredentialsContainer; |
|||
import org.springframework.security.core.GrantedAuthority; |
|||
import org.springframework.security.core.SpringSecurityCoreVersion; |
|||
import org.springframework.security.core.userdetails.UserDetails; |
|||
|
|||
import java.time.LocalDateTime; |
|||
import java.util.Collection; |
|||
|
|||
public class LoginUser implements UserDetails, CredentialsContainer { |
|||
|
|||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID; |
|||
|
|||
/** |
|||
* 用户 |
|||
*/ |
|||
private User user; |
|||
|
|||
|
|||
/** |
|||
* 登录时间 |
|||
*/ |
|||
private LocalDateTime loginTime; |
|||
|
|||
public LoginUser(User user, LocalDateTime loginTime) { |
|||
this.user = user; |
|||
this.loginTime = loginTime; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public Collection<? extends GrantedAuthority> getAuthorities() { |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public String getPassword() { |
|||
return user.getPassword(); |
|||
} |
|||
|
|||
@Override |
|||
public String getUsername() { |
|||
return user.getUsername(); |
|||
} |
|||
|
|||
/** |
|||
* 账户是否未过期,过期无法验证 |
|||
*/ |
|||
@Override |
|||
public boolean isAccountNonExpired() { |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 指定用户是否解锁,锁定的用户无法进行身份验证 |
|||
* <p> |
|||
* 密码锁定 |
|||
* </p> |
|||
*/ |
|||
@Override |
|||
public boolean isAccountNonLocked() { |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 指示是否已过期的用户的凭据(密码),过期的凭据防止认证 |
|||
*/ |
|||
@Override |
|||
public boolean isCredentialsNonExpired() { |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 用户是否被启用或禁用。禁用的用户无法进行身份验证。 |
|||
*/ |
|||
@Override |
|||
public boolean isEnabled() { |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* 认证完成后,擦除密码 |
|||
*/ |
|||
@Override |
|||
public void eraseCredentials() { |
|||
user.setPassword(null); |
|||
} |
|||
|
|||
|
|||
public int getId() { |
|||
return user.getId(); |
|||
} |
|||
|
|||
public Role getRole() { |
|||
return user.getRole(); |
|||
} |
|||
|
|||
|
|||
} |
@ -1,8 +1,16 @@ |
|||
package com.genersoft.iot.vmp.service; |
|||
|
|||
import com.genersoft.iot.vmp.common.reponse.ResponseData; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo; |
|||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; |
|||
import com.github.pagehelper.PageInfo; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
public interface IRecordInfoServer { |
|||
|
|||
PageInfo<RecordInfo> getRecordList(int page, int count); |
|||
|
|||
ResponseData resetRecords(Map<String, Object> params); |
|||
} |
|||
|
@ -1,22 +0,0 @@ |
|||
package com.genersoft.iot.vmp.service; |
|||
|
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface IUserService { |
|||
|
|||
User getUser(String username, String password); |
|||
|
|||
boolean changePassword(int id, String password); |
|||
|
|||
User getUserByUsername(String username); |
|||
|
|||
int addUser(User user); |
|||
|
|||
int deleteUser(int id); |
|||
|
|||
List<User> getAllUsers(); |
|||
|
|||
int updateUsers(User user); |
|||
} |
@ -0,0 +1,10 @@ |
|||
package com.genersoft.iot.vmp.service; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
|
|||
public interface IVideoSquareService { |
|||
|
|||
//获取视屏树tree
|
|||
JSONArray selectVideoTree(); |
|||
|
|||
} |
@ -1,56 +0,0 @@ |
|||
package com.genersoft.iot.vmp.service.impl; |
|||
|
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.UserMapper; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class UserServiceImpl implements IUserService { |
|||
|
|||
@Autowired |
|||
private UserMapper userMapper; |
|||
|
|||
@Override |
|||
public User getUser(String username, String password) { |
|||
return userMapper.select(username, password); |
|||
} |
|||
|
|||
@Override |
|||
public boolean changePassword(int id, String password) { |
|||
User user = userMapper.selectById(id); |
|||
user.setPassword(password); |
|||
return userMapper.update(user) > 0; |
|||
} |
|||
|
|||
@Override |
|||
public User getUserByUsername(String username) { |
|||
return userMapper.getUserByUsername(username); |
|||
} |
|||
|
|||
@Override |
|||
public int addUser(User user) { |
|||
User userByUsername = userMapper.getUserByUsername(user.getUsername()); |
|||
if (userByUsername != null) return 0; |
|||
return userMapper.add(user); |
|||
} |
|||
@Override |
|||
public int deleteUser(int id) { |
|||
return userMapper.delete(id); |
|||
} |
|||
|
|||
@Override |
|||
public List<User> getAllUsers() { |
|||
return userMapper.selectAll(); |
|||
} |
|||
|
|||
@Override |
|||
public int updateUsers(User user) { |
|||
return userMapper.update(user); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,52 @@ |
|||
package com.genersoft.iot.vmp.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.genersoft.iot.vmp.gb28181.bean.Device; |
|||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
|||
import com.genersoft.iot.vmp.service.IVideoSquareService; |
|||
import com.genersoft.iot.vmp.storager.dao.VideoSquareMapper; |
|||
import org.apache.commons.lang3.ObjectUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class VideoSquareServiceImpl implements IVideoSquareService { |
|||
|
|||
@Autowired |
|||
private VideoSquareMapper videoSquareMapper; |
|||
|
|||
@Override |
|||
public JSONArray selectVideoTree() { |
|||
JSONArray jsonArray = new JSONArray(); |
|||
List<Device> devices = videoSquareMapper.selectDevices(); |
|||
if (ObjectUtils.anyNotNull(devices)) { |
|||
List<DeviceChannel> deviceChannels = videoSquareMapper.selectDeviceChannels(); |
|||
devices.forEach(device -> { |
|||
String deviceId1 = device.getDeviceId(); |
|||
JSONObject parent = new JSONObject(); |
|||
parent.put("title", deviceId1); |
|||
parent.put("key", deviceId1); |
|||
jsonArray.add(parent); |
|||
JSONArray children = new JSONArray(); |
|||
parent.put("children", children); |
|||
deviceChannels.forEach(deviceChannel -> { |
|||
String deviceId2 = deviceChannel.getDeviceId(); |
|||
if (deviceId1.equals(deviceId2)) { |
|||
JSONObject childrenObj = new JSONObject(); |
|||
childrenObj.put("title", deviceChannel.getName()); |
|||
childrenObj.put("key", deviceId1 + "_" + deviceChannel.getChannelId()); |
|||
childrenObj.put("slots", JSON.parse("{icon: 'cameraVideo'}")); |
|||
children.add(childrenObj); |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
return jsonArray; |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.genersoft.iot.vmp.storager.dao; |
|||
|
|||
import com.genersoft.iot.vmp.gb28181.bean.Device; |
|||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Select; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
@Repository |
|||
public interface VideoSquareMapper { |
|||
|
|||
@Select("select * FROM device") |
|||
List<Device> selectDevices(); |
|||
|
|||
@Select("select * from device_channel") |
|||
List<DeviceChannel> selectDeviceChannels(); |
|||
} |
File diff suppressed because it is too large
@ -1,44 +0,0 @@ |
|||
package com.genersoft.iot.vmp.utils; |
|||
|
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.PropertySource; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 一个优秀的颓废程序猿(CSDN) |
|||
*/ |
|||
@Component |
|||
@PropertySource(value = {"classpath:git.properties" }, ignoreResourceNotFound = true) |
|||
public class GitUtil { |
|||
|
|||
@Value("${git.branch:null}") |
|||
private String branch; |
|||
@Value("${git.commit.id:null}") |
|||
private String gitCommitId; |
|||
@Value("${git.remote.origin.url:null}") |
|||
private String gitUrl; |
|||
@Value("${git.build.time:null}") |
|||
private String buildDate; |
|||
@Value("${git.commit.id.abbrev:null}") |
|||
private String commitIdShort; |
|||
|
|||
public String getGitCommitId() { |
|||
return gitCommitId; |
|||
} |
|||
|
|||
public String getBranch() { |
|||
return branch; |
|||
} |
|||
|
|||
public String getGitUrl() { |
|||
return gitUrl; |
|||
} |
|||
|
|||
public String getBuildDate() { |
|||
return buildDate; |
|||
} |
|||
|
|||
public String getCommitIdShort() { |
|||
return commitIdShort; |
|||
} |
|||
} |
@ -1,73 +0,0 @@ |
|||
package com.genersoft.iot.vmp.utils; |
|||
|
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.ClassUtils; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.io.InputStreamReader; |
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
import java.util.jar.JarEntry; |
|||
import java.util.jar.JarFile; |
|||
|
|||
/** |
|||
* 一个优秀的颓废程序猿 |
|||
*/ |
|||
@Component |
|||
public class JarFileUtils { |
|||
private static Logger log = LoggerFactory.getLogger(JarFileUtils.class); |
|||
private static Map<String, String> map = new HashMap<>(); |
|||
|
|||
public Map<String, String> readJarFile() { |
|||
JarFile jarFile = null; |
|||
BufferedReader br = null; |
|||
try { |
|||
// 获取jar的运行路径,因linux下jar的路径为”file:/app/.../test.jar!/BOOT-INF/class!/“这种格式,所以需要去掉”file:“和”!/BOOT-INF/class!/“
|
|||
String jarFilePath = ClassUtils.getDefaultClassLoader().getResource("").getPath().replace("!/BOOT-INF/classes!/", ""); |
|||
if (jarFilePath.startsWith("file")) { |
|||
jarFilePath = jarFilePath.substring(5); |
|||
} |
|||
log.debug("jarFilePath:" + jarFilePath); |
|||
// 通过JarFile的getJarEntry方法读取META-INF/MANIFEST.MF
|
|||
jarFile = new JarFile(jarFilePath); |
|||
JarEntry entry = jarFile.getJarEntry("META-INF/MANIFEST.MF"); |
|||
log.info("读取的内容:" + entry.toString()); |
|||
// 如果读取到MANIFEST.MF文件内容,则转换为string
|
|||
if (entry != null) { |
|||
InputStream in = jarFile.getInputStream(entry); |
|||
|
|||
StringBuilder sb = new StringBuilder(); |
|||
br = new BufferedReader(new InputStreamReader(in)); |
|||
String line = ""; |
|||
while ((line = br.readLine()) != null) { |
|||
if (line != null && line.contains(":")) { |
|||
int index = line.indexOf(":"); |
|||
map.put(line.substring(0, index).trim(), line.substring(index + 1, line.length()).trim()); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
} catch (IOException e) { |
|||
log.debug("读取MANIFEST.MF文件异常:" + e.getMessage()); |
|||
} finally { |
|||
try { |
|||
if (null != br) { |
|||
br.close(); |
|||
} |
|||
if (null != jarFile) { |
|||
jarFile.close(); |
|||
} |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
return map; |
|||
|
|||
} |
|||
|
|||
} |
@ -1,51 +1,23 @@ |
|||
//package com.genersoft.iot.vmp.vmanager.record;
|
|||
//
|
|||
//import com.alibaba.fastjson.JSONObject;
|
|||
//import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
|||
//import com.genersoft.iot.vmp.service.IRecordInfoServer;
|
|||
//import com.genersoft.iot.vmp.storager.dao.dto.RecordInfo;
|
|||
//import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
|||
//import com.github.pagehelper.PageInfo;
|
|||
//import io.swagger.annotations.Api;
|
|||
//import io.swagger.annotations.ApiImplicitParam;
|
|||
//import io.swagger.annotations.ApiImplicitParams;
|
|||
//import io.swagger.annotations.ApiOperation;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.web.bind.annotation.*;
|
|||
//
|
|||
//@Api(tags = "云端录像")
|
|||
//@CrossOrigin
|
|||
//@RestController
|
|||
//@RequestMapping("/api/record")
|
|||
//public class RecordController {
|
|||
//
|
|||
// @Autowired
|
|||
// private IRecordInfoServer recordInfoServer;
|
|||
//
|
|||
// @ApiOperation("录像列表查询")
|
|||
// @ApiImplicitParams({
|
|||
// @ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
|
|||
// @ApiImplicitParam(name="count", value = "每页查询数量", required = true, dataTypeClass = Integer.class),
|
|||
// @ApiImplicitParam(name="query", value = "查询内容", dataTypeClass = String.class),
|
|||
// })
|
|||
// @GetMapping(value = "/app/list")
|
|||
// @ResponseBody
|
|||
// public Object list(@RequestParam(required = false)Integer page,
|
|||
// @RequestParam(required = false)Integer count ){
|
|||
//
|
|||
// PageInfo<RecordInfo> recordList = recordInfoServer.getRecordList(page - 1, page - 1 + count);
|
|||
// return recordList;
|
|||
// }
|
|||
//
|
|||
// @ApiOperation("获取录像详情")
|
|||
// @ApiImplicitParams({
|
|||
// @ApiImplicitParam(name="recordInfo", value = "录像记录", required = true, dataTypeClass = RecordInfo.class)
|
|||
// })
|
|||
// @GetMapping(value = "/detail")
|
|||
// @ResponseBody
|
|||
// public JSONObject list(RecordInfo recordInfo, String time ){
|
|||
//
|
|||
//
|
|||
// return null;
|
|||
// }
|
|||
//}
|
|||
package com.genersoft.iot.vmp.vmanager.record; |
|||
|
|||
import com.genersoft.iot.vmp.common.reponse.ResponseData; |
|||
import com.genersoft.iot.vmp.service.IRecordInfoServer; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.Map; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/record") |
|||
public class RecordController { |
|||
|
|||
@Autowired |
|||
private IRecordInfoServer recordInfoServer; |
|||
|
|||
@PostMapping(value = "/resetRecords") |
|||
@ResponseBody |
|||
public ResponseData resetRecords(@RequestBody Map<String, Object> params) { |
|||
return recordInfoServer.resetRecords(params); |
|||
} |
|||
|
|||
} |
|||
|
@ -1,101 +0,0 @@ |
|||
package com.genersoft.iot.vmp.vmanager.user; |
|||
|
|||
import com.genersoft.iot.vmp.conf.security.SecurityUtils; |
|||
import com.genersoft.iot.vmp.service.IRoleService; |
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.Role; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.authentication.AuthenticationManager; |
|||
import org.springframework.util.DigestUtils; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.List; |
|||
|
|||
@Api(tags = "角色管理") |
|||
@CrossOrigin |
|||
@RestController |
|||
@RequestMapping("/api/role") |
|||
public class RoleController { |
|||
|
|||
@Autowired |
|||
private IRoleService roleService; |
|||
|
|||
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
|
|||
@ApiOperation("添加角色") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "name", required = true, value = "角色名", dataTypeClass = String.class), |
|||
@ApiImplicitParam(name = "authority", required = true, value = "权限(自行定义内容,目前未使用)", dataTypeClass = String.class), |
|||
}) |
|||
@PostMapping("/add") |
|||
public ResponseEntity<WVPResult<Integer>> add(@RequestParam String name, |
|||
@RequestParam(required = false) String authority){ |
|||
WVPResult<Integer> result = new WVPResult<>(); |
|||
// 获取当前登录用户id
|
|||
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); |
|||
if (currenRoleId != 1) { |
|||
// 只用角色id为1才可以删除和添加用户
|
|||
result.setCode(-1); |
|||
result.setMsg("用户无权限"); |
|||
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); |
|||
} |
|||
|
|||
Role role = new Role(); |
|||
role.setName(name); |
|||
role.setAuthority(authority); |
|||
role.setCreateTime(format.format(System.currentTimeMillis())); |
|||
role.setUpdateTime(format.format(System.currentTimeMillis())); |
|||
|
|||
int addResult = roleService.add(role); |
|||
|
|||
result.setCode(addResult > 0 ? 0 : -1); |
|||
result.setMsg(addResult > 0 ? "success" : "fail"); |
|||
result.setData(addResult); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
|
|||
@ApiOperation("删除角色") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class), |
|||
}) |
|||
@DeleteMapping("/delete") |
|||
public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ |
|||
// 获取当前登录用户id
|
|||
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); |
|||
WVPResult<String> result = new WVPResult<>(); |
|||
if (currenRoleId != 1) { |
|||
// 只用角色id为0才可以删除和添加用户
|
|||
result.setCode(-1); |
|||
result.setMsg("用户无权限"); |
|||
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); |
|||
} |
|||
int deleteResult = roleService.delete(id); |
|||
|
|||
result.setCode(deleteResult>0? 0 : -1); |
|||
result.setMsg(deleteResult>0? "success" : "fail"); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
|
|||
@ApiOperation("查询角色") |
|||
@ApiImplicitParams({}) |
|||
@GetMapping("/all") |
|||
public ResponseEntity<WVPResult<List<Role>>> all(){ |
|||
// 获取当前登录用户id
|
|||
List<Role> allRoles = roleService.getAll(); |
|||
WVPResult<List<Role>> result = new WVPResult<>(); |
|||
result.setCode(0); |
|||
result.setMsg("success"); |
|||
result.setData(allRoles); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
} |
@ -1,182 +0,0 @@ |
|||
package com.genersoft.iot.vmp.vmanager.user; |
|||
|
|||
import com.genersoft.iot.vmp.conf.security.SecurityUtils; |
|||
import com.genersoft.iot.vmp.conf.security.dto.LoginUser; |
|||
import com.genersoft.iot.vmp.service.IRoleService; |
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.Role; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiImplicitParam; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.security.authentication.AuthenticationManager; |
|||
import org.springframework.util.DigestUtils; |
|||
import org.springframework.util.StringUtils; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.security.sasl.AuthenticationException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.List; |
|||
|
|||
@Api(tags = "用户管理") |
|||
@CrossOrigin |
|||
@RestController |
|||
@RequestMapping("/api/user") |
|||
public class UserController { |
|||
|
|||
@Autowired |
|||
private AuthenticationManager authenticationManager; |
|||
|
|||
@Autowired |
|||
private IUserService userService; |
|||
|
|||
@Autowired |
|||
private IRoleService roleService; |
|||
|
|||
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
|
|||
@ApiOperation("登录") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "username", required = true, value = "用户名", dataTypeClass = String.class), |
|||
@ApiImplicitParam(name = "password", required = true, value = "密码(32位md5加密)", dataTypeClass = String.class), |
|||
}) |
|||
@GetMapping("/login") |
|||
public WVPResult<LoginUser> login(@RequestParam String username, @RequestParam String password){ |
|||
LoginUser user = null; |
|||
WVPResult<LoginUser> result = new WVPResult<>(); |
|||
try { |
|||
user = SecurityUtils.login(username, password, authenticationManager); |
|||
} catch (AuthenticationException e) { |
|||
e.printStackTrace(); |
|||
result.setCode(-1); |
|||
result.setMsg("fail"); |
|||
} |
|||
if (user != null) { |
|||
result.setCode(0); |
|||
result.setMsg("success"); |
|||
result.setData(user); |
|||
}else { |
|||
result.setCode(-1); |
|||
result.setMsg("fail"); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
@ApiOperation("修改密码") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "username", required = true, value = "用户名", dataTypeClass = String.class), |
|||
@ApiImplicitParam(name = "oldpassword", required = true, value = "旧密码(已md5加密的密码)", dataTypeClass = String.class), |
|||
@ApiImplicitParam(name = "password", required = true, value = "新密码(未md5加密的密码)", dataTypeClass = String.class), |
|||
}) |
|||
@PostMapping("/changePassword") |
|||
public String changePassword(@RequestParam String oldPassword, @RequestParam String password){ |
|||
// 获取当前登录用户id
|
|||
LoginUser userInfo = SecurityUtils.getUserInfo(); |
|||
if (userInfo== null) { |
|||
return "fail"; |
|||
} |
|||
String username = userInfo.getUsername(); |
|||
LoginUser user = null; |
|||
try { |
|||
user = SecurityUtils.login(username, oldPassword, authenticationManager); |
|||
if (user != null) { |
|||
int userId = SecurityUtils.getUserId(); |
|||
boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes())); |
|||
if (result) { |
|||
return "success"; |
|||
} |
|||
} |
|||
} catch (AuthenticationException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return "fail"; |
|||
} |
|||
|
|||
|
|||
@ApiOperation("添加用户") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "username", required = true, value = "用户名", dataTypeClass = String.class), |
|||
@ApiImplicitParam(name = "password", required = true, value = "密码(未md5加密的密码)", dataTypeClass = String.class), |
|||
@ApiImplicitParam(name = "roleId", required = true, value = "角色ID", dataTypeClass = String.class), |
|||
}) |
|||
@PostMapping("/add") |
|||
public ResponseEntity<WVPResult<Integer>> add(@RequestParam String username, |
|||
@RequestParam String password, |
|||
@RequestParam Integer roleId){ |
|||
WVPResult<Integer> result = new WVPResult<>(); |
|||
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || roleId == null) { |
|||
result.setCode(-1); |
|||
result.setMsg("参数不可为空"); |
|||
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST); |
|||
} |
|||
// 获取当前登录用户id
|
|||
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); |
|||
if (currenRoleId != 1) { |
|||
// 只用角色id为1才可以删除和添加用户
|
|||
result.setCode(-1); |
|||
result.setMsg("用户无权限"); |
|||
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); |
|||
} |
|||
User user = new User(); |
|||
user.setUsername(username); |
|||
user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes())); |
|||
|
|||
Role role = roleService.getRoleById(roleId); |
|||
|
|||
if (role == null) { |
|||
result.setCode(-1); |
|||
result.setMsg("roleId is not found"); |
|||
// 角色不存在
|
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
user.setRole(role); |
|||
user.setCreateTime(format.format(System.currentTimeMillis())); |
|||
user.setUpdateTime(format.format(System.currentTimeMillis())); |
|||
int addResult = userService.addUser(user); |
|||
|
|||
result.setCode(addResult > 0 ? 0 : -1); |
|||
result.setMsg(addResult > 0 ? "success" : "fail"); |
|||
result.setData(addResult); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
|
|||
@ApiOperation("删除用户") |
|||
@ApiImplicitParams({ |
|||
@ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class), |
|||
}) |
|||
@DeleteMapping("/delete") |
|||
public ResponseEntity<WVPResult<String>> delete(@RequestParam Integer id){ |
|||
// 获取当前登录用户id
|
|||
int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); |
|||
WVPResult<String> result = new WVPResult<>(); |
|||
if (currenRoleId != 1) { |
|||
// 只用角色id为0才可以删除和添加用户
|
|||
result.setCode(-1); |
|||
result.setMsg("用户无权限"); |
|||
return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); |
|||
} |
|||
int deleteResult = userService.deleteUser(id); |
|||
|
|||
result.setCode(deleteResult>0? 0 : -1); |
|||
result.setMsg(deleteResult>0? "success" : "fail"); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
|
|||
@ApiOperation("查询用户") |
|||
@ApiImplicitParams({}) |
|||
@GetMapping("/all") |
|||
public ResponseEntity<WVPResult<List<User>>> all(){ |
|||
// 获取当前登录用户id
|
|||
List<User> allUsers = userService.getAllUsers(); |
|||
WVPResult<List<User>> result = new WVPResult<>(); |
|||
result.setCode(0); |
|||
result.setMsg("success"); |
|||
result.setData(allUsers); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.genersoft.iot.vmp.vmanager.videoSquare; |
|||
|
|||
import com.genersoft.iot.vmp.common.reponse.ResponseData; |
|||
import com.genersoft.iot.vmp.service.IVideoSquareService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/square") |
|||
public class VideoSquareController { |
|||
|
|||
@Autowired |
|||
private IVideoSquareService videoSquareService; |
|||
|
|||
@GetMapping(value = "/video/tree") |
|||
@ResponseBody |
|||
public ResponseData queryVideoTree() { |
|||
return ResponseData.success(videoSquareService.selectVideoTree()); |
|||
} |
|||
} |
@ -1,25 +0,0 @@ |
|||
package com.genersoft.iot.vmp.web; |
|||
|
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@CrossOrigin |
|||
@RestController |
|||
@RequestMapping(value = "/auth") |
|||
public class AuthController { |
|||
|
|||
@Autowired |
|||
private IUserService userService; |
|||
|
|||
@RequestMapping("/login") |
|||
public String devices(String name, String passwd){ |
|||
User user = userService.getUser(name, passwd); |
|||
if (user != null) { |
|||
return "success"; |
|||
}else { |
|||
return "fail"; |
|||
} |
|||
} |
|||
} |
@ -1,3 +1,3 @@ |
|||
spring: |
|||
profiles: |
|||
active: dev |
|||
active: dev |
@ -1,58 +0,0 @@ |
|||
package com.genersoft.iot.vmp.service.impl; |
|||
|
|||
import com.genersoft.iot.vmp.service.IRoleService; |
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.Role; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.List; |
|||
|
|||
|
|||
@SpringBootTest |
|||
@RunWith(SpringRunner.class) |
|||
class RoleServiceImplTest { |
|||
|
|||
@Resource |
|||
private IRoleService roleService; |
|||
|
|||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
@org.junit.jupiter.api.Test |
|||
void getAllUser() { |
|||
List<Role> all = roleService.getAll(); |
|||
Role roleById = roleService.getRoleById(1); |
|||
System.out.println(); |
|||
|
|||
} |
|||
|
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void add() { |
|||
for (int i = 0; i < 10; i++) { |
|||
Role role = new Role(); |
|||
role.setName("test+" + i); |
|||
role.setAuthority("adadadda"); |
|||
role.setCreateTime(format.format(System.currentTimeMillis())); |
|||
role.setUpdateTime(format.format(System.currentTimeMillis())); |
|||
roleService.add(role); |
|||
} |
|||
} |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void delete() { |
|||
roleService.delete(20); |
|||
} |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void update() { |
|||
Role role = new Role(); |
|||
role.setId(21); |
|||
role.setName("TTTTTT"); |
|||
role.setAuthority("adadadda"); |
|||
roleService.update(role); |
|||
} |
|||
} |
@ -1,72 +0,0 @@ |
|||
package com.genersoft.iot.vmp.service.impl; |
|||
|
|||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; |
|||
import com.genersoft.iot.vmp.service.IDeviceAlarmService; |
|||
import com.genersoft.iot.vmp.service.IUserService; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.Role; |
|||
import com.genersoft.iot.vmp.storager.dao.dto.User; |
|||
import org.junit.runner.RunWith; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
import org.springframework.test.context.junit4.SpringRunner; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
|
|||
@SpringBootTest |
|||
@RunWith(SpringRunner.class) |
|||
class UserServiceImplTest { |
|||
|
|||
@Resource |
|||
private IUserService userService; |
|||
|
|||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void getAllUser() { |
|||
List<User> allUsers = userService.getAllUsers(); |
|||
System.out.println(userService.getAllUsers().size()); |
|||
User admin = userService.getUser("admin", "21232f297a57a5a743894a0e4a801fc3"); |
|||
User admin1 = userService.getUserByUsername("admin"); |
|||
System.out.println(12); |
|||
} |
|||
|
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void add() { |
|||
for (int i = 0; i < 10; i++) { |
|||
User user = new User(); |
|||
user.setUsername("admin_" + i); |
|||
user.setPassword("admin_password_" + i); |
|||
|
|||
Role role = new Role(); |
|||
role.setId(1); |
|||
user.setRole(role); |
|||
user.setCreateTime(format.format(System.currentTimeMillis())); |
|||
user.setUpdateTime(format.format(System.currentTimeMillis())); |
|||
userService.addUser(user); |
|||
} |
|||
} |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void delete() { |
|||
userService.deleteUser(1002); |
|||
} |
|||
|
|||
@org.junit.jupiter.api.Test |
|||
void update() { |
|||
User user = new User(); |
|||
user.setId(11); |
|||
user.setUsername("update" ); |
|||
user.setPassword("update"); |
|||
Role role = new Role(); |
|||
role.setId(2); |
|||
user.setRole(role); |
|||
user.setUpdateTime(format.format(System.currentTimeMillis())); |
|||
userService.updateUsers(user); |
|||
} |
|||
|
|||
|
|||
} |
@ -1,12 +0,0 @@ |
|||
{ |
|||
"presets": [ |
|||
["env", { |
|||
"modules": false, |
|||
"targets": { |
|||
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"] |
|||
} |
|||
}], |
|||
"stage-2" |
|||
], |
|||
"plugins": ["transform-vue-jsx", "transform-runtime"] |
|||
} |
@ -0,0 +1,3 @@ |
|||
> 1% |
|||
last 2 versions |
|||
not ie <= 10 |
@ -1,9 +1,39 @@ |
|||
root = true |
|||
|
|||
[*] |
|||
charset = utf-8 |
|||
indent_style = space |
|||
indent_size = 2 |
|||
end_of_line = lf |
|||
insert_final_newline = true |
|||
trim_trailing_whitespace = true |
|||
charset=utf-8 |
|||
end_of_line=lf |
|||
insert_final_newline=false |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[{*.ng,*.sht,*.html,*.shtm,*.shtml,*.htm}] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[{*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[{.babelrc,.stylelintrc,jest.config,.eslintrc,.prettierrc,*.json,*.jsb3,*.jsb2,*.bowerrc}] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[*.svg] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[*.js.map] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[*.less] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[*.vue] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
[{.analysis_options,*.yml,*.yaml}] |
|||
indent_style=space |
|||
indent_size=2 |
|||
|
|||
|
@ -0,0 +1,3 @@ |
|||
NODE_ENV=production |
|||
VUE_APP_PREVIEW=false |
|||
VUE_APP_API_BASE_URL=/ |
@ -0,0 +1,3 @@ |
|||
NODE_ENV=development |
|||
VUE_APP_PREVIEW=true |
|||
VUE_APP_API_BASE_URL=/debug |
@ -0,0 +1,3 @@ |
|||
NODE_ENV=production |
|||
VUE_APP_PREVIEW=true |
|||
VUE_APP_API_BASE_URL=/debug |
@ -0,0 +1 @@ |
|||
public/* linguist-vendored |
@ -1,14 +0,0 @@ |
|||
// https://github.com/michael-ciniawsky/postcss-load-config
|
|||
|
|||
module.exports = { |
|||
"plugins": { |
|||
"postcss-import": {}, |
|||
"postcss-url": {}, |
|||
// to edit target browsers: use "browserslist" field in package.json
|
|||
"autoprefixer": {}, |
|||
'postcss-pxtorem': { |
|||
rootValue: 16, |
|||
propList: ['font-size'] // 只转化font-size
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,6 @@ |
|||
{ |
|||
"printWidth": 120, |
|||
"semi": false, |
|||
"singleQuote": true, |
|||
"prettier.spaceBeforeFunctionParen": true |
|||
} |
@ -0,0 +1,7 @@ |
|||
language: node_js |
|||
node_js: |
|||
- 10.15.0 |
|||
cache: yarn |
|||
script: |
|||
- yarn |
|||
- yarn run lint --no-fix && yarn run build |
@ -0,0 +1,6 @@ |
|||
FROM nginx |
|||
|
|||
RUN rm /etc/nginx/conf.d/default.conf |
|||
|
|||
ADD deploy/nginx.conf /etc/nginx/conf.d/default.conf |
|||
COPY dist/ /usr/share/nginx/html/ |
@ -0,0 +1,21 @@ |
|||
MIT License |
|||
|
|||
Copyright (c) 2018 Anan Yang |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
@ -1,21 +1 @@ |
|||
# gb_web |
|||
|
|||
> A Vue.js project |
|||
|
|||
## Build Setup |
|||
|
|||
``` bash |
|||
# install dependencies |
|||
npm install |
|||
|
|||
# serve with hot reload at localhost:8080 |
|||
npm run dev |
|||
|
|||
# build for production with minification |
|||
npm run build |
|||
|
|||
# build for production and view the bundle analyzer report |
|||
npm run build --report |
|||
``` |
|||
|
|||
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). |
|||
WVP视频平台ant-design风格前端 |
@ -0,0 +1,30 @@ |
|||
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV) |
|||
const IS_PREVIEW = process.env.VUE_APP_PREVIEW === 'true' |
|||
|
|||
const plugins = [] |
|||
if (IS_PROD && !IS_PREVIEW) { |
|||
// 去除日志的插件,
|
|||
plugins.push('transform-remove-console') |
|||
} |
|||
|
|||
// lazy load ant-design-vue
|
|||
// if your use import on Demand, Use this code
|
|||
plugins.push(['import', { |
|||
'libraryName': 'ant-design-vue', |
|||
'libraryDirectory': 'es', |
|||
'style': true // `style: true` 会加载 less 文件
|
|||
}]) |
|||
|
|||
module.exports = { |
|||
presets: [ |
|||
'@vue/cli-plugin-babel/preset', |
|||
[ |
|||
'@babel/preset-env', |
|||
{ |
|||
'useBuiltIns': 'entry', |
|||
'corejs': 3 |
|||
} |
|||
] |
|||
], |
|||
plugins |
|||
} |
@ -1,41 +0,0 @@ |
|||
'use strict' |
|||
require('./check-versions')() |
|||
|
|||
process.env.NODE_ENV = 'production' |
|||
|
|||
const ora = require('ora') |
|||
const rm = require('rimraf') |
|||
const path = require('path') |
|||
const chalk = require('chalk') |
|||
const webpack = require('webpack') |
|||
const config = require('../config') |
|||
const webpackConfig = require('./webpack.prod.conf') |
|||
|
|||
const spinner = ora('building for production...') |
|||
spinner.start() |
|||
|
|||
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => { |
|||
if (err) throw err |
|||
webpack(webpackConfig, (err, stats) => { |
|||
spinner.stop() |
|||
if (err) throw err |
|||
process.stdout.write(stats.toString({ |
|||
colors: true, |
|||
modules: false, |
|||
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
|
|||
chunks: false, |
|||
chunkModules: false |
|||
}) + '\n\n') |
|||
|
|||
if (stats.hasErrors()) { |
|||
console.log(chalk.red(' Build failed with errors.\n')) |
|||
process.exit(1) |
|||
} |
|||
|
|||
console.log(chalk.cyan(' Build complete.\n')) |
|||
console.log(chalk.yellow( |
|||
' Tip: built files are meant to be served over an HTTP server.\n' + |
|||
' Opening index.html over file:// won\'t work.\n' |
|||
)) |
|||
}) |
|||
}) |
@ -1,54 +0,0 @@ |
|||
'use strict' |
|||
const chalk = require('chalk') |
|||
const semver = require('semver') |
|||
const packageConfig = require('../package.json') |
|||
const shell = require('shelljs') |
|||
|
|||
function exec (cmd) { |
|||
return require('child_process').execSync(cmd).toString().trim() |
|||
} |
|||
|
|||
const versionRequirements = [ |
|||
{ |
|||
name: 'node', |
|||
currentVersion: semver.clean(process.version), |
|||
versionRequirement: packageConfig.engines.node |
|||
} |
|||
] |
|||
|
|||
if (shell.which('npm')) { |
|||
versionRequirements.push({ |
|||
name: 'npm', |
|||
currentVersion: exec('npm --version'), |
|||
versionRequirement: packageConfig.engines.npm |
|||
}) |
|||
} |
|||
|
|||
module.exports = function () { |
|||
const warnings = [] |
|||
|
|||
for (let i = 0; i < versionRequirements.length; i++) { |
|||
const mod = versionRequirements[i] |
|||
|
|||
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { |
|||
warnings.push(mod.name + ': ' + |
|||
chalk.red(mod.currentVersion) + ' should be ' + |
|||
chalk.green(mod.versionRequirement) |
|||
) |
|||
} |
|||
} |
|||
|
|||
if (warnings.length) { |
|||
console.log('') |
|||
console.log(chalk.yellow('To use this template, you must update following to modules:')) |
|||
console.log() |
|||
|
|||
for (let i = 0; i < warnings.length; i++) { |
|||
const warning = warnings[i] |
|||
console.log(' ' + warning) |
|||
} |
|||
|
|||
console.log() |
|||
process.exit(1) |
|||
} |
|||
} |
Before Width: | Height: | Size: 6.7 KiB |
@ -1,101 +0,0 @@ |
|||
'use strict' |
|||
const path = require('path') |
|||
const config = require('../config') |
|||
const ExtractTextPlugin = require('extract-text-webpack-plugin') |
|||
const packageConfig = require('../package.json') |
|||
|
|||
exports.assetsPath = function (_path) { |
|||
const assetsSubDirectory = process.env.NODE_ENV === 'production' |
|||
? config.build.assetsSubDirectory |
|||
: config.dev.assetsSubDirectory |
|||
|
|||
return path.posix.join(assetsSubDirectory, _path) |
|||
} |
|||
|
|||
exports.cssLoaders = function (options) { |
|||
options = options || {} |
|||
|
|||
const cssLoader = { |
|||
loader: 'css-loader', |
|||
options: { |
|||
sourceMap: options.sourceMap |
|||
} |
|||
} |
|||
|
|||
const postcssLoader = { |
|||
loader: 'postcss-loader', |
|||
options: { |
|||
sourceMap: options.sourceMap |
|||
} |
|||
} |
|||
|
|||
// generate loader string to be used with extract text plugin
|
|||
function generateLoaders (loader, loaderOptions) { |
|||
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader] |
|||
|
|||
if (loader) { |
|||
loaders.push({ |
|||
loader: loader + '-loader', |
|||
options: Object.assign({}, loaderOptions, { |
|||
sourceMap: options.sourceMap |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
// Extract CSS when that option is specified
|
|||
// (which is the case during production build)
|
|||
if (options.extract) { |
|||
return ExtractTextPlugin.extract({ |
|||
use: loaders, |
|||
fallback: 'vue-style-loader' |
|||
}) |
|||
} else { |
|||
return ['vue-style-loader'].concat(loaders) |
|||
} |
|||
} |
|||
|
|||
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
|
|||
return { |
|||
css: generateLoaders(), |
|||
postcss: generateLoaders(), |
|||
less: generateLoaders('less'), |
|||
sass: generateLoaders('sass', { indentedSyntax: true }), |
|||
scss: generateLoaders('sass'), |
|||
stylus: generateLoaders('stylus'), |
|||
styl: generateLoaders('stylus') |
|||
} |
|||
} |
|||
|
|||
// Generate loaders for standalone style files (outside of .vue)
|
|||
exports.styleLoaders = function (options) { |
|||
const output = [] |
|||
const loaders = exports.cssLoaders(options) |
|||
|
|||
for (const extension in loaders) { |
|||
const loader = loaders[extension] |
|||
output.push({ |
|||
test: new RegExp('\\.' + extension + '$'), |
|||
use: loader |
|||
}) |
|||
} |
|||
|
|||
return output |
|||
} |
|||
|
|||
exports.createNotifierCallback = () => { |
|||
const notifier = require('node-notifier') |
|||
|
|||
return (severity, errors) => { |
|||
if (severity !== 'error') return |
|||
|
|||
const error = errors[0] |
|||
const filename = error.file && error.file.split('!').pop() |
|||
|
|||
notifier.notify({ |
|||
title: packageConfig.name, |
|||
message: severity + ': ' + error.name, |
|||
subtitle: filename || '', |
|||
icon: path.join(__dirname, 'logo.png') |
|||
}) |
|||
} |
|||
} |
@ -1,22 +0,0 @@ |
|||
'use strict' |
|||
const utils = require('./utils') |
|||
const config = require('../config') |
|||
const isProduction = process.env.NODE_ENV === 'production' |
|||
const sourceMapEnabled = isProduction |
|||
? config.build.productionSourceMap |
|||
: config.dev.cssSourceMap |
|||
|
|||
module.exports = { |
|||
loaders: utils.cssLoaders({ |
|||
sourceMap: sourceMapEnabled, |
|||
extract: isProduction |
|||
}), |
|||
cssSourceMap: sourceMapEnabled, |
|||
cacheBusting: config.dev.cacheBusting, |
|||
transformToRequire: { |
|||
video: ['src', 'poster'], |
|||
source: 'src', |
|||
img: 'src', |
|||
image: 'xlink:href' |
|||
} |
|||
} |
@ -1,83 +0,0 @@ |
|||
'use strict' |
|||
const path = require('path') |
|||
const utils = require('./utils') |
|||
const config = require('../config') |
|||
const vueLoaderConfig = require('./vue-loader.conf') |
|||
|
|||
function resolve (dir) { |
|||
return path.join(__dirname, '..', dir) |
|||
} |
|||
|
|||
|
|||
|
|||
module.exports = { |
|||
context: path.resolve(__dirname, '../'), |
|||
entry: { |
|||
app: './src/main.js' |
|||
}, |
|||
output: { |
|||
path: config.build.assetsRoot, |
|||
filename: '[name].js', |
|||
publicPath: process.env.NODE_ENV === 'production' |
|||
? config.build.assetsPublicPath |
|||
: config.dev.assetsPublicPath |
|||
}, |
|||
resolve: { |
|||
extensions: ['.js', '.vue', '.json'], |
|||
alias: { |
|||
'vue$': 'vue/dist/vue.esm.js', |
|||
'@': resolve('src'), |
|||
'@static': resolve('static'), |
|||
} |
|||
}, |
|||
module: { |
|||
rules: [ |
|||
{ |
|||
test: /\.vue$/, |
|||
loader: 'vue-loader', |
|||
options: vueLoaderConfig |
|||
}, |
|||
{ |
|||
test: /\.js$/, |
|||
loader: 'babel-loader', |
|||
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] |
|||
}, |
|||
{ |
|||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, |
|||
loader: 'url-loader', |
|||
options: { |
|||
limit: 10000, |
|||
name: utils.assetsPath('img/[name].[hash:7].[ext]') |
|||
} |
|||
}, |
|||
{ |
|||
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, |
|||
loader: 'url-loader', |
|||
options: { |
|||
limit: 10000, |
|||
name: utils.assetsPath('media/[name].[hash:7].[ext]') |
|||
} |
|||
}, |
|||
{ |
|||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, |
|||
loader: 'url-loader', |
|||
options: { |
|||
limit: 10000, |
|||
name: utils.assetsPath('fonts/[name].[hash:7].[ext]') |
|||
} |
|||
} |
|||
] |
|||
}, |
|||
node: { |
|||
// prevent webpack from injecting useless setImmediate polyfill because Vue
|
|||
// source contains it (although only uses it if it's native).
|
|||
setImmediate: false, |
|||
// prevent webpack from injecting mocks to Node native modules
|
|||
// that does not make sense for the client
|
|||
dgram: 'empty', |
|||
fs: 'empty', |
|||
net: 'empty', |
|||
tls: 'empty', |
|||
child_process: 'empty' |
|||
} |
|||
} |
@ -1,95 +0,0 @@ |
|||
'use strict' |
|||
const utils = require('./utils') |
|||
const webpack = require('webpack') |
|||
const config = require('../config') |
|||
const merge = require('webpack-merge') |
|||
const path = require('path') |
|||
const baseWebpackConfig = require('./webpack.base.conf') |
|||
const CopyWebpackPlugin = require('copy-webpack-plugin') |
|||
const HtmlWebpackPlugin = require('html-webpack-plugin') |
|||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') |
|||
const portfinder = require('portfinder') |
|||
|
|||
const HOST = process.env.HOST |
|||
const PORT = process.env.PORT && Number(process.env.PORT) |
|||
|
|||
const devWebpackConfig = merge(baseWebpackConfig, { |
|||
module: { |
|||
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true }) |
|||
}, |
|||
// cheap-module-eval-source-map is faster for development
|
|||
devtool: config.dev.devtool, |
|||
|
|||
// these devServer options should be customized in /config/index.js
|
|||
devServer: { |
|||
clientLogLevel: 'warning', |
|||
historyApiFallback: { |
|||
rewrites: [ |
|||
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') }, |
|||
], |
|||
}, |
|||
hot: true, |
|||
contentBase: false, // since we use CopyWebpackPlugin.
|
|||
compress: true, |
|||
host: HOST || config.dev.host, |
|||
port: PORT || config.dev.port, |
|||
open: config.dev.autoOpenBrowser, |
|||
overlay: config.dev.errorOverlay |
|||
? { warnings: false, errors: true } |
|||
: false, |
|||
publicPath: config.dev.assetsPublicPath, |
|||
proxy: config.dev.proxyTable, |
|||
quiet: true, // necessary for FriendlyErrorsPlugin
|
|||
watchOptions: { |
|||
poll: config.dev.poll, |
|||
} |
|||
}, |
|||
plugins: [ |
|||
new webpack.DefinePlugin({ |
|||
'process.env': require('../config/dev.env') |
|||
}), |
|||
new webpack.HotModuleReplacementPlugin(), |
|||
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
|
|||
new webpack.NoEmitOnErrorsPlugin(), |
|||
// https://github.com/ampedandwired/html-webpack-plugin
|
|||
new HtmlWebpackPlugin({ |
|||
filename: 'index.html', |
|||
template: 'index.html', |
|||
inject: true |
|||
}), |
|||
// copy custom static assets
|
|||
new CopyWebpackPlugin([ |
|||
{ |
|||
from: path.resolve(__dirname, '../static'), |
|||
to: config.dev.assetsSubDirectory, |
|||
ignore: ['.*'] |
|||
} |
|||
]) |
|||
] |
|||
}) |
|||
|
|||
module.exports = new Promise((resolve, reject) => { |
|||
portfinder.basePort = process.env.PORT || config.dev.port |
|||
portfinder.getPort((err, port) => { |
|||
if (err) { |
|||
reject(err) |
|||
} else { |
|||
// publish the new Port, necessary for e2e tests
|
|||
process.env.PORT = port |
|||
// add port to devServer config
|
|||
devWebpackConfig.devServer.port = port |
|||
|
|||
// Add FriendlyErrorsPlugin
|
|||
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({ |
|||
compilationSuccessInfo: { |
|||
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`], |
|||
}, |
|||
onErrors: config.dev.notifyOnErrors |
|||
? utils.createNotifierCallback() |
|||
: undefined |
|||
})) |
|||
|
|||
resolve(devWebpackConfig) |
|||
} |
|||
}) |
|||
}) |
@ -1,145 +0,0 @@ |
|||
'use strict' |
|||
const path = require('path') |
|||
const utils = require('./utils') |
|||
const webpack = require('webpack') |
|||
const config = require('../config') |
|||
const merge = require('webpack-merge') |
|||
const baseWebpackConfig = require('./webpack.base.conf') |
|||
const CopyWebpackPlugin = require('copy-webpack-plugin') |
|||
const HtmlWebpackPlugin = require('html-webpack-plugin') |
|||
const ExtractTextPlugin = require('extract-text-webpack-plugin') |
|||
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') |
|||
const UglifyJsPlugin = require('uglifyjs-webpack-plugin') |
|||
|
|||
const env = require('../config/prod.env') |
|||
|
|||
const webpackConfig = merge(baseWebpackConfig, { |
|||
module: { |
|||
rules: utils.styleLoaders({ |
|||
sourceMap: config.build.productionSourceMap, |
|||
extract: true, |
|||
usePostCSS: true |
|||
}) |
|||
}, |
|||
devtool: config.build.productionSourceMap ? config.build.devtool : false, |
|||
output: { |
|||
path: config.build.assetsRoot, |
|||
filename: utils.assetsPath('js/[name].[chunkhash].js'), |
|||
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') |
|||
}, |
|||
plugins: [ |
|||
// http://vuejs.github.io/vue-loader/en/workflow/production.html
|
|||
new webpack.DefinePlugin({ |
|||
'process.env': env |
|||
}), |
|||
new UglifyJsPlugin({ |
|||
uglifyOptions: { |
|||
compress: { |
|||
warnings: false |
|||
} |
|||
}, |
|||
sourceMap: config.build.productionSourceMap, |
|||
parallel: true |
|||
}), |
|||
// extract css into its own file
|
|||
new ExtractTextPlugin({ |
|||
filename: utils.assetsPath('css/[name].[contenthash].css'), |
|||
// Setting the following option to `false` will not extract CSS from codesplit chunks.
|
|||
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
|
|||
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
|
|||
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
|
|||
allChunks: true, |
|||
}), |
|||
// Compress extracted CSS. We are using this plugin so that possible
|
|||
// duplicated CSS from different components can be deduped.
|
|||
new OptimizeCSSPlugin({ |
|||
cssProcessorOptions: config.build.productionSourceMap |
|||
? { safe: true, map: { inline: false } } |
|||
: { safe: true } |
|||
}), |
|||
// generate dist index.html with correct asset hash for caching.
|
|||
// you can customize output by editing /index.html
|
|||
// see https://github.com/ampedandwired/html-webpack-plugin
|
|||
new HtmlWebpackPlugin({ |
|||
filename: config.build.index, |
|||
template: 'index.html', |
|||
inject: true, |
|||
minify: { |
|||
removeComments: true, |
|||
collapseWhitespace: true, |
|||
removeAttributeQuotes: true |
|||
// more options:
|
|||
// https://github.com/kangax/html-minifier#options-quick-reference
|
|||
}, |
|||
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
|
|||
chunksSortMode: 'dependency' |
|||
}), |
|||
// keep module.id stable when vendor modules does not change
|
|||
new webpack.HashedModuleIdsPlugin(), |
|||
// enable scope hoisting
|
|||
new webpack.optimize.ModuleConcatenationPlugin(), |
|||
// split vendor js into its own file
|
|||
new webpack.optimize.CommonsChunkPlugin({ |
|||
name: 'vendor', |
|||
minChunks (module) { |
|||
// any required modules inside node_modules are extracted to vendor
|
|||
return ( |
|||
module.resource && |
|||
/\.js$/.test(module.resource) && |
|||
module.resource.indexOf( |
|||
path.join(__dirname, '../node_modules') |
|||
) === 0 |
|||
) |
|||
} |
|||
}), |
|||
// extract webpack runtime and module manifest to its own file in order to
|
|||
// prevent vendor hash from being updated whenever app bundle is updated
|
|||
new webpack.optimize.CommonsChunkPlugin({ |
|||
name: 'manifest', |
|||
minChunks: Infinity |
|||
}), |
|||
// This instance extracts shared chunks from code splitted chunks and bundles them
|
|||
// in a separate chunk, similar to the vendor chunk
|
|||
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
|
|||
new webpack.optimize.CommonsChunkPlugin({ |
|||
name: 'app', |
|||
async: 'vendor-async', |
|||
children: true, |
|||
minChunks: 3 |
|||
}), |
|||
|
|||
// copy custom static assets
|
|||
new CopyWebpackPlugin([ |
|||
{ |
|||
from: path.resolve(__dirname, '../static'), |
|||
to: config.build.assetsSubDirectory, |
|||
ignore: ['.*'] |
|||
} |
|||
]) |
|||
] |
|||
}) |
|||
|
|||
if (config.build.productionGzip) { |
|||
const CompressionWebpackPlugin = require('compression-webpack-plugin') |
|||
|
|||
webpackConfig.plugins.push( |
|||
new CompressionWebpackPlugin({ |
|||
asset: '[path].gz[query]', |
|||
algorithm: 'gzip', |
|||
test: new RegExp( |
|||
'\\.(' + |
|||
config.build.productionGzipExtensions.join('|') + |
|||
')$' |
|||
), |
|||
threshold: 10240, |
|||
minRatio: 0.8 |
|||
}) |
|||
) |
|||
} |
|||
|
|||
if (config.build.bundleAnalyzerReport) { |
|||
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin |
|||
webpackConfig.plugins.push(new BundleAnalyzerPlugin()) |
|||
} |
|||
|
|||
module.exports = webpackConfig |
@ -1,8 +0,0 @@ |
|||
'use strict' |
|||
const merge = require('webpack-merge') |
|||
const prodEnv = require('./prod.env') |
|||
|
|||
module.exports = merge(prodEnv, { |
|||
NODE_ENV: '"development"', |
|||
BASE_API: '"/debug"' |
|||
}) |
@ -1,85 +0,0 @@ |
|||
'use strict' |
|||
// Template version: 1.3.1
|
|||
// see http://vuejs-templates.github.io/webpack for documentation.
|
|||
|
|||
const path = require('path') |
|||
|
|||
module.exports = { |
|||
dev: { |
|||
|
|||
// Paths
|
|||
assetsSubDirectory: 'static', |
|||
assetsPublicPath: '/', |
|||
proxyTable: { |
|||
'/debug': { |
|||
target: 'http://localhost:18080', |
|||
changeOrigin: true, |
|||
pathRewrite: { |
|||
'^/debug': '/' |
|||
} |
|||
}, |
|||
'/static/snap': { |
|||
target: 'http://localhost:18080', |
|||
changeOrigin: true, |
|||
// pathRewrite: {
|
|||
// '^/static/snap': '/static/snap'
|
|||
// }
|
|||
}, |
|||
|
|||
}, |
|||
|
|||
// Various Dev Server settings
|
|||
host: 'localhost', // can be overwritten by process.env.HOST
|
|||
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
|
|||
autoOpenBrowser: false, |
|||
errorOverlay: true, |
|||
notifyOnErrors: true, |
|||
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
|
|||
|
|||
|
|||
/** |
|||
* Source Maps |
|||
*/ |
|||
|
|||
// https://webpack.js.org/configuration/devtool/#development
|
|||
devtool: 'cheap-module-eval-source-map', |
|||
|
|||
// If you have problems debugging vue-files in devtools,
|
|||
// set this to false - it *may* help
|
|||
// https://vue-loader.vuejs.org/en/options.html#cachebusting
|
|||
cacheBusting: true, |
|||
|
|||
cssSourceMap: true |
|||
}, |
|||
|
|||
build: { |
|||
// Template for index.html
|
|||
index: path.resolve(__dirname, '../../src/main/resources/static/index.html'), |
|||
|
|||
// Paths
|
|||
assetsRoot: path.resolve(__dirname, '../../src/main/resources/static/'), |
|||
assetsSubDirectory: './static', |
|||
assetsPublicPath: '/', |
|||
|
|||
/** |
|||
* Source Maps |
|||
*/ |
|||
|
|||
productionSourceMap: true, |
|||
// https://webpack.js.org/configuration/devtool/#production
|
|||
devtool: '#source-map', |
|||
|
|||
// Gzip off by default as many popular static hosts such as
|
|||
// Surge or Netlify already gzip all static assets for you.
|
|||
// Before setting to `true`, make sure to:
|
|||
// npm install --save-dev compression-webpack-plugin
|
|||
productionGzip: false, |
|||
productionGzipExtensions: ['js', 'css'], |
|||
|
|||
// Run the build command with an extra argument to
|
|||
// View the bundle analyzer report after build finishes:
|
|||
// `npm run build --report`
|
|||
// Set to `true` or `false` to always turn it on or off
|
|||
bundleAnalyzerReport: process.env.npm_config_report |
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
const ThemeColorReplacer = require('webpack-theme-color-replacer') |
|||
const generate = require('@ant-design/colors/lib/generate').default |
|||
|
|||
const getAntdSerials = (color) => { |
|||
// 淡化(即less的tint)
|
|||
const lightens = new Array(9).fill().map((t, i) => { |
|||
return ThemeColorReplacer.varyColor.lighten(color, i / 10) |
|||
}) |
|||
const colorPalettes = generate(color) |
|||
const rgb = ThemeColorReplacer.varyColor.toNum3(color.replace('#', '')).join(',') |
|||
return lightens.concat(colorPalettes).concat(rgb) |
|||
} |
|||
|
|||
const themePluginOption = { |
|||
fileName: 'css/theme-colors-[contenthash:8].css', |
|||
matchColors: getAntdSerials('#1890ff'), // 主色系列
|
|||
// 改变样式选择器,解决样式覆盖问题
|
|||
changeSelector (selector) { |
|||
switch (selector) { |
|||
case '.ant-calendar-today .ant-calendar-date': |
|||
return ':not(.ant-calendar-selected-date):not(.ant-calendar-selected-day)' + selector |
|||
case '.ant-btn:focus,.ant-btn:hover': |
|||
return '.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger),.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger)' |
|||
case '.ant-btn.active,.ant-btn:active': |
|||
return '.ant-btn.active:not(.ant-btn-primary):not(.ant-btn-danger),.ant-btn:active:not(.ant-btn-primary):not(.ant-btn-danger)' |
|||
case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon': |
|||
case '.ant-steps-item-process .ant-steps-item-icon>.ant-steps-icon': |
|||
return ':not(.ant-steps-item-process)' + selector |
|||
// fixed https://github.com/vueComponent/ant-design-vue-pro/issues/876
|
|||
case '.ant-steps-item-process .ant-steps-item-icon': |
|||
return ':not(.ant-steps-item-custom)' + selector |
|||
case '.ant-menu-horizontal>.ant-menu-item-active,.ant-menu-horizontal>.ant-menu-item-open,.ant-menu-horizontal>.ant-menu-item-selected,.ant-menu-horizontal>.ant-menu-item:hover,.ant-menu-horizontal>.ant-menu-submenu-active,.ant-menu-horizontal>.ant-menu-submenu-open,.ant-menu-horizontal>.ant-menu-submenu-selected,.ant-menu-horizontal>.ant-menu-submenu:hover': |
|||
case '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal > .ant-menu-submenu-selected,.ant-menu-horizontal > .ant-menu-submenu:hover': |
|||
return '.ant-menu-horizontal > .ant-menu-item-active,.ant-menu-horizontal > .ant-menu-item-open,.ant-menu-horizontal > .ant-menu-item-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-item:hover,.ant-menu-horizontal > .ant-menu-submenu-active,.ant-menu-horizontal > .ant-menu-submenu-open,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu-selected,.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu:hover' |
|||
case '.ant-menu-horizontal > .ant-menu-item-selected > a': |
|||
case '.ant-menu-horizontal>.ant-menu-item-selected>a': |
|||
return '.ant-menu-horizontal:not(ant-menu-light):not(.ant-menu-dark) > .ant-menu-item-selected > a' |
|||
case '.ant-menu-horizontal > .ant-menu-item > a:hover': |
|||
case '.ant-menu-horizontal>.ant-menu-item>a:hover': |
|||
return '.ant-menu-horizontal:not(ant-menu-light):not(.ant-menu-dark) > .ant-menu-item > a:hover' |
|||
default : |
|||
return selector |
|||
} |
|||
} |
|||
} |
|||
|
|||
const createThemeColorReplacerPlugin = () => new ThemeColorReplacer(themePluginOption) |
|||
|
|||
module.exports = createThemeColorReplacerPlugin |
@ -1,4 +0,0 @@ |
|||
'use strict' |
|||
module.exports = { |
|||
NODE_ENV: '"production"' |
|||
} |
@ -0,0 +1,115 @@ |
|||
export default { |
|||
theme: [ |
|||
{ |
|||
key: 'dark', |
|||
fileName: 'dark.css', |
|||
theme: 'dark' |
|||
}, |
|||
{ |
|||
key: '#F5222D', |
|||
fileName: '#F5222D.css', |
|||
modifyVars: { |
|||
'@primary-color': '#F5222D' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#FA541C', |
|||
fileName: '#FA541C.css', |
|||
modifyVars: { |
|||
'@primary-color': '#FA541C' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#FAAD14', |
|||
fileName: '#FAAD14.css', |
|||
modifyVars: { |
|||
'@primary-color': '#FAAD14' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#13C2C2', |
|||
fileName: '#13C2C2.css', |
|||
modifyVars: { |
|||
'@primary-color': '#13C2C2' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#52C41A', |
|||
fileName: '#52C41A.css', |
|||
modifyVars: { |
|||
'@primary-color': '#52C41A' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#2F54EB', |
|||
fileName: '#2F54EB.css', |
|||
modifyVars: { |
|||
'@primary-color': '#2F54EB' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#722ED1', |
|||
fileName: '#722ED1.css', |
|||
modifyVars: { |
|||
'@primary-color': '#722ED1' |
|||
} |
|||
}, |
|||
|
|||
{ |
|||
key: '#F5222D', |
|||
theme: 'dark', |
|||
fileName: 'dark-#F5222D.css', |
|||
modifyVars: { |
|||
'@primary-color': '#F5222D' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#FA541C', |
|||
theme: 'dark', |
|||
fileName: 'dark-#FA541C.css', |
|||
modifyVars: { |
|||
'@primary-color': '#FA541C' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#FAAD14', |
|||
theme: 'dark', |
|||
fileName: 'dark-#FAAD14.css', |
|||
modifyVars: { |
|||
'@primary-color': '#FAAD14' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#13C2C2', |
|||
theme: 'dark', |
|||
fileName: 'dark-#13C2C2.css', |
|||
modifyVars: { |
|||
'@primary-color': '#13C2C2' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#52C41A', |
|||
theme: 'dark', |
|||
fileName: 'dark-#52C41A.css', |
|||
modifyVars: { |
|||
'@primary-color': '#52C41A' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#2F54EB', |
|||
theme: 'dark', |
|||
fileName: 'dark-#2F54EB.css', |
|||
modifyVars: { |
|||
'@primary-color': '#2F54EB' |
|||
} |
|||
}, |
|||
{ |
|||
key: '#722ED1', |
|||
theme: 'dark', |
|||
fileName: 'dark-#722ED1.css', |
|||
modifyVars: { |
|||
'@primary-color': '#722ED1' |
|||
} |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,9 @@ |
|||
0.0.0.0:80 { |
|||
gzip |
|||
root /usr/share/nginx/html |
|||
|
|||
rewrite { |
|||
r .* |
|||
to {path} / |
|||
} |
|||
} |
@ -0,0 +1,24 @@ |
|||
server { |
|||
listen 80; |
|||
server_name _; |
|||
# gzip config |
|||
gzip on; |
|||
gzip_min_length 1k; |
|||
gzip_comp_level 6; |
|||
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; |
|||
gzip_vary on; |
|||
gzip_disable "MSIE [1-6]\."; |
|||
|
|||
root /usr/share/nginx/html; |
|||
include /etc/nginx/mime.types; |
|||
|
|||
location / { |
|||
try_files $uri $uri/ /index.html; |
|||
} |
|||
|
|||
# location /api { |
|||
# proxy_pass https://preview.pro.antdv.com/api; |
|||
# proxy_set_header X-Forwarded-Proto $scheme; |
|||
# proxy_set_header X-Real-IP $remote_addr; |
|||
# } |
|||
} |
@ -1,18 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> |
|||
<title>国标28181</title> |
|||
<link rel="stylesheet" type="text/css" href="./static/css/iconfont.css"> |
|||
<link rel="stylesheet" type="text/css" href="./static/css/login.css"> |
|||
</head> |
|||
<body> |
|||
<script type="text/javascript" src="./static/js/jessibuca/index.js"></script> |
|||
<script type="text/javascript" src="./static/js/EasyWasmPlayer.js"></script> |
|||
<script type="text/javascript" src="./static/js/ZLMRTCClient.js"></script> |
|||
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=rk73w8dv1rkE4UdZsataG68VarhYQzrx&s=1"></script> |
|||
<div id="app"></div> |
|||
<!-- built files will be auto injected --> |
|||
</body> |
|||
</html> |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue