feat(微服务迁移-wiki):服务迁移及代码优化

This commit is contained in:
wanjia 2024-01-12 15:20:26 +08:00
parent ce5ce7c17d
commit fe7c81abbb
65 changed files with 6305 additions and 0 deletions

View File

@ -16,6 +16,7 @@
<module>ruoyi-cms</module>
<module>ruoyi-zone</module>
<module>ruoyi-pms</module>
<module>ruoyi-wiki</module>
</modules>
<artifactId>ruoyi-modules</artifactId>

View File

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ruoyi-modules</artifactId>
<groupId>com.ruoyi</groupId>
<version>3.6.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-wiki</artifactId>
<dependencies>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Swagger UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.fox.version}</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- RuoYi Common Async -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-async</artifactId>
</dependency>
<!-- RuoYi Common DataSource -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datasource</artifactId>
</dependency>
<!-- RuoYi Common DataScope -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-datascope</artifactId>
</dependency>
<!-- RuoYi Common Log -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-log</artifactId>
</dependency>
<!-- RuoYi Common Swagger -->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-core</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- mybatis-plus begin -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.5.5</version>
</dependency>
<!-- mybatis-plus end -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.24</version>
</dependency>
<dependency>
<groupId>com.github.jhonnymertz</groupId>
<artifactId>java-wkhtmltopdf-wrapper</artifactId>
<version>1.1.13-RELEASE</version>
</dependency>
<!-- 处理访问Gitlink相关接口 -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-httpClient</artifactId>
<version>3.6.2</version>
<scope>compile</scope>
</dependency>
<!-- render markdown to html -->
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>0.64.8</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,24 @@
package com.ruoyi.wiki;
import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
//@EnableDiscoveryClient
@EnableCustomConfig
@EnableCustomSwagger2
@EnableRyFeignClients
@SpringBootApplication
public class WikiApiApplication {
public static void main(String[] args) {
SpringApplication.run(WikiApiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 项目管理模块启动成功 ლ(´ڡ`ლ)゙ \n");
}
}

View File

@ -0,0 +1,84 @@
package com.ruoyi.wiki.config;
import cn.hutool.core.exceptions.ValidateException;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.wiki.refactoring.enums.ResponseEnum;
import com.ruoyi.wiki.refactoring.exception.BusiException;
import com.ruoyi.wiki.refactoring.utils.ValidatorUtils;
import javassist.NotFoundException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.validation.BindException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
@ControllerAdvice
public class ExceptionInterceptor {
private static final Logger logger = LoggerFactory.getLogger(ExceptionInterceptor.class);
private static String logTemplate = "request page url{}, error:{}";
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({IllegalArgumentException.class})
public AjaxResult handle(HttpServletRequest request, IllegalArgumentException e) {
logger.error(logTemplate, request.getRequestURI(), e.getMessage());
return AjaxResult.error(e.getMessage());
}
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({MethodArgumentNotValidException.class})
public AjaxResult handle(HttpServletRequest request, MethodArgumentNotValidException e) {
logger.error(logTemplate, request.getRequestURI(), e);
return AjaxResult.error(ValidatorUtils.buildValidationdErrorMessage(e.getBindingResult()));
}
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({BindException.class})
public AjaxResult handle(HttpServletRequest request, BindException e) {
logger.error(logTemplate, request.getRequestURI(), e);
return AjaxResult.error(ValidatorUtils.buildValidationdErrorMessage(e.getBindingResult()));
}
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({BusiException.class})
public AjaxResult handle(HttpServletRequest request, BusiException e) {
logger.error(logTemplate, request.getRequestURI(), e);
return AjaxResult.error(e.getMessage());
}
@ResponseBody
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({Exception.class})
public AjaxResult handle(HttpServletRequest request, Exception e) {
logger.error(e.toString() + "\n" + StringUtils.join(e.getStackTrace(), "\n"));
return AjaxResult.error(ResponseEnum.SYS_ERROR.getValue());
}
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler({ValidateException.class})
public AjaxResult handle(HttpServletRequest request, ValidateException e) {
return AjaxResult.error(ResponseEnum.BAD_REQUEST.getValue());
}
@ResponseBody
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler({NotFoundException.class})
public AjaxResult handle(HttpServletRequest request, NotFoundException e) {
logger.error(e.toString() + "\n" + StringUtils.join(e.getStackTrace(), "\n"));
return AjaxResult.error(ResponseEnum.NOT_FOUND.getValue());
}
}

View File

@ -0,0 +1,43 @@
package com.ruoyi.wiki.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.ruoyi.wiki.handler.MetaHandler;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableTransactionManagement
@Configuration
@MapperScan("com.ruoyi.wiki.mapper")
public class MyBatisPlusConfig {
/**
* 分页插件
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
// 配置分页参数
paginationInterceptor.setMaxLimit(500L);
// 设置分页参数的封装方式默认为false即不封装分页参数
paginationInterceptor.setOverflow(false);
interceptor.addInnerInterceptor(paginationInterceptor);
return interceptor;
}
/**
* 自动填充功能
* @return
*/
@Bean
public GlobalConfig globalConfig() {
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setMetaObjectHandler(new MetaHandler());
return globalConfig;
}
}

View File

@ -0,0 +1,31 @@
package com.ruoyi.wiki.contoller.sys;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.wiki.service.sys.UserService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(value = "/user")
public class UserController {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
UserService userService;
@ApiOperation("获取登录信息")
@RequestMapping(value = "getUserInfo", method = RequestMethod.GET)
public AjaxResult getUserInfo(HttpServletRequest request, HttpServletResponse response){
return AjaxResult.success(userService.getCurrentUser(request));
}
}

View File

@ -0,0 +1,185 @@
package com.ruoyi.wiki.contoller.wiki;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.wiki.refactoring.response.HttpClientResult;
import com.ruoyi.wiki.refactoring.utils.BeanCopyUtils;
import com.ruoyi.wiki.refactoring.utils.FastJsonUtils;
import com.ruoyi.wiki.domain.sys.User;
import com.ruoyi.wiki.domain.wiki.vo.*;
import com.ruoyi.wiki.service.sys.UserService;
import com.ruoyi.wiki.service.wiki.WikiService;
import com.ruoyi.wiki.domain.wiki.Wiki;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping(value = "/open")
public class WikiController {
@Value("${gitea-wiki-api-domain}")
private String giteaApiDomain;
@Value("${gitea-wiki-api-base-url}")
private String giteaApiBaseUrl;
@Value("${gitea-wiki-token}")
private String token;
@Value("${gitea-wiki-ssh-clone-domain}")
private String giteaSSHDomain;
@Value("${gitea-wiki-https-clone-domain}")
private String giteaHttpsDomain;
@Autowired
private WikiService wikiService;
@Autowired
private UserService userService;
Logger logger = LoggerFactory.getLogger(this.getClass());
@ApiOperation("wikiPages")
@GetMapping("/wikiPages")
public AjaxResult wikiPages(
HttpServletRequest request,
@ApiParam(value = "owner of the repo", required = true) @RequestParam(defaultValue = "") String owner,
@ApiParam(value = "name of the repo", required = true) @RequestParam(defaultValue = "") String repo,
@ApiParam(value = "id of the project", required = true) @RequestParam(defaultValue = "") Integer projectId) throws Exception {
String giteaToken = wikiService.getGiteaToken(request, projectId);
//未获取有效giteaToken时赋值内置giteaToken
giteaToken = giteaToken == null ? token : giteaToken;
HttpClientResult httpClientResult = wikiService.getWikiPages(owner, repo, giteaApiDomain+giteaApiBaseUrl, giteaToken);
if (httpClientResult == null) {
throw new ServiceException("获取wiki数据异常");
}
if (httpClientResult.getCode() == 200) {
List<WikiPageVo> wikiPageVoList = wikiService.getWikiPageVoList(giteaHttpsDomain, giteaSSHDomain, owner, repo, httpClientResult);
return new AjaxResult(httpClientResult.getCode(), "操作成功", wikiPageVoList);
} else
return new AjaxResult(httpClientResult.getCode(), "操作失败", httpClientResult.getContent());
}
@ApiOperation("getWiki")
@GetMapping("/getWiki")
public AjaxResult getWiki(
HttpServletRequest request,
@ApiParam(value = "owner of the repo", required = true) @RequestParam(defaultValue = "") String owner,
@ApiParam(value = "name of the repo", required = true) @RequestParam(defaultValue = "") String repo,
@ApiParam(value = "name of the wikipage", required = true) @RequestParam(defaultValue = "") String pageName,
@ApiParam(value = "id of the project", required = true) @RequestParam(defaultValue = "") Integer projectId) throws Exception {
String giteaToken = wikiService.getGiteaToken(request, projectId);
//未获取有效giteaToken时赋值内置giteaToken
giteaToken = giteaToken == null ? token : giteaToken;
HttpClientResult httpClientResult = wikiService.getWiki(owner, repo, pageName, giteaApiDomain+giteaApiBaseUrl, giteaToken);
if (httpClientResult == null) {
throw new ServiceException("获取wiki数据异常");
}
if (httpClientResult.getCode() != 200) {
return new AjaxResult(httpClientResult.getCode(),"操作失败", httpClientResult.getContent());
}
WikiContent wikiContent = getWikiContent(httpClientResult);
return new AjaxResult(httpClientResult.getCode(), "操作成功", wikiContent);
}
@ApiOperation("createWiki")
@PostMapping("/createWiki")
public AjaxResult createWiki(
HttpServletRequest request, @Validated @RequestBody WikiAllVo wikiAllVo
) throws Exception {
String giteaToken = wikiService.getGiteaToken(request, wikiAllVo.getProjectId());
if (wikiService.StringExist(wikiAllVo.getTitle())){
throw new ServiceException("wikiName不能以-开头");
}
logger.info("giteaToken:" + giteaToken);
Wiki wiki = BeanCopyUtils.beanPropertiesCopy(wikiAllVo, Wiki.class);
HttpClientResult httpClientResult = wikiService.createWiki(wiki, giteaToken, giteaApiDomain+giteaApiBaseUrl);
if (httpClientResult == null) {
throw new ServiceException("创建wiki数据异常");
}
return new AjaxResult(httpClientResult.getCode(), "", httpClientResult.getContent());
}
@ApiOperation("deleteWiki")
@DeleteMapping("/deleteWiki")
public AjaxResult deleteWiki(
HttpServletRequest request, @Validated @RequestBody WikiDeleteVo wikiDeleteVo) throws Exception {
String giteaToken = wikiService.getGiteaToken(request, wikiDeleteVo.getProjectId());
logger.info("giteaToken: " + giteaToken);
Wiki wiki = BeanCopyUtils.beanPropertiesCopy(wikiDeleteVo, Wiki.class);
wiki.setTitle(wikiDeleteVo.getPageName());
HttpClientResult httpClientResult = wikiService.deleteWiki(wiki, giteaToken, giteaApiDomain+giteaApiBaseUrl);
if (httpClientResult == null) {
throw new ServiceException("删除wiki数据异常");
}
return new AjaxResult(httpClientResult.getCode(), "", httpClientResult.getContent());
}
@ApiOperation("updateWiki")
@RequestMapping(value = "/updateWiki", method = RequestMethod.PUT)
public AjaxResult updateWiki(
HttpServletRequest request, @Validated @RequestBody WikiAllVo wikiAllVo) throws Exception {
String giteaToken = wikiService.getGiteaToken(request, wikiAllVo.getProjectId());
HttpClientResult httpClientResult = updateWikiByVo(wikiAllVo, giteaToken);
return new AjaxResult(httpClientResult.getCode(), "", httpClientResult.getContent());
}
/************************************************* private method *************************************************/
private WikiContent getWikiContent(HttpClientResult httpClientResult) {
WikiContent wikiContent = FastJsonUtils.toBean(httpClientResult.getContent(), WikiContent.class);
if (wikiContent != null && wikiContent.getLast_commit() != null
&& wikiContent.getLast_commit().getAuthor() != null) {
wikiContent.setImage_url(userService.getRemoteUserLogoByUserLogin(wikiContent.getLast_commit().getAuthor().getName()));
User commitUser = userService.getUserByLogin(wikiContent.getLast_commit().getAuthor().getName());
if(commitUser != null){
wikiContent.setUserName(StringUtils.isEmpty(commitUser.getNickname()) ? commitUser.getLogin() : commitUser.getNickname());
}
if (!StringUtils.isBlank(wikiContent.getSimple_content())){
wikiContent.setSimple_content(wikiContent.getSimple_content().replaceAll("/wiki/raw/api/attachments", "/api/attachments"));
}
}
return wikiContent;
}
private HttpClientResult updateWikiByVo(WikiAllVo wikiAllVo, String giteaToken) throws Exception {
if (!wikiAllVo.getTitle().equals(wikiAllVo.getPageName())){
HttpClientResult httpClientResult = wikiService.getWiki(wikiAllVo.getOwner(),
wikiAllVo.getRepo(),
wikiService.StringToURLEncode(wikiAllVo.getTitle()),
giteaApiDomain+giteaApiBaseUrl
, giteaToken
);
if(httpClientResult.getCode() == 200){
throw new ServiceException("标题已存在");
}
}
Wiki wiki = BeanCopyUtils.beanPropertiesCopy(wikiAllVo, Wiki.class);
wiki.setName(wikiAllVo.getPageName());
HttpClientResult httpClientResult = wikiService.updateWiki(wiki, giteaToken, giteaApiDomain+giteaApiBaseUrl);
if (httpClientResult == null) {
throw new ServiceException("删除wiki数据异常");
}
logger.info("****httpClientResult**** " + httpClientResult.getCode());
return httpClientResult;
}
}

View File

@ -0,0 +1,105 @@
package com.ruoyi.wiki.contoller.wiki;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.wiki.refactoring.response.HttpClientResult;
import com.ruoyi.wiki.service.wiki.WikiService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping(value = "/open")
public class WikiExportController {
@Value("${wiki-export-pdf-destPath}")
private String destPath;
@Value("${wkhtmltopdf-tool-path}")
private String toPdfToolPath;
@Value("${gitea-wiki-api-domain}")
private String giteaApiDomain;
@Value("${gitea-wiki-api-base-url}")
private String giteaApiBaseUrl;
@Value("${gitea-wiki-token}")
private String token;
@Autowired
private WikiService wikiService;
Logger logger = LoggerFactory.getLogger(this.getClass());
@ApiOperation("导出Wiki-wrapper")
@GetMapping("/wikiExport-wrapper")
public AjaxResult wikiExportToPdf(HttpServletResponse response,
HttpServletRequest request,
@ApiParam(value = "owner of the repo", required = true) @RequestParam(defaultValue = "") String owner,
@ApiParam(value = "name of the repo", required = true) @RequestParam(defaultValue = "") String repoName,
@ApiParam(value = "type of the file", required = true) @RequestParam(defaultValue = "") String type,
@ApiParam(value = "name of the project", required = true) @RequestParam(defaultValue = "") String projectName,
@ApiParam(value = "id of the project pdf|html|markdown", required = true) @RequestParam(defaultValue = "") Integer projectId) throws Exception {
String giteaToken = wikiService.getGiteaToken(request, projectId);
String giteaApiUrl = giteaApiDomain + giteaApiBaseUrl;
switch (type) {
case "pdf":
wikiService.exportWikiToPdf(response, toPdfToolPath, owner, repoName, giteaApiUrl, destPath, giteaToken);
break;
case "html":
wikiService.exportWikiToHtml(response, owner, repoName, giteaApiUrl, destPath, projectName, giteaToken);
break;
case "markdown":
wikiService.exportWikiToMd(response, owner, repoName, giteaApiUrl, destPath, giteaToken);
break;
}
return AjaxResult.success();
}
@ApiOperation("上传文件")
@RequestMapping(value = "/uploadWiki/{owner}/{repoName}/{projectId}", method = RequestMethod.POST)
public AjaxResult upload(
HttpServletRequest request,
@ApiParam(value = "owner of the repo", required = true) @PathVariable String owner,
@ApiParam(value = "name of the repo", required = true) @PathVariable String repoName,
@ApiParam(value = "id of the project", required = true) @PathVariable Integer projectId,
@ApiParam(value = "The file to upload", required = true) @RequestPart MultipartFile multipartFile){
String fileName = validateAndGetFileName(multipartFile);
String giteaToken = wikiService.getGiteaToken(request, projectId);
logger.info("giteaToken:" + giteaToken);
if (wikiService.StringExist(fileName)){
throw new ServiceException("wikiName不能以-开头");
}
HttpClientResult httpClientResult = wikiService.createWikiByUploadFile(giteaApiDomain, giteaApiBaseUrl, owner, repoName, multipartFile, fileName, giteaToken);
return new AjaxResult(httpClientResult.getCode(), "", httpClientResult.getContent());
}
/************************************************* private method *************************************************/
@NotNull
private String validateAndGetFileName(MultipartFile multipartFile) {
if(multipartFile.isEmpty()){
throw new ServiceException("错误参数:multipartFile,错误提示:不能为空");
}
String fileName = multipartFile.getOriginalFilename();
if (fileName == null || fileName.trim().isEmpty()) {
throw new RuntimeException("上传的文件名为空");
}
return fileName;
}
}

View File

@ -0,0 +1,109 @@
package com.ruoyi.wiki.domain.members;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("members")
public class Members {
private Integer id;
private Integer userId;
private Integer projectId;
private Date createdOn;
private Boolean mailNotification;
private Integer courseId;
private Integer courseGroupId;
private Integer isCollect;
private Integer graduationGroupId;
private Boolean isApplySignature;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public Boolean getMailNotification() {
return mailNotification;
}
public void setMailNotification(Boolean mailNotification) {
this.mailNotification = mailNotification;
}
public Integer getCourseId() {
return courseId;
}
public void setCourseId(Integer courseId) {
this.courseId = courseId;
}
public Integer getCourseGroupId() {
return courseGroupId;
}
public void setCourseGroupId(Integer courseGroupId) {
this.courseGroupId = courseGroupId;
}
public Integer getIsCollect() {
return isCollect;
}
public void setIsCollect(Integer isCollect) {
this.isCollect = isCollect;
}
public Integer getGraduationGroupId() {
return graduationGroupId;
}
public void setGraduationGroupId(Integer graduationGroupId) {
this.graduationGroupId = graduationGroupId;
}
public Boolean getIsApplySignature() {
return isApplySignature;
}
public void setIsApplySignature(Boolean isApplySignature) {
this.isApplySignature = isApplySignature;
}
}

View File

@ -0,0 +1,499 @@
package com.ruoyi.wiki.domain.projects;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("projects")
public class Projects {
private Integer id;
private String name;
private String homepage;
private Boolean isPublic;
private Integer parentId;
private Date createdOn;
private Date updatedOn;
private String identifier;
private Integer status;
private Integer lft;
private Integer rgt;
private Boolean inheritMembers;
private Integer projectType;
private Boolean hiddenRepo;
private Integer attachmenttype;
private Integer userId;
private Integer dtsTest;
private String enterpriseName;
private Integer organizationId;
private Integer projectNewType;
private Integer gpid;
private Integer forkedFromProjectId;
private Integer forkedCount;
private Integer publishResource;
private Integer visits;
private Integer hot;
private String inviteCode;
private String qrcode;
private Integer qrcodeExpiretime;
private Byte trainingStatus;
private String repIdentifier;
private Integer projectCategoryId;
private Integer projectLanguageId;
private Integer licenseId;
private Integer ignoreId;
private Integer praisesCount;
private Integer watchersCount;
private Integer issuesCount;
private Integer pullRequestsCount;
private String language;
private Integer versionsCount;
private Integer issueTagsCount;
private Integer closedIssuesCount;
private Boolean openDevops;
private Integer giteaWebhookId;
private Integer openDevopsCount;
private Boolean recommend;
private Integer platform;
private Integer orderIndex;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getHomepage() {
return homepage;
}
public void setHomepage(String homepage) {
this.homepage = homepage == null ? null : homepage.trim();
}
public Boolean getIsPublic() {
return isPublic;
}
public void setIsPublic(Boolean isPublic) {
this.isPublic = isPublic;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier == null ? null : identifier.trim();
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getLft() {
return lft;
}
public void setLft(Integer lft) {
this.lft = lft;
}
public Integer getRgt() {
return rgt;
}
public void setRgt(Integer rgt) {
this.rgt = rgt;
}
public Boolean getInheritMembers() {
return inheritMembers;
}
public void setInheritMembers(Boolean inheritMembers) {
this.inheritMembers = inheritMembers;
}
public Integer getProjectType() {
return projectType;
}
public void setProjectType(Integer projectType) {
this.projectType = projectType;
}
public Boolean getHiddenRepo() {
return hiddenRepo;
}
public void setHiddenRepo(Boolean hiddenRepo) {
this.hiddenRepo = hiddenRepo;
}
public Integer getAttachmenttype() {
return attachmenttype;
}
public void setAttachmenttype(Integer attachmenttype) {
this.attachmenttype = attachmenttype;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getDtsTest() {
return dtsTest;
}
public void setDtsTest(Integer dtsTest) {
this.dtsTest = dtsTest;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName == null ? null : enterpriseName.trim();
}
public Integer getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Integer organizationId) {
this.organizationId = organizationId;
}
public Integer getProjectNewType() {
return projectNewType;
}
public void setProjectNewType(Integer projectNewType) {
this.projectNewType = projectNewType;
}
public Integer getGpid() {
return gpid;
}
public void setGpid(Integer gpid) {
this.gpid = gpid;
}
public Integer getForkedFromProjectId() {
return forkedFromProjectId;
}
public void setForkedFromProjectId(Integer forkedFromProjectId) {
this.forkedFromProjectId = forkedFromProjectId;
}
public Integer getForkedCount() {
return forkedCount;
}
public void setForkedCount(Integer forkedCount) {
this.forkedCount = forkedCount;
}
public Integer getPublishResource() {
return publishResource;
}
public void setPublishResource(Integer publishResource) {
this.publishResource = publishResource;
}
public Integer getVisits() {
return visits;
}
public void setVisits(Integer visits) {
this.visits = visits;
}
public Integer getHot() {
return hot;
}
public void setHot(Integer hot) {
this.hot = hot;
}
public String getInviteCode() {
return inviteCode;
}
public void setInviteCode(String inviteCode) {
this.inviteCode = inviteCode == null ? null : inviteCode.trim();
}
public String getQrcode() {
return qrcode;
}
public void setQrcode(String qrcode) {
this.qrcode = qrcode == null ? null : qrcode.trim();
}
public Integer getQrcodeExpiretime() {
return qrcodeExpiretime;
}
public void setQrcodeExpiretime(Integer qrcodeExpiretime) {
this.qrcodeExpiretime = qrcodeExpiretime;
}
public Byte getTrainingStatus() {
return trainingStatus;
}
public void setTrainingStatus(Byte trainingStatus) {
this.trainingStatus = trainingStatus;
}
public String getRepIdentifier() {
return repIdentifier;
}
public void setRepIdentifier(String repIdentifier) {
this.repIdentifier = repIdentifier == null ? null : repIdentifier.trim();
}
public Integer getProjectCategoryId() {
return projectCategoryId;
}
public void setProjectCategoryId(Integer projectCategoryId) {
this.projectCategoryId = projectCategoryId;
}
public Integer getProjectLanguageId() {
return projectLanguageId;
}
public void setProjectLanguageId(Integer projectLanguageId) {
this.projectLanguageId = projectLanguageId;
}
public Integer getLicenseId() {
return licenseId;
}
public void setLicenseId(Integer licenseId) {
this.licenseId = licenseId;
}
public Integer getIgnoreId() {
return ignoreId;
}
public void setIgnoreId(Integer ignoreId) {
this.ignoreId = ignoreId;
}
public Integer getPraisesCount() {
return praisesCount;
}
public void setPraisesCount(Integer praisesCount) {
this.praisesCount = praisesCount;
}
public Integer getWatchersCount() {
return watchersCount;
}
public void setWatchersCount(Integer watchersCount) {
this.watchersCount = watchersCount;
}
public Integer getIssuesCount() {
return issuesCount;
}
public void setIssuesCount(Integer issuesCount) {
this.issuesCount = issuesCount;
}
public Integer getPullRequestsCount() {
return pullRequestsCount;
}
public void setPullRequestsCount(Integer pullRequestsCount) {
this.pullRequestsCount = pullRequestsCount;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language == null ? null : language.trim();
}
public Integer getVersionsCount() {
return versionsCount;
}
public void setVersionsCount(Integer versionsCount) {
this.versionsCount = versionsCount;
}
public Integer getIssueTagsCount() {
return issueTagsCount;
}
public void setIssueTagsCount(Integer issueTagsCount) {
this.issueTagsCount = issueTagsCount;
}
public Integer getClosedIssuesCount() {
return closedIssuesCount;
}
public void setClosedIssuesCount(Integer closedIssuesCount) {
this.closedIssuesCount = closedIssuesCount;
}
public Boolean getOpenDevops() {
return openDevops;
}
public void setOpenDevops(Boolean openDevops) {
this.openDevops = openDevops;
}
public Integer getGiteaWebhookId() {
return giteaWebhookId;
}
public void setGiteaWebhookId(Integer giteaWebhookId) {
this.giteaWebhookId = giteaWebhookId;
}
public Integer getOpenDevopsCount() {
return openDevopsCount;
}
public void setOpenDevopsCount(Integer openDevopsCount) {
this.openDevopsCount = openDevopsCount;
}
public Boolean getRecommend() {
return recommend;
}
public void setRecommend(Boolean recommend) {
this.recommend = recommend;
}
public Integer getPlatform() {
return platform;
}
public void setPlatform(Integer platform) {
this.platform = platform;
}
public Integer getOrderIndex() {
return orderIndex;
}
public void setOrderIndex(Integer orderIndex) {
this.orderIndex = orderIndex;
}
}

View File

@ -0,0 +1,63 @@
package com.ruoyi.wiki.domain.sys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("tokens")
public class Token {
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
private Integer userId;
private String action;
private String value;
private Date createdOn;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action == null ? null : action.trim();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value == null ? null : value.trim();
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
}

View File

@ -0,0 +1,471 @@
package com.ruoyi.wiki.domain.sys;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("users")
public class User {
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
private String login;
private String hashedPassword;
private String firstname;
private String lastname;
private String mail;
private Boolean admin;
private Integer status;
private Date lastLoginOn;
private String language;
private Integer authSourceId;
private Date createdOn;
private Date updatedOn;
private String type;
private String identityUrl;
private String mailNotification;
private String salt;
private Integer gid;
private Integer visits;
@TableField("excellent_teacher")
private Integer excellentTeacher;
@TableField("excellent_student")
private Integer excellentStudent;
private String phone;
private Boolean authentication;
private Integer grade;
private Integer experience;
private String nickname;
private Boolean showRealname;
private Boolean professionalCertification;
private String idNumber;
private Integer certification;
private Boolean homepageTeacher;
private Boolean homepageEngineer;
private Byte isTest;
private Integer ecoderUserId;
private Boolean business;
private Boolean profileCompleted;
private Long laboratoryId;
private String platform;
private String giteaToken;
private Integer giteaUid;
private Boolean isShixunMarker;
private Boolean isSyncPwd;
private Integer watchersCount;
private Integer devopsStep;
public Boolean getShixunMarker() {
return isShixunMarker;
}
public void setShixunMarker(Boolean shixunMarker) {
isShixunMarker = shixunMarker;
}
public Boolean getSyncPwd() {
return isSyncPwd;
}
public void setSyncPwd(Boolean syncPwd) {
isSyncPwd = syncPwd;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login == null ? null : login.trim();
}
public String getHashedPassword() {
return hashedPassword;
}
public void setHashedPassword(String hashedPassword) {
this.hashedPassword = hashedPassword == null ? null : hashedPassword.trim();
}
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname == null ? null : firstname.trim();
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname == null ? null : lastname.trim();
}
public String getMail() {
return mail;
}
public void setMail(String mail) {
this.mail = mail == null ? null : mail.trim();
}
public Boolean getAdmin() {
return admin;
}
public void setAdmin(Boolean admin) {
this.admin = admin;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getLastLoginOn() {
return lastLoginOn;
}
public void setLastLoginOn(Date lastLoginOn) {
this.lastLoginOn = lastLoginOn;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language == null ? null : language.trim();
}
public Integer getAuthSourceId() {
return authSourceId;
}
public void setAuthSourceId(Integer authSourceId) {
this.authSourceId = authSourceId;
}
public Date getCreatedOn() {
return createdOn;
}
public void setCreatedOn(Date createdOn) {
this.createdOn = createdOn;
}
public Date getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getIdentityUrl() {
return identityUrl;
}
public void setIdentityUrl(String identityUrl) {
this.identityUrl = identityUrl == null ? null : identityUrl.trim();
}
public String getMailNotification() {
return mailNotification;
}
public void setMailNotification(String mailNotification) {
this.mailNotification = mailNotification == null ? null : mailNotification.trim();
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt == null ? null : salt.trim();
}
public Integer getGid() {
return gid;
}
public void setGid(Integer gid) {
this.gid = gid;
}
public Integer getVisits() {
return visits;
}
public void setVisits(Integer visits) {
this.visits = visits;
}
public Integer getExcellentTeacher() {
return excellentTeacher;
}
public void setExcellentTeacher(Integer excellentTeacher) {
this.excellentTeacher = excellentTeacher;
}
public Integer getExcellentStudent() {
return excellentStudent;
}
public void setExcellentStudent(Integer excellentStudent) {
this.excellentStudent = excellentStudent;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public Boolean getAuthentication() {
return authentication;
}
public void setAuthentication(Boolean authentication) {
this.authentication = authentication;
}
public Integer getGrade() {
return grade;
}
public void setGrade(Integer grade) {
this.grade = grade;
}
public Integer getExperience() {
return experience;
}
public void setExperience(Integer experience) {
this.experience = experience;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname == null ? null : nickname.trim();
}
public Boolean getShowRealname() {
return showRealname;
}
public void setShowRealname(Boolean showRealname) {
this.showRealname = showRealname;
}
public Boolean getProfessionalCertification() {
return professionalCertification;
}
public void setProfessionalCertification(Boolean professionalCertification) {
this.professionalCertification = professionalCertification;
}
public String getIdNumber() {
return idNumber;
}
public void setIdNumber(String idNumber) {
this.idNumber = idNumber == null ? null : idNumber.trim();
}
public Integer getCertification() {
return certification;
}
public void setCertification(Integer certification) {
this.certification = certification;
}
public Boolean getHomepageTeacher() {
return homepageTeacher;
}
public void setHomepageTeacher(Boolean homepageTeacher) {
this.homepageTeacher = homepageTeacher;
}
public Boolean getHomepageEngineer() {
return homepageEngineer;
}
public void setHomepageEngineer(Boolean homepageEngineer) {
this.homepageEngineer = homepageEngineer;
}
public Byte getIsTest() {
return isTest;
}
public void setIsTest(Byte isTest) {
this.isTest = isTest;
}
public Integer getEcoderUserId() {
return ecoderUserId;
}
public void setEcoderUserId(Integer ecoderUserId) {
this.ecoderUserId = ecoderUserId;
}
public Boolean getBusiness() {
return business;
}
public void setBusiness(Boolean business) {
this.business = business;
}
public Boolean getProfileCompleted() {
return profileCompleted;
}
public void setProfileCompleted(Boolean profileCompleted) {
this.profileCompleted = profileCompleted;
}
public Long getLaboratoryId() {
return laboratoryId;
}
public void setLaboratoryId(Long laboratoryId) {
this.laboratoryId = laboratoryId;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform == null ? null : platform.trim();
}
public String getGiteaToken() {
return giteaToken;
}
public void setGiteaToken(String giteaToken) {
this.giteaToken = giteaToken == null ? null : giteaToken.trim();
}
public Integer getGiteaUid() {
return giteaUid;
}
public void setGiteaUid(Integer giteaUid) {
this.giteaUid = giteaUid;
}
public Boolean getIsShixunMarker() {
return isShixunMarker;
}
public void setIsShixunMarker(Boolean isShixunMarker) {
this.isShixunMarker = isShixunMarker;
}
public Boolean getIsSyncPwd() {
return isSyncPwd;
}
public void setIsSyncPwd(Boolean isSyncPwd) {
this.isSyncPwd = isSyncPwd;
}
public Integer getWatchersCount() {
return watchersCount;
}
public void setWatchersCount(Integer watchersCount) {
this.watchersCount = watchersCount;
}
public Integer getDevopsStep() {
return devopsStep;
}
public void setDevopsStep(Integer devopsStep) {
this.devopsStep = devopsStep;
}
}

View File

@ -0,0 +1,218 @@
package com.ruoyi.wiki.domain.sys;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("user_extensions")
public class UserExtension {
private Integer id;
private Integer userId;
private Date birthday;
private String briefIntroduction;
private Integer gender;
private String location;
private String occupation;
private Integer workExperience;
private Integer zipCode;
private Date createdAt;
private Date updatedAt;
private Integer identity;
private String technicalTitle;
private String studentId;
private String teacherRealname;
private String studentRealname;
private String locationCity;
private Integer schoolId;
private String description;
private Integer departmentId;
private String province;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getBriefIntroduction() {
return briefIntroduction;
}
public void setBriefIntroduction(String briefIntroduction) {
this.briefIntroduction = briefIntroduction == null ? null : briefIntroduction.trim();
}
public Integer getGender() {
return gender;
}
public void setGender(Integer gender) {
this.gender = gender;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location == null ? null : location.trim();
}
public String getOccupation() {
return occupation;
}
public void setOccupation(String occupation) {
this.occupation = occupation == null ? null : occupation.trim();
}
public Integer getWorkExperience() {
return workExperience;
}
public void setWorkExperience(Integer workExperience) {
this.workExperience = workExperience;
}
public Integer getZipCode() {
return zipCode;
}
public void setZipCode(Integer zipCode) {
this.zipCode = zipCode;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Integer getIdentity() {
return identity;
}
public void setIdentity(Integer identity) {
this.identity = identity;
}
public String getTechnicalTitle() {
return technicalTitle;
}
public void setTechnicalTitle(String technicalTitle) {
this.technicalTitle = technicalTitle == null ? null : technicalTitle.trim();
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId == null ? null : studentId.trim();
}
public String getTeacherRealname() {
return teacherRealname;
}
public void setTeacherRealname(String teacherRealname) {
this.teacherRealname = teacherRealname == null ? null : teacherRealname.trim();
}
public String getStudentRealname() {
return studentRealname;
}
public void setStudentRealname(String studentRealname) {
this.studentRealname = studentRealname == null ? null : studentRealname.trim();
}
public String getLocationCity() {
return locationCity;
}
public void setLocationCity(String locationCity) {
this.locationCity = locationCity == null ? null : locationCity.trim();
}
public Integer getSchoolId() {
return schoolId;
}
public void setSchoolId(Integer schoolId) {
this.schoolId = schoolId;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Integer getDepartmentId() {
return departmentId;
}
public void setDepartmentId(Integer departmentId) {
this.departmentId = departmentId;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province == null ? null : province.trim();
}
}

View File

@ -0,0 +1,94 @@
package com.ruoyi.wiki.domain.sys;
public class UserVo {
private String username;
private String real_name;
private String login;
private String user_id;
private String image_url;
private boolean admin;
private String user_identity;
private boolean isOperator;
private String token;
private String giteaToken;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public boolean isOperator() {
return isOperator;
}
public void setOperator(boolean operator) {
isOperator = operator;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getReal_name() {
return real_name;
}
public void setReal_name(String real_name) {
this.real_name = real_name;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getImage_url() {
return image_url;
}
public void setImage_url(String image_url) {
this.image_url = image_url;
}
public boolean isAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
public String getUser_identity() {
return user_identity;
}
public void setUser_identity(String user_identity) {
this.user_identity = user_identity;
}
public String getGiteaToken() {
return giteaToken;
}
public void setGiteaToken(String giteaToken) {
this.giteaToken = giteaToken;
}
}

View File

@ -0,0 +1,65 @@
package com.ruoyi.wiki.domain.team_projects;
import java.util.Date;
public class TeamProjects {
private Long id;
private Long organizationId;
private Long projectId;
private Long teamId;
private Date createdAt;
private Date updatedAt;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getOrganizationId() {
return organizationId;
}
public void setOrganizationId(Long organizationId) {
this.organizationId = organizationId;
}
public Long getProjectId() {
return projectId;
}
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
public Long getTeamId() {
return teamId;
}
public void setTeamId(Long teamId) {
this.teamId = teamId;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.wiki.domain.wiki;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
public class Wiki {
@NotEmpty
private String owner;
@NotEmpty
private String repo;
private String title;
private String message;
private String content_base64;
@NotEmpty
private String name;
}

View File

@ -0,0 +1,20 @@
package com.ruoyi.wiki.domain.wiki;
import com.fasterxml.jackson.annotation.JsonAlias;
import lombok.Data;
import java.util.Base64;
@Data
public class WikiContentSimple {
private String title;
private String simple_content;
@JsonAlias("md_content")
private String content_base64;
public void setContent_base64(String content_base64) {
this.content_base64 = new String (Base64.getDecoder().decode(content_base64));
}
}

View File

@ -0,0 +1,10 @@
package com.ruoyi.wiki.domain.wiki;
import lombok.Data;
@Data
public class WikiPage {
private String title;
private String sub_url;
}

View File

@ -0,0 +1,15 @@
package com.ruoyi.wiki.domain.wiki.vo;
import lombok.Data;
import java.util.Date;
@Data
public class AuthorMessage {
private String name;
private Date date;
private String email;
}

View File

@ -0,0 +1,12 @@
package com.ruoyi.wiki.domain.wiki.vo;
import lombok.Data;
@Data
public class CommitMessage {
private String sha;
private String message;
private AuthorMessage author;
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.wiki.domain.wiki.vo;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
@Data
public class WikiAllVo {
@NotEmpty
private String owner;
@NotEmpty
private String repo;
private String pageName;
private String message;
private String content_base64;
@NotEmpty
@Size(max = 50, message = "长度在0~50")
private String title;
private Integer projectId;
}

View File

@ -0,0 +1,11 @@
package com.ruoyi.wiki.domain.wiki.vo;
import lombok.Data;
@Data
public class WikiCloneLinkVo {
private String https;
private String ssh;
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.wiki.domain.wiki.vo;
import com.fasterxml.jackson.annotation.JsonAlias;
import lombok.Data;
@Data
public class WikiContent {
@JsonAlias("name")
private String title;
@JsonAlias("commit")
private CommitMessage last_commit;
private String commit_count;
@JsonAlias("md_content")
private String content_base64;
private String simple_content;
private String image_url;
private String userName;
private String sidebar;
private String footer;
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.wiki.domain.wiki.vo;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
public class WikiDeleteVo {
@NotEmpty
private String owner;
@NotEmpty
private String repo;
private String pageName;
private Integer projectId;
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.wiki.domain.wiki.vo;
import com.fasterxml.jackson.annotation.JsonAlias;
import lombok.Data;
@Data
public class WikiPageVo {
@JsonAlias("name")
private String title;
@JsonAlias("commit")
private CommitMessage last_commit;
private WikiCloneLinkVo wiki_clone_link;
private String image_url;
private String userName;
private String sub_url;
}

View File

@ -0,0 +1,13 @@
package com.ruoyi.wiki.domain.wiki.vo;
import lombok.Data;
@Data
public class WikiVo {
private String message;
private String content_base64;
private String title;
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.wiki.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class MetaHandler implements MetaObjectHandler {
/**
* 更新数据执行
* @param metaObject
*/
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updatedAt", new Date(), metaObject);
}
/**
* 新增数据执行
* @param metaObject
*/
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createdAt", new Date(), metaObject);
}
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.wiki.mapper.members;
import com.ruoyi.wiki.domain.members.Members;
import org.apache.ibatis.annotations.Param;
public interface MembersMapper {
int deleteByPrimaryKey(Integer id);
int insert(Members record);
int insertSelective(Members record);
Members selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Members record);
int updateByPrimaryKey(Members record);
int doesMemberExist(@Param("userId") Integer userId,@Param("projectId") Integer projectId);
}

View File

@ -0,0 +1,17 @@
package com.ruoyi.wiki.mapper.projects;
import com.ruoyi.wiki.domain.projects.Projects;
import org.apache.ibatis.annotations.Param;
public interface ProjectsMapper {
int deleteByPrimaryKey(Integer id);
int updateByPrimaryKey(Projects record);
Projects getProjectById(@Param("projectId")Integer projectId);
Projects getProjectByLoginAndIdentifier(@Param("login") String login,@Param("identifier") String identifier,@Param("identifier1") String identifier1);
}

View File

@ -0,0 +1,20 @@
package com.ruoyi.wiki.mapper.sys;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.wiki.domain.sys.Token;
public interface TokenMapper extends BaseMapper<Token> {
int deleteByPrimaryKey(Integer id);
int insert(Token record);
int insertSelective(Token record);
Token selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(Token record);
int updateByPrimaryKey(Token record);
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.wiki.mapper.sys;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.wiki.domain.sys.UserExtension;
public interface UserExtensionMapper extends BaseMapper<UserExtension> {
int deleteByPrimaryKey(Integer id);
int insert(UserExtension record);
int insertSelective(UserExtension record);
UserExtension selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(UserExtension record);
int updateByPrimaryKeyWithBLOBs(UserExtension record);
int updateByPrimaryKey(UserExtension record);
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.wiki.mapper.sys;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.wiki.domain.sys.User;
public interface UserMapper extends BaseMapper<User> {
int deleteByPrimaryKey(Integer id);
int insert(User record);
int insertSelective(User record);
User selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
}

View File

@ -0,0 +1,21 @@
package com.ruoyi.wiki.mapper.team_projects;
import com.ruoyi.wiki.domain.team_projects.TeamProjects;
import org.apache.ibatis.annotations.Param;
public interface TeamProjectsMapper {
int deleteByPrimaryKey(Long id);
int insert(TeamProjects record);
int insertSelective(TeamProjects record);
TeamProjects selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(TeamProjects record);
int updateByPrimaryKey(TeamProjects record);
int doesMemberExist(@Param("userId") Integer userId,@Param("projectId") Integer projectId);
}

View File

@ -0,0 +1,42 @@
package com.ruoyi.wiki.refactoring.constant;
import java.util.HashMap;
import java.util.Map;
/**
* 系统常量
*
* @author David
*/
public class Constants {
public static final String CHARSET_URF8 = "UTF-8";
public static final String COOKIE_NAME = "autologin_trustie";
public static final String TOKEN_ACTION = "autologin";
public static final String MAIL_REG = "^[a-zA-Z0-9]+([.\\-_\\\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$";
public static final String PHONE_REG = "^1\\d{10}$";
public static final Byte TXT_FILE = 1;
public static final Byte VIDEO_FILE = 2;
public static final Byte IMG_FILE = 3;
public static final Byte APP_FILE = 4;
public static final Byte OTHER_FILE = 5;
public static final Map<String, Byte> FILE_TYPE_MAP = new HashMap<String, Byte>() {
{
put(".jpg", IMG_FILE);
put(".png", IMG_FILE);
put(".jpeg", IMG_FILE);
put(".mp4", VIDEO_FILE);
put(".txt", TXT_FILE);
put(".doc", TXT_FILE);
put(".docx", TXT_FILE);
put(".xls", TXT_FILE);
put(".xlsx", TXT_FILE);
put(".exe", APP_FILE);
}
};
}

View File

@ -0,0 +1,24 @@
package com.ruoyi.wiki.refactoring.enums;
public enum ResponseEnum {
NOT_FOUND("404", "资源不存在"),
BAD_REQUEST("400", "请求失败"),
SYS_ERROR("999", "系统错误"),
FORBIDDEN("403", "权限不足");
private String key;
private String value;
private ResponseEnum(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return this.key;
}
public String getValue() {
return this.value;
}
}

View File

@ -0,0 +1,27 @@
package com.ruoyi.wiki.refactoring.exception;
public class BusiException extends RuntimeException {
private String errorCode = "999";
public BusiException(String message) {
super(message);
}
public BusiException(String message, String errorCode) {
super(message);
this.errorCode = errorCode;
}
public BusiException(String message, Throwable cause) {
super(message, cause);
}
public BusiException(String message, String errorCode, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
}
public String getErrorCode() {
return this.errorCode;
}
}

View File

@ -0,0 +1,56 @@
package com.ruoyi.wiki.refactoring.response;
import java.io.Serializable;
public class HttpClientResult implements Serializable {
private static final long serialVersionUID = 2168152194164783950L;
/**
* 响应状态码
*/
private int code;
/**
* 响应数据
*/
private String content;
public HttpClientResult() {
}
public HttpClientResult(int code) {
this.code = code;
}
public HttpClientResult(String content) {
this.content = content;
}
public HttpClientResult(int code, String content) {
this.code = code;
this.content = content;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public String toString() {
return "HttpClientResult [code=" + code + ", content=" + content + "]";
}
}

View File

@ -0,0 +1,19 @@
package com.ruoyi.wiki.refactoring.utils;
import com.ruoyi.wiki.refactoring.exception.BusiException;
import org.springframework.beans.BeanUtils;
public class BeanCopyUtils {
public static <T> T beanPropertiesCopy(Object source, Class clazz) {
T target = null;
try {
target = (T) clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new BusiException(e.toString());
}
BeanUtils.copyProperties(source, target);
return target;
}
}

View File

@ -0,0 +1,71 @@
package com.ruoyi.wiki.refactoring.utils;
import org.springframework.beans.BeanUtils;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
/**
* ClassName CommonUtils
* Description 公共工具类
*
* @author ZengWei
* Date 2021/3/30
*/
public class CommonUtils {
/**
* @author ZengWei
* Description 获取文件大小换算
* Date 2021/3/30
* @param size
* @return java.lang.String
**/
public static String getSize(Double size){
if (size>=1024*1024*1024) {
return String.format("%.1f", size/1073741824L) + "G";
} else if (size>=1024*1024) {
return String.format("%.1f", size/1048576L) + "M";
} else if (size>=1024) {
return String.format("%.1f", size/1024) + "K";
}
return size + "B";
}
/**
* 把指定的复杂对象属性按照指定的内容封装到新的map中
* @param source 目标对象
* @param ps 需要封装到map中的属性
* @return map
*/
public static Map<String, Object> obj2map(Object source, String[] ps) {
Map<String, Object> map = new HashMap<>();
if (source == null)
return null;
if (ps == null || ps.length < 1) {
return null;
}
for (String p : ps) {
PropertyDescriptor sourcePd = BeanUtils.getPropertyDescriptor(
source.getClass(), p);
if (sourcePd != null && sourcePd.getReadMethod() != null) {
try {
Method readMethod = sourcePd.getReadMethod();
if (!Modifier.isPublic(readMethod.getDeclaringClass()
.getModifiers())) {
readMethod.setAccessible(true);
}
Object value = readMethod.invoke(source, new Object[0]);
map.put(p, value);
} catch (Exception ex) {
throw new RuntimeException(
"Could not copy properties from source to target",
ex);
}
}
}
return map;
}
}

View File

@ -0,0 +1,65 @@
package com.ruoyi.wiki.refactoring.utils;
import org.apache.commons.collections4.CollectionUtils;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
public class ConvertBean {
public static HashMap<String, Object> convertToMap(Object obj) throws Exception{
HashMap<String, Object> map = new HashMap<String, Object>();
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
String varName = field.getName();
boolean accessFlag = field.isAccessible();
field.setAccessible(true);
Object o = field.get(obj);
if (o != null)
map.put(varName, o.toString());
field.setAccessible(accessFlag);
}
return map;
}
/**
* 将List<String>集合 转化为String
* {"aaa","bbb"} To 'aaa','bbb'
*/
public static String convertListToString(List<String> strlist){
StringBuilder sb = new StringBuilder();
if(CollectionUtils.isNotEmpty(strlist)){
for (int i=0;i<strlist.size();i++) {
if(i==0){
sb.append("'").append(strlist.get(i)).append("'");
}else{
sb.append(",").append("'").append(strlist.get(i)).append("'");
}
}
}
return sb.toString();
}
public static HashMap<String, String> convertToStringMap(Object obj) throws Exception{
HashMap<String, String> map = new HashMap<String, String>();
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
String varName = field.getName();
boolean accessFlag = field.isAccessible();
field.setAccessible(true);
Object o = field.get(obj);
if (o != null)
map.put(varName, o.toString());
field.setAccessible(accessFlag);
}
return map;
}
}

View File

@ -0,0 +1,32 @@
package com.ruoyi.wiki.refactoring.utils;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
public class CookieUtil {
/**
* 返回一个可用的 cookie
* @param request
* @return
*/
public static String getToken(String name, HttpServletRequest request) {
String token = null;
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for(Cookie ck : cookies){
if (ck.getName().equals(name)) {
token = ck.getValue();
}
}
}
if(token == null){
token = request.getHeader("Authorization");
}
if (token == null) {
token = request.getParameter("token");
}
return token;
}
}

View File

@ -0,0 +1,430 @@
package com.ruoyi.wiki.refactoring.utils;
import com.ruoyi.wiki.refactoring.exception.BusiException;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
public class DateUtils {
public static final String PATTERN_DATE_HOUR = "yyyy-MM-dd HH:mm";
public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss";
public static final String PATTERN_DATE = "yyyy-MM-dd";
public static final String SHORT_PATTERN_DATE = "yyyyMMdd";
public static final String PATTERN_FULL_DATE = "yyyyMMddHHmmss";
public static final String SHORT_HOUR_MIN_DATE = "HHmm";
public static final String PATTERN_DATE_ONLY_YEAR_MONTH = "yyyy-MM";
public static final String ZERO_STR = "0";
public static final String PATTERN_STANDARD_MILLISECOND = "yyyy-MM-dd HH:mm:ss.SSS";
private static final Logger LOG = LoggerFactory.getLogger(DateUtils.class);
private static final long ONE_DAY_MSED = 86400000L;
private static final int MIN_TO_MSEC = 60000;
private static final int[] WEEK_OF_DAYS = {7, 1, 2, 3, 4, 5, 6};
public static long calculateTimeInMillis(Date from, Date to) {
Calendar fromCal = getCalendar(from);
Calendar toCal = getCalendar(to);
return toCal.getTimeInMillis() - fromCal.getTimeInMillis();
}
public static Calendar getCalendar(Date date) {
Calendar gc = Calendar.getInstance();
gc.setTime(date);
return gc;
}
public static String date2String(Date date, String pattern) {
if (date == null) {
return "";
}
String patternNew = pattern;
if (StringUtils.isEmpty(pattern)) {
patternNew = "yyyy-MM-dd HH:mm:ss";
}
SimpleDateFormat sdf = new SimpleDateFormat(patternNew);
return sdf.format(date);
}
public static String getNowDateTime() {
Date now = new Date();
return getFormatDate(now, "yyyy-MM-dd HH:mm:ss");
}
public static Date string2Date(String strDate, String pattern) throws BusiException {
if ((strDate == null) || ("".equals(strDate))) {
throw new BusiException("str date null");
}
String patternNew = pattern;
if ((pattern == null) || ("".equals(pattern))) {
patternNew = "yyyy-MM-dd";
}
SimpleDateFormat sdf = new SimpleDateFormat(patternNew);
Date date = null;
try {
date = sdf.parse(strDate);
} catch (ParseException e) {
throw new BusiException(e.toString());
}
return date;
}
public static String stringToYear(String strDest) throws BusiException {
if ((strDest == null) || ("".equals(strDest))) {
throw new BusiException("str dest null");
}
Date date = string2Date(strDest, "yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(date);
return String.valueOf(c.get(1));
}
public static String stringToMonth(String strDest) throws BusiException {
if ((strDest == null) || ("".equals(strDest))) {
throw new BusiException("strDest null");
}
Date date = string2Date(strDest, "yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(date);
int month = c.get(2);
month += 1;
if (month < 10) {
return "0" + month;
}
return String.valueOf(month);
}
public static String stringToDay(String strDest) throws BusiException {
if ((strDest == null) || ("".equals(strDest))) {
throw new BusiException("strDest is null");
}
Date date = string2Date(strDest, "yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(date);
int day = c.get(5);
if (day < 10) {
return "0" + day;
}
return Integer.toString(day);
}
public static Date getFirstDayOfMonth(Calendar c) {
int year = c.get(1);
int month = c.get(2);
int day = 1;
c.set(year, month, day, 0, 0, 0);
return c.getTime();
}
public static Date getLastDayOfMonth(Calendar c) {
int year = c.get(1);
int month = c.get(2) + 1;
int day = 1;
if (month > 11) {
month = 0;
year += 1;
}
c.set(year, month, day - 1, 0, 0, 0);
return c.getTime();
}
public static String date2GregorianCalendarString(Date date) throws BusiException {
if (date == null) {
throw new BusiException("Date is null");
}
long tmp = date.getTime();
GregorianCalendar ca = new GregorianCalendar();
ca.setTimeInMillis(tmp);
try {
XMLGregorianCalendar tXmlGregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(ca);
return tXmlGregorianCalendar.normalize().toString();
} catch (DatatypeConfigurationException e) {
throw new BusiException("Date is null:" + e);
}
}
public static boolean compareDate(Date firstDate, Date secondDate) throws BusiException {
if ((firstDate == null) || (secondDate == null)) {
throw new BusiException("Date is null");
}
String strFirstDate = date2String(firstDate, "yyyy-MM-dd");
String strSecondDate = date2String(secondDate, "yyyy-MM-dd");
return StringUtils.equals(strFirstDate, strSecondDate);
}
public static Date getStartTimeOfDate(Date currentDate) throws BusiException {
Assert.notNull(currentDate, "");
String strDateTime = date2String(currentDate, "yyyy-MM-dd") + " 00:00:00";
return string2Date(strDateTime, "yyyy-MM-dd HH:mm:ss");
}
public static Date getEndTimeOfDate(Date currentDate) throws BusiException {
Assert.notNull(currentDate, "");
String strDateTime = date2String(currentDate, "yyyy-MM-dd") + " 23:59:59";
return string2Date(strDateTime, "yyyy-MM-dd HH:mm:ss");
}
public static long dateStrToLong(String[] symbols, String dateStr) {
String newDateStr = dateStr;
for (String symbol : symbols) {
newDateStr = newDateStr.replaceAll(symbol, "");
}
return Long.parseLong(newDateStr);
}
public static long dateAddMonthToLong(int month, int dateType) throws BusiException {
Calendar c = Calendar.getInstance();
c.add(2, month);
String fmt;
if (dateType == 1) {
fmt = "yyyyMMddHHmm";
} else {
fmt = "yyyyMMdd";
}
try {
return Long.parseLong(date2String(c.getTime(), fmt));
} catch (Exception e) {
LOG.error("日期转化异常:", e);
throw new BusiException(e.toString());
}
}
public static Date dateAddMin(Date date, int min) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(12, min);
return c.getTime();
}
public static Date dateAddDay(Date date, int day) {
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(5, day);
return c.getTime();
}
public static long getCurrtDateToLong(int dateType) throws BusiException {
Date date = new Date();
String fmt;
if (dateType == 1) {
fmt = "yyyyMMddHHmm";
} else {
fmt = "yyyyMMdd";
}
try {
return Long.parseLong(date2String(date, fmt));
} catch (Exception e) {
LOG.error("getCurrtDateToLong异常", e);
throw new BusiException(e.toString());
}
}
public static int daysOfTwo(Date sDate, Date eDate) {
Calendar aCalendar = Calendar.getInstance();
aCalendar.setTime(sDate);
int day1 = aCalendar.get(6);
aCalendar.setTime(eDate);
int day2 = aCalendar.get(6);
return day2 - day1;
}
public static int daysBetween(Date smdate, Date bdate)
throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date newsmdate = sdf.parse(sdf.format(smdate));
Date newBdate = sdf.parse(sdf.format(bdate));
Calendar cal = Calendar.getInstance();
cal.setTime(newsmdate);
long time1 = cal.getTimeInMillis();
cal.setTime(newBdate);
long time2 = cal.getTimeInMillis();
long betweenDays = (time2 - time1) / 86400000L;
return Integer.parseInt(String.valueOf(betweenDays));
}
public static String getFormatDate(Date date) {
Date newDate = date;
if (newDate == null) {
newDate = new Date();
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
return sdf.format(newDate);
}
public static String getFormatDate() {
return getFormatDate(new Date(), "yyyy-MM-dd");
}
public static String getFormatDate(Date date, String pattern) {
Date newDate = date;
if (newDate == null) {
newDate = new Date();
}
String patternNew = pattern;
if ((pattern == null) || ("".equals(pattern))) {
patternNew = "yyyy-MM-dd";
}
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(newDate);
}
public static String getFormatDateNoDefaultValue(Date date, String pattern) {
Date newDate = date;
if (newDate == null) {
return "";
}
String patternNew = pattern;
if ((pattern == null) || ("".equals(pattern))) {
patternNew = "yyyy-MM-dd";
}
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(newDate);
}
public static boolean checkTimeIsInRange(Date date, int startTime, int endTime) {
int hour = getCalendarResult(date, 11);
int minute = getCalendarResult(date, 12);
String nowStr = String.valueOf(hour);
if (minute / 10 == 0) {
nowStr = nowStr + "0" + minute;
} else {
nowStr = nowStr + Integer.toString(minute);
}
int mixTime = Integer.parseInt(String.format("%s", new Object[]{nowStr}));
return (startTime <= mixTime) && (mixTime <= endTime);
}
public static int getDayOfWeek(Date date) {
Date newDate = date;
if (newDate == null) {
newDate = new Date();
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int weekday = calendar.get(7) - 1;
return WEEK_OF_DAYS[weekday];
}
private static int getCalendarResult(Date date, int type) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(type);
}
public static Date calculateDateWithMinutes(Date sourceDate, int minutes) {
if (sourceDate == null)
return null;
return new Date(sourceDate.getTime() + minutes * 60000);
}
public static Date getDateFromStr1(String str) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.parse(str);
} catch (Exception e) {
LOG.error("字符串转yyyy-MM-dd HH:mm:ss格式时间出错str=" + str + ",e=", e);
}
return null;
}
public static int getShortHourMin() {
Date newDate = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("HHmm");
return Integer.parseInt(sdf.format(newDate));
}
public static Date getShortMonth(int count) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(2, count);
return cal.getTime();
}
public static long getDateDiff(Date d1, Date d2) {
Calendar c = Calendar.getInstance();
c.setTime(d1);
Calendar c1 = Calendar.getInstance();
c1.setTime(d2);
int date = c.get(6);
int date1 = c1.get(6);
return date - date1;
}
//日期天数加法
public static String getDateAddDayString(Date date,Integer day){
if(date == null || day==null){
return null;
}
Calendar calendar = new GregorianCalendar();
DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_WEEK,day);
return df.format(calendar.getTime());
}
//日期天数加法
public static Date getDateAddDay(Date date,Integer day,String pattern) throws ParseException {
if(date.equals(null) || day.equals(null)){
return null;
}
Calendar calendar = new GregorianCalendar();
DateFormat df=new SimpleDateFormat(pattern);
calendar.setTime(date);
calendar.add(Calendar.DAY_OF_WEEK,day);
String time = df.format(calendar.getTime());
return df.parse(time);
}
//之前的日期与当前日期相差的时间小时
public static String getDelayTime(Date previousDate) {
Date now = new Date();
if (previousDate == null) {
return null;
}
long a = (now.getTime() - previousDate.getTime()) / (1000 * 60);
int c = ((a < 0) == true ? 1 : 0) + ((a < 60) == true ? 1 : 0) + ((a < 60 * 24) == true ? 1 : 0);
int day, hour, min;
switch (c) {
case 0:
day = (int) a / 60 / 24;
hour = (int) (a % (60 * 24)) / 60;
min = (int) (a - day * 24 * 60 - hour * 60);
return "相差" + day + "" + hour + "小时" + min + "分钟";
case 1:
hour = (int) (a / 60);
min = (int) (a % 60);
return "相差" + hour + "小时" + min + "分钟";
case 2:
return "相差" + a + "分钟";
case 3:
return null;
}
return null;
}
}

View File

@ -0,0 +1,76 @@
package com.ruoyi.wiki.refactoring.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import javax.xml.crypto.dsig.keyinfo.KeyValue;
import java.util.List;
import java.util.Map;
public class FastJsonUtils {
public static Object toBean(String text) {
return JSON.parse(text);
}
public static <T> T toBean(String text, Class<T> clazz) {
return JSON.parseObject(text, clazz);
}
// 转换为数组
public static <T> Object[] toArray(String text) {
return toArray(text, null);
}
// 转换为数组
public static <T> Object[] toArray(String text, Class<T> clazz) {
return JSON.parseArray(text, clazz).toArray();
}
// 转换为List
public static <T> List<T> toList(String text, Class<T> clazz) {
return JSON.parseArray(text, clazz);
}
/**
* 将javabean转化为序列化的json字符串
* @param keyvalue
* @return
*/
public static Object beanToJson(KeyValue keyvalue) {
String textJson = JSON.toJSONString(keyvalue);
Object objectJson = JSON.parse(textJson);
return objectJson;
}
/**
* 将string转化为序列化的json字符串
* @param
* @return
*/
public static Object textToJson(String text) {
Object objectJson = JSON.parse(text);
return objectJson;
}
/**
* json字符串转化为map
* @param s
* @return
*/
public static Map stringToCollect(String s) {
Map m = JSONObject.parseObject(s);
return m;
}
/**
* 将map转化为string
* @param m
* @return
*/
public static String collectToString(Map m) {
String s = JSONObject.toJSONString(m);
return s;
}
}

View File

@ -0,0 +1,171 @@
package com.ruoyi.wiki.refactoring.utils;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* ClassName FileUtils
* Description 文件工具类
*
* @author ZengWei
* Date 2021/3/31
*/
@Component
public class FileUtils {
// 文件在服务器端保存的主目录
@Value("${FILES.BASEPATHFILE}")
private String basePath;
private static final Logger logger = LoggerFactory.getLogger(FileUtils.class);
/**
* @author ZengWei
* Description 生成保存文件名称
* Date 2021/3/31
* @param oldName
* @return java.lang.String
**/
public String getNewFilePathAndName(String oldName) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("/yyyy/MM/dd");
StringBuilder newPathAndName = new StringBuilder();
newPathAndName.append(basePath);
newPathAndName.append(simpleDateFormat.format(new Date()));
newPathAndName.append("/");
newPathAndName.append(IDUtils.getFileName());
newPathAndName.append(oldName.lastIndexOf(".") > -1 ? oldName.substring(oldName.lastIndexOf(".")) : "");
return newPathAndName.toString();
}
/**
* @author ZengWei
* Description 创建文件
* Date 2021/3/31
* @param file
* @return boolean
**/
public boolean createFile(File file) {
if(!file.getParentFile().exists()) {
if (!file.getParentFile().mkdirs()) {
logger.info("创建目录失败");
return false;
}
}
try {
if (!file.createNewFile()) {
logger.info("创建文件失败");
return false;
}
} catch (IOException e) {
logger.info(e.getMessage());
return false;
}
return true;
}
/**
* @author ZengWei
* Description 保存上传文件
* Date 2021/3/31
* @param file
* @return java.lang.String
**/
public String upload(MultipartFile file) {
if (file.isEmpty()) {
logger.info("上传的文件为空");
return "";
}
String filePathAndName = this.getNewFilePathAndName(file.getOriginalFilename());
File dest = new File(filePathAndName);
if (!this.createFile(dest)) {
return "";
}
try {
file.transferTo(dest);
} catch (IOException e) {
logger.info("保存文件失败");
logger.info(e.getMessage());
return "";
}
return filePathAndName;
}
/**
* @author ZengWei
* Description 下去载文件
* Date 2021/4/7
* @param response
* @param filePath
* @param fileName
* @return void
**/
public void downLoadFile(HttpServletResponse response, String filePath, String fileName) throws IOException {
response.setHeader("content-type", "application/octet-stream");
response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8"));
ServletOutputStream outputStream = response.getOutputStream();
InputStream inputStream = new FileInputStream(new File(filePath));
IOUtils.copy(inputStream, outputStream);
outputStream.flush();
inputStream.close();
outputStream.close();
}
/**
* @author ZengWei
* Description 获取文件编码
* Date 2021/4/7
* @param file
* @return java.lang.String
**/
public String codeString(File file) throws Exception {
BufferedInputStream bin = new BufferedInputStream(new FileInputStream(file));
int p = (bin.read() << 8) + bin.read();
bin.close();
String code = null;
switch (p) {
case 0xefbb:
code = "UTF-8";
break;
case 0xfffe:
code = "Unicode";
break;
case 0xfeff:
code = "UTF-16BE";
break;
default:
code = "GBK";
}
return code;
}
public void writeStringToFile(String s, String fileName, String path ){
try {
Path directory = Paths.get(path);
Files.createDirectories(directory); // 创建目录如果目录已存在则清空
Path filePath = directory.resolve(fileName);
Files.write(filePath, s.getBytes());
} catch (IOException iox) {
iox.printStackTrace();
}
}
}

View File

@ -0,0 +1,50 @@
package com.ruoyi.wiki.refactoring.utils;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class GetIpByRequestUtils {
/**
* 获取请求ip
* @param request
* @return
*/
public static String getIP(HttpServletRequest request){
String ip = request.getRemoteAddr();
String headerIP = request.getHeader("x-real-ip");
if(headerIP == null || "".equals(headerIP) || "null".equals(headerIP)){
headerIP = request.getHeader("x-forwarded-for");
}
System.out.println("headerIP:"+headerIP);
if(headerIP !=null && !"".equals(headerIP) && !"null".equals(headerIP)){
ip = headerIP;
}
return ip;
}
/**
* 获取真实的ip
* @param request
* @return
* @throws UnknownHostException
*/
public static String getRealIp(HttpServletRequest request){
String ip;
// 有的user可能使用代理为处理用户使用代理的情况使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if ("127.0.0.1".equals(ip)) {
try {
// 获取本机真正的ip地址
ip = InetAddress.getLocalHost().getHostAddress();
}catch (Exception e){
e.printStackTrace();
}
}
return ip;
}
}

View File

@ -0,0 +1,379 @@
package com.ruoyi.wiki.refactoring.utils;
import com.ruoyi.wiki.refactoring.response.HttpClientResult;
import org.apache.http.*;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.*;
import java.util.Map.Entry;
public class HttpClientUtils {
private static final Logger logger = LoggerFactory.getLogger(HttpClientUtils.class);
// 编码格式发送编码格式统一用UTF-8
private static final String ENCODING = "UTF-8";
// 设置连接超时时间单位毫秒
private static final int CONNECT_TIMEOUT = 6000;
// 请求获取数据的超时时间(即响应时间)单位毫秒
private static final int SOCKET_TIMEOUT = 6000;
/**
* 发送get请求不带请求头和请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public static HttpClientResult doGet(String url) throws Exception {
return doGet(url, null, null);
}
/**
* 发送get请求带请求参数
*
* @param url 请求地址
* @param params 请求参数集合
* @return
* @throws Exception
*/
public static HttpClientResult doGet(String url, Map<String, String> params) throws Exception {
return doGet(url, null, params);
}
/**
* 发送get请求带请求头和请求参数
*
* @param url 请求地址
* @param headers 请求头集合
* @param params 请求参数集合
* @return
* @throws Exception
*/
public static HttpClientResult doGet(String url, Map<String, String> headers, Map<String, String> params) throws Exception {
// 创建httpClient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建访问的地址
URIBuilder uriBuilder = new URIBuilder(url);
if (params != null) {
Set<Entry<String, String>> entrySet = params.entrySet();
for (Entry<String, String> entry : entrySet) {
uriBuilder.setParameter(entry.getKey(), entry.getValue());
}
}
// 创建http对象
HttpGet httpGet = new HttpGet(uriBuilder.build());
/**
* setConnectTimeout设置连接超时时间单位毫秒
* setConnectionRequestTimeout设置从connect Manager(连接池)获取Connection
* 超时时间单位毫秒这个属性是新加的属性因为目前版本是可以共享连接池的
* setSocketTimeout请求获取数据的超时时间(即响应时间)单位毫秒 如果访问一个接口多少时间内无法返回数据就直接放弃此次调用
*/
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
httpGet.setConfig(requestConfig);
// 设置请求头
packageHeader(headers, httpGet);
// 创建httpResponse对象
CloseableHttpResponse httpResponse = null;
try {
// 执行请求并获得响应结果
return getHttpClientResult(httpResponse, httpClient, httpGet);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}finally {
// 释放资源
release(httpResponse, httpClient);
}
}
/**
* 发送post请求不带请求头和请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public static HttpClientResult doPost(String url) throws Exception {
return doPost(url, null, null);
}
/**
* 发送post请求带请求参数
*
* @param url 请求地址
* @param params 参数集合
* @return
* @throws Exception
*/
public static HttpClientResult doPost(String url, Map<String, String> params) throws Exception {
return doPost(url, null, params);
}
/**
* 发送post请求带请求头和请求参数
*
* @param url 请求地址
* @param headers 请求头集合
* @param params 请求参数集合
* @return
* @throws Exception
*/
public static HttpClientResult doPost(String url, Map<String, String> headers, Map<String, String> params) throws Exception {
// 创建httpClient对象
CloseableHttpClient httpClient = HttpClients.createDefault();
// 创建http对象
HttpPost httpPost = new HttpPost(url);
/**
* setConnectTimeout设置连接超时时间单位毫秒
* setConnectionRequestTimeout设置从connect Manager(连接池)获取Connection
* 超时时间单位毫秒这个属性是新加的属性因为目前版本是可以共享连接池的
* setSocketTimeout请求获取数据的超时时间(即响应时间)单位毫秒 如果访问一个接口多少时间内无法返回数据就直接放弃此次调用
*/
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
httpPost.setConfig(requestConfig);
// 设置请求头
/*httpPost.setHeader("Cookie", "");
httpPost.setHeader("Connection", "keep-alive");
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Accept-Language", "zh-CN,zh;q=0.9");
httpPost.setHeader("Accept-Encoding", "gzip, deflate, br");
httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");*/
packageHeader(headers, httpPost);
// 封装请求参数
packageParam(params, httpPost);
// 创建httpResponse对象
CloseableHttpResponse httpResponse = null;
try {
// 执行请求并获得响应结果
return getHttpClientResult(httpResponse, httpClient, httpPost);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
finally {
// 释放资源
if (httpResponse != null) {
release(httpResponse, httpClient);
}
}
}
/**
* 发送put请求不带请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public static HttpClientResult doPut(String url) throws Exception {
return doPut(url);
}
/**
* 发送put请求带请求参数
*
* @param url 请求地址
* @param params 参数集合
* @return
* @throws Exception
*/
public static HttpClientResult doPut(String url, Map<String, String> params) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPut httpPut = new HttpPut(url);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
httpPut.setConfig(requestConfig);
packageParam(params, httpPut);
CloseableHttpResponse httpResponse = null;
try {
return getHttpClientResult(httpResponse, httpClient, httpPut);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}finally {
release(httpResponse, httpClient);
}
}
public static HttpClientResult doPatch(String url, Map<String, String> params) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPatch httpPatch = new HttpPatch(url);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
httpPatch.setConfig(requestConfig);
packageParam(params, httpPatch);
CloseableHttpResponse httpResponse = null;
try {
return getHttpClientResult(httpResponse, httpClient, httpPatch);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}finally {
release(httpResponse, httpClient);
}
}
/**
* 发送delete请求不带请求参数
*
* @param url 请求地址
* @return
* @throws Exception
*/
public static HttpClientResult doDelete(String url) throws Exception {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpDelete httpDelete = new HttpDelete(url);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
httpDelete.setConfig(requestConfig);
httpDelete.setHeader("accept","application/json");
CloseableHttpResponse httpResponse = null;
try {
return getHttpClientResult(httpResponse, httpClient, httpDelete);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}finally {
release(httpResponse, httpClient);
}
}
/**
* 发送delete请求带请求参数
*
* @param url 请求地址
* @param params 参数集合
* @return
* @throws Exception
*/
public static HttpClientResult doDelete(String url, Map<String, String> params) throws Exception {
if (params == null) {
params = new HashMap<String, String>();
}
params.put("_method", "delete");
return doPost(url, params);
}
/**
* Description: 封装请求头
* @param params
* @param httpMethod
*/
public static void packageHeader(Map<String, String> params, HttpRequestBase httpMethod) {
// 封装请求头
if (params != null) {
Set<Entry<String, String>> entrySet = params.entrySet();
for (Entry<String, String> entry : entrySet) {
// 设置到请求头到HttpRequestBase对象中
httpMethod.setHeader(entry.getKey(), entry.getValue());
}
}
}
/**
* Description: 封装请求参数
*
* @param params
* @param httpMethod
* @throws UnsupportedEncodingException
*/
public static void packageParam(Map<String, String> params, HttpEntityEnclosingRequestBase httpMethod)
throws UnsupportedEncodingException {
// 封装请求参数
if (params != null) {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
Set<Entry<String, String>> entrySet = params.entrySet();
for (Entry<String, String> entry : entrySet) {
nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
// 设置到请求的http对象中
httpMethod.setEntity(new UrlEncodedFormEntity(nvps, ENCODING));
}
}
/**
* Description: 获得响应结果
*
* @param httpResponse
* @param httpClient
* @param httpMethod
* @return
* @throws Exception
*/
public static HttpClientResult getHttpClientResult(CloseableHttpResponse httpResponse,
CloseableHttpClient httpClient, HttpRequestBase httpMethod) throws Exception {
if (httpMethod instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) httpMethod).getEntity();
if (entity != null) {
logger.info("Request Body: " + EntityUtils.toString(entity));
}
}
Header[] headers = httpMethod.getAllHeaders();
for (Header header : headers) {
logger.info("Request Header: " + header.getName() + ": " + header.getValue());
}
// 执行请求
httpResponse = httpClient.execute(httpMethod);
// 获取返回结果
if (httpResponse != null && httpResponse.getStatusLine() != null) {
String content = "";
if (httpResponse.getEntity() != null) {
content = EntityUtils.toString(httpResponse.getEntity(), ENCODING);
}
return new HttpClientResult(httpResponse.getStatusLine().getStatusCode(), content);
}
return new HttpClientResult(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
/**
* Description: 释放资源
*
* @param httpResponse
* @param httpClient
* @throws IOException
*/
public static void release(CloseableHttpResponse httpResponse, CloseableHttpClient httpClient) throws IOException {
// 释放资源
if (httpResponse != null) {
httpResponse.close();
}
if (httpClient != null) {
httpClient.close();
}
}
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.wiki.refactoring.utils;
import java.util.Random;
public class IDUtils {
public static String getFileName() {
//取当前时间的长整形值包含毫秒
long millis = System.currentTimeMillis();
//long millis = System.nanoTime();
//加上三位随机数
Random random = new Random();
int end3 = random.nextInt(999);
//如果不足三位前面补0
String str = millis + String.format("%03d", end3);
return str;
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.wiki.refactoring.utils;
import com.vladsch.flexmark.ext.tables.TablesExtension;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.Node;
import org.springframework.stereotype.Component;
import java.util.Collections;
@Component
public class MarkdownUtil {
public static String convertToHtml(String markdown) {
// 创建解析器和渲染器
Parser parser = Parser.builder()
.extensions(Collections.singletonList(TablesExtension.create()))
.build();
HtmlRenderer renderer = HtmlRenderer.builder()
// 如果需要自定义渲染器可以在这里添加
.build();
// 解析 Markdown
Node document = parser.parse(markdown);
// 渲染为 HTML
return renderer.render(document);
}
}

View File

@ -0,0 +1,45 @@
package com.ruoyi.wiki.refactoring.utils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import javax.validation.Validation;
import javax.validation.Validator;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ValidatorUtils {
private static final Validator VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator();
private static final String ERROR_PARAMS = "错误参数:";
private static final String ERROR_TIPS = ",错误提示:";
public static String buildValidationdErrorMessage(BindingResult bindingResult) {
StringBuilder sBuild = new StringBuilder();
List<FieldError> errList = bindingResult.getFieldErrors();
for (FieldError error : errList) {
sBuild.append(ERROR_PARAMS).append(error.getField()).append(ERROR_TIPS).append(error.getDefaultMessage()).append("|");
}
return sBuild.toString();
}
public static String parseGBK(String sIn)
throws UnsupportedEncodingException {
return StringUtils.isEmpty(sIn) ? sIn : new String(sIn.getBytes("GBK"), "ISO-8859-1");
}
public static Map<String, String> buildValidationErrorMessageMap(BindingResult bindingResult) {
Map<String, String> errorMessageMap = new HashMap<>();
List<FieldError> errList = bindingResult.getFieldErrors();
for (FieldError error : errList) {
errorMessageMap.put(error.getField(), error.getDefaultMessage());
}
return errorMessageMap;
}
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.wiki.service.sys;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.wiki.domain.sys.Token;
public interface TokenService extends IService<Token> {
Token getToken(String action, String key);
Token getTokenByUser(int userId, String action);
int updateByPrimaryKey(Token record);
}

View File

@ -0,0 +1,9 @@
package com.ruoyi.wiki.service.sys;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.wiki.domain.sys.UserExtension;
public interface UserExtentionService extends IService<UserExtension> {
UserExtension getUserExtensionByUserId(int userId);
}

View File

@ -0,0 +1,23 @@
package com.ruoyi.wiki.service.sys;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.wiki.domain.sys.User;
import com.ruoyi.wiki.domain.sys.UserVo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
public interface UserService extends IService<User> {
UserVo getCurrentUser(HttpServletRequest request);
UserVo getUserByToken(String key);
User getUserByLogin(String login);
String getUserImages(String login);
String getRemoteUserLogoByUserLogin(String login);
}

View File

@ -0,0 +1,36 @@
package com.ruoyi.wiki.service.sys.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.wiki.domain.sys.Token;
import com.ruoyi.wiki.mapper.sys.TokenMapper;
import com.ruoyi.wiki.service.sys.TokenService;
import org.springframework.stereotype.Service;
@Service
public class TokenServiceImpl extends ServiceImpl<TokenMapper, Token> implements TokenService {
@Override
public Token getToken(String action, String key) {
QueryWrapper wrapper = new QueryWrapper<Token>();
wrapper.eq("action", action);
wrapper.eq("value", key);
return baseMapper.selectOne(wrapper);
}
@Override
public Token getTokenByUser(int userId, String action) {
QueryWrapper wrapper = new QueryWrapper<Token>();
wrapper.eq("action", action);
wrapper.eq("user_id", userId);
return baseMapper.selectOne(wrapper);
}
@Override
public int updateByPrimaryKey(Token record) {
return baseMapper.updateByPrimaryKey(record);
}
}

View File

@ -0,0 +1,20 @@
package com.ruoyi.wiki.service.sys.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.wiki.domain.sys.UserExtension;
import com.ruoyi.wiki.mapper.sys.UserExtensionMapper;
import com.ruoyi.wiki.service.sys.UserExtentionService;
import org.springframework.stereotype.Service;
@Service
public class UserExtensionServiceImpl extends ServiceImpl<UserExtensionMapper, UserExtension> implements UserExtentionService {
@Override
public UserExtension getUserExtensionByUserId(int userId) {
QueryWrapper<UserExtension> wrapper = new QueryWrapper<>();
wrapper.eq("user_id", userId);
return baseMapper.selectOne(wrapper);
}
}

View File

@ -0,0 +1,149 @@
package com.ruoyi.wiki.service.sys.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.wiki.refactoring.constant.Constants;
import com.ruoyi.wiki.refactoring.response.HttpClientResult;
import com.ruoyi.wiki.refactoring.utils.CookieUtil;
import com.ruoyi.wiki.refactoring.utils.FastJsonUtils;
import com.ruoyi.wiki.refactoring.utils.HttpClientUtils;
import com.ruoyi.wiki.domain.sys.Token;
import com.ruoyi.wiki.domain.sys.User;
import com.ruoyi.wiki.domain.sys.UserExtension;
import com.ruoyi.wiki.domain.sys.UserVo;
import com.ruoyi.wiki.mapper.sys.UserMapper;
import com.ruoyi.wiki.service.sys.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.text.MessageFormat;
import java.util.*;
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Value("${military-server-static-path}")
private String militaryServerStaticPath;
@Value("${military-server-user-logo-path}")
private String militaryServerUserLogoPath;
@Value("${trustie_or_military_host}")
private String trustieOrMilitaryHost;
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private TokenService tokenService;
@Autowired
private UserExtentionService extentionService;
@Override
public UserVo getCurrentUser(HttpServletRequest request) {
String key = CookieUtil.getToken(Constants.COOKIE_NAME, request);
if (key == null) {
key = request.getParameter("token");
}
if(key == null){
return getVisitor();
}
logger.info("==token:{}", key);
return this.getUserByToken(key);
}
public UserVo getUserByToken(String key) {
Token token = tokenService.getToken(Constants.TOKEN_ACTION, key);
if(token == null){
return getVisitor();
}
User user = baseMapper.selectByPrimaryKey(token.getUserId());
if(user != null){
UserVo vo = getUserVo(user);
vo.setToken(key);
return vo;
}
return getVisitor();
}
@Override
public User getUserByLogin(String login) {
QueryWrapper<User> wrapper = new QueryWrapper<>();
wrapper.eq("login", login);
List<User> users = baseMapper.selectList(wrapper);
return CollectionUtils.isEmpty(users)?null : users.get(0);
}
@Override
public String getUserImages(String login) {
User user = getUserByLogin(login);
if(user == null){
return "images/avatars/User/b";
}
UserExtension extension = extentionService.getUserExtensionByUserId(user.getId());
String img = extension.getGender().intValue() == 0 ? "b" : "g";
return "images/avatars/User/" + img;
}
private UserVo getUserVo(User user) {
UserExtension extension = extentionService.getUserExtensionByUserId(user.getId());
UserVo userVo = new UserVo();
String name = user.getFirstname()+user.getLastname();
userVo.setUsername(StringUtils.isEmpty(name)? user.getNickname() : name);
userVo.setAdmin(user.getAdmin());
userVo.setLogin(user.getLogin());
userVo.setReal_name(StringUtils.isEmpty(name)? user.getNickname() : name);
userVo.setUser_id(user.getId().toString());
String img = extension == null || extension.getGender() == null || extension.getGender() == 0 ? "boy.jpg" : "girl.jpg";
userVo.setImage_url("avatars/User/"+img);
userVo.setImage_url(this.getRemoteUserLogoByUserLogin(user.getLogin()));
userVo.setGiteaToken(user.getGiteaToken());
return userVo;
}
private UserVo getVisitor(){
UserVo user = new UserVo();
user.setUsername("游客");
user.setLogin("");
return user;
}
public String getUserLogoByUserId(Integer userId) {
UserExtension extension = extentionService.getUserExtensionByUserId(userId);
String userLogo = militaryServerUserLogoPath + userId.toString();
File file = new File(militaryServerStaticPath + userLogo);
if (file.exists()) {
return userLogo;
}
String img = extension.getGender() == null || extension.getGender() == 0 ? "boy.jpg" : "girl.jpg";
return militaryServerUserLogoPath + img;
}
@Override
public String getRemoteUserLogoByUserLogin(String login) {
Map map = this.getRemoteUserInfoByLogin(login);
return null == map ? "" : (null == map.get("image_url") ? "" : map.get("image_url").toString());
}
private Map getRemoteUserInfoByLogin(String login) {
try {
String url = MessageFormat.format("{0}/api/users/{1}.json", trustieOrMilitaryHost, login);
HttpClientResult result = HttpClientUtils.doGet(url);
Map map = FastJsonUtils.stringToCollect(result.getContent());
return map;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,463 @@
package com.ruoyi.wiki.service.wiki;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.jhonnymertz.wkhtmltopdf.wrapper.Pdf;
import com.github.jhonnymertz.wkhtmltopdf.wrapper.configurations.WrapperConfig;
import com.github.jhonnymertz.wkhtmltopdf.wrapper.params.Param;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.wiki.domain.projects.Projects;
import com.ruoyi.wiki.domain.sys.User;
import com.ruoyi.wiki.domain.sys.UserVo;
import com.ruoyi.wiki.domain.wiki.vo.WikiCloneLinkVo;
import com.ruoyi.wiki.domain.wiki.vo.WikiPageVo;
import com.ruoyi.wiki.mapper.members.MembersMapper;
import com.ruoyi.wiki.mapper.projects.ProjectsMapper;
import com.ruoyi.wiki.mapper.team_projects.TeamProjectsMapper;
import com.ruoyi.wiki.domain.wiki.Wiki;
import com.ruoyi.wiki.domain.wiki.WikiContentSimple;
import com.ruoyi.wiki.domain.wiki.WikiPage;
import com.ruoyi.wiki.domain.wiki.vo.WikiVo;
import com.ruoyi.wiki.refactoring.response.HttpClientResult;
import com.ruoyi.wiki.refactoring.utils.*;
import com.ruoyi.wiki.service.sys.UserService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
@Component
public class WikiService {
@Autowired
private FileUtils fileUtils;
@Resource
private ProjectsMapper projectsMapper;
@Resource
private MembersMapper membersMapper;
@Resource
private TeamProjectsMapper teamProjectsMapper;
@Value("${trustie_or_military_host}")
private String trustieOrMilitaryHost;
@Autowired
private UserService userService;
Logger logger = LoggerFactory.getLogger(this.getClass());
private final Map<String, String> userLogoCache = new ConcurrentHashMap<>();
public String getGiteaToken(HttpServletRequest request, Integer projectId) {
UserVo user = userService.getCurrentUser(request);
Integer userId = user.getUser_id() == null ? null : Integer.parseInt(user.getUser_id());
//如果用户无权限抛出异常
if (!this.canViewWiki(userId, projectId)) {
throw new ServiceException("项目私有/非项目成员");
}
return user.getGiteaToken();
}
public HttpClientResult getWikiPages(String owner, String repo, String URL, String giteaToken) throws Exception {
String urlFormat = String.format("/repos/%s/%s/wiki/pages?page=1&limit=9999", owner, repo);
if (giteaToken != null) {
urlFormat += "&access_token=" + giteaToken;
}
String completeUrl = URL + urlFormat;
logger.info("completeUrl:" + completeUrl);
HttpClientResult httpClientResult = HttpClientUtils.doGet(completeUrl, null);
logger.info("httpClientResultCode:" + httpClientResult.getCode());
return httpClientResult;
}
public List<WikiPageVo> getWikiPageVoList(String giteaHttpsDomain, String giteaSSHDomain, String owner, String repo, HttpClientResult httpClientResult) {
List<WikiPageVo> wikiPageVoList = JSONObject.parseArray(httpClientResult.getContent(), WikiPageVo.class);
WikiCloneLinkVo wikiCloneLinkVo = new WikiCloneLinkVo();
wikiCloneLinkVo.setHttps(giteaHttpsDomain + "/" + owner + "/" + repo + ".wiki.git");
wikiCloneLinkVo.setSsh(giteaSSHDomain + ":" + owner + "/" + repo + ".wiki.git");
if (wikiPageVoList != null) {
ForkJoinPool forkJoinPool = new ForkJoinPool(20);
ForkJoinTask<?> fs = forkJoinPool.submit(() -> wikiPageVoList.parallelStream().forEach(wikiPageVo -> {
if (wikiPageVo.getLast_commit() != null && wikiPageVo.getLast_commit().getAuthor() != null) {
User commitUser = userService.getUserByLogin(wikiPageVo.getLast_commit().getAuthor().getName());
String userName = null;
if (commitUser != null) {
userName = StringUtils.isEmpty(commitUser.getNickname()) ? commitUser.getLogin() : commitUser.getNickname();
}
wikiPageVo.setUserName(userName);
wikiPageVo.setImage_url(this.getRemoteUserLogoByUserLoginWithCache(wikiPageVo.getLast_commit().getAuthor().getName()));
wikiPageVo.setWiki_clone_link(wikiCloneLinkVo);
}
}));
fs.join(); // 等待所有任务完成
forkJoinPool.shutdown(); // 关闭线程池
}
return wikiPageVoList;
}
public HttpClientResult getWiki(String owner, String repo, String pageName, String URL, String giteaToken) throws Exception {
String urlFormat = String.format("/repos/%s/%s/wiki/page/%s", owner, repo, pageName);
if (giteaToken != null) {
urlFormat += "?access_token=" + giteaToken;
}
String completeUrl = URL + urlFormat;
logger.info("completeUrl: " + completeUrl);
return HttpClientUtils.doGet(completeUrl, null, null);
}
public HttpClientResult createWiki(Wiki wiki, String token, String URL) throws Exception {
String owner = wiki.getOwner();
String repo = wiki.getRepo();
String urlFormat = String.format("/repos/%s/%s/wiki/new?access_token=%s", owner, repo, token);
Map<String, String> params;
WikiVo wikiVo = BeanCopyUtils.beanPropertiesCopy(wiki, WikiVo.class);
params = ConvertBean.convertToStringMap(wikiVo);
logger.info("completeUrl: " + URL + urlFormat);
String completeUrl = URL + urlFormat;
return HttpClientUtils.doPost(completeUrl, null, params);
}
public HttpClientResult deleteWiki(Wiki wiki, String giteaToken, String URL) throws Exception {
String owner = wiki.getOwner();
String repo = wiki.getRepo();
String pageName = wiki.getTitle();
String urlFormat = String.format("/repos/%s/%s/wiki/page/%s?access_token=%s", owner, repo, pageName, giteaToken);
String completeUrl = URL + urlFormat;
logger.info("delete completeUrl " + completeUrl);
return HttpClientUtils.doDelete(completeUrl);
}
public HttpClientResult updateWiki(Wiki wiki, String giteaToken, String URL) throws Exception {
String owner = wiki.getOwner();
String repo = wiki.getRepo();
String pageName = wiki.getName();
String urlFormat = String.format("/repos/%s/%s/wiki/page/%s?access_token=%s", owner, repo, pageName, giteaToken);
WikiVo wikiVo = BeanCopyUtils.beanPropertiesCopy(wiki, WikiVo.class);
String completeUrl = URL + urlFormat;
logger.info("completeUrl: " + completeUrl);
return HttpClientUtils.doPatch(completeUrl, ConvertBean.convertToStringMap(wikiVo));
}
public String StringToURLEncode(String s) throws UnsupportedEncodingException {
s = java.net.URLEncoder.encode(s, "UTF-8").replaceAll("\\+", "%20").replaceAll("\\*", "%2A");
//如果encodeInput以-结尾就在后面接上.-
if (s.endsWith("-")) {
s += ".-";
};
return s;
}
public void exportWikiToPdf(HttpServletResponse response, String toPdfToolPath, String owner, String repoName,
String URL, String destPath, String giteaToken) throws Exception {
WrapperConfig wrapperConfig = new WrapperConfig(toPdfToolPath);
Pdf pdf = new Pdf(wrapperConfig);
// String wkhtmltopdfCommand = "D:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe";
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, URL, giteaToken);
String content = httpClientResult.getContent();
List<WikiPage> wikiPages = FastJsonUtils.toList(content, WikiPage.class);
for (WikiPage wikiPage : wikiPages) {
if ("".equals(wikiPage.getTitle()) || "_Sidebar".equals(wikiPage.getTitle())) {
continue;
}
HttpClientResult httpClientResult1 = this.getWiki(owner, repoName, wikiPage.getSub_url(), URL, giteaToken);
if (httpClientResult1.getCode() == 200) {
WikiContentSimple wikiContentSimple = FastJsonUtils.toBean(httpClientResult1.getContent(), WikiContentSimple.class);
wikiContentSimple.setSimple_content(MarkdownUtil.convertToHtml(wikiContentSimple.getContent_base64()));
pdf.addPageFromString(wikiContentSimple.getSimple_content().replaceAll("/api/attachments", trustieOrMilitaryHost + "/api/attachments"));
// logger.info("wikiContent" + wikiContentSimple.getSimple_content());
}
}
pdf.setAllowMissingAssets();
// Add a Table of Contents
pdf.addToc();
pdf.addTocParam(new Param("--toc-header-text", "目录"));
// The `wkhtmltopdf` shell command accepts different types of options such as global, page, headers and footers, and toc. Please see `wkhtmltopdf -H` for a full explanation.
// All options are passed as array, for example:
// pdf.addParam(new Param("--no-footer-line"), new Param("--header-html", "file:///header.html"));
// pdf.addParam(new Param("--enable-javascript"));
pdf.addParam(new Param("--footer-center", "[page]/[toPage]"));
pdf.addParam(new Param("--encoding", "UTF-8"));
pdf.addParam(new Param("--javascript-delay", "10000"));
// Add styling for Table of Contents
// pdf.addTocParam(new Param("--xsl-style-sheet", "my_toc.xsl"));
String pdfName = repoName + ".pdf";
String completeDestPath = destPath + pdfName;
// Save the PDF
pdf.saveAs(completeDestPath);
logger.info("导出cmd命令" + pdf.getCommand());
try {
fileUtils.downLoadFile(response, completeDestPath, pdfName);
//文件下载完毕删除临时文件
org.apache.commons.io.FileUtils.forceDelete(new File(completeDestPath));
pdf.cleanAllTempFiles();
} catch (IOException e) {
logger.warn("delete scratch pdf file fail: " + completeDestPath);
}
}
public void exportWikiToMd(HttpServletResponse response, String owner, String repoName, String URL,
String destPath, String giteaToken) throws Exception {
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, URL, giteaToken);
String content = httpClientResult.getContent();
List<WikiPage> wikiPages = FastJsonUtils.toList(content, WikiPage.class);
String dirPath = destPath + File.separator + repoName;
for (WikiPage wikiPage : wikiPages) {
if ("".equals(wikiPage.getTitle()) || "_Sidebar".equals(wikiPage.getTitle())) {
continue;
}
HttpClientResult httpClientResult1 = this.getWiki(owner, repoName, wikiPage.getSub_url(), URL, giteaToken);
if (httpClientResult1.getCode() == 200) {
WikiContentSimple wikiContentSimple = FastJsonUtils.toBean(httpClientResult1.getContent(), WikiContentSimple.class);
fileUtils.writeStringToFile(wikiContentSimple.getContent_base64(), wikiContentSimple.getTitle() + ".md", dirPath);
logger.info("wikiContent" + wikiContentSimple.getSimple_content());
}
}
downLoadZip(response, repoName, dirPath);
}
public void exportWikiToHtml(HttpServletResponse response, String owner, String repoName, String URL,
String destPath, String projectName, String giteaToken) throws Exception {
HttpClientResult httpClientResult = this.getWikiPages(owner, repoName, URL, giteaToken);
String content = httpClientResult.getContent();
List<WikiPage> wikiPages = FastJsonUtils.toList(content, WikiPage.class);
String dirPath = destPath + File.separator + repoName;
StringBuilder htmlContent = new StringBuilder(this.initHtmlContent(projectName));
for (WikiPage wikiPage : wikiPages) {
if ("".equals(wikiPage.getTitle()) || "_Sidebar".equals(wikiPage.getTitle())) {
continue;
}
HttpClientResult httpClientResult1 = this.getWiki(owner, repoName, wikiPage.getSub_url(), URL, giteaToken);
if (httpClientResult1.getCode() == 200) {
WikiContentSimple wikiContentSimple = FastJsonUtils.toBean(httpClientResult1.getContent(), WikiContentSimple.class);
wikiContentSimple.setSimple_content(MarkdownUtil.convertToHtml(wikiContentSimple.getContent_base64()));
htmlContent.append("<div class=\"wiki-content-title\">");
htmlContent.append(wikiPage.getTitle());
htmlContent.append("</div>");
htmlContent.append("<div class=\"wiki-content-detail editor-content-panel markdown-body\">");
htmlContent.append(wikiContentSimple.getSimple_content().replaceAll("/api/attachments", trustieOrMilitaryHost + "/api/attachments"));
htmlContent.append("</div>");
}
}
fileUtils.writeStringToFile(htmlContent.toString(), "index.html", dirPath);
downLoadZip(response, repoName, dirPath);
}
public HttpClientResult createWikiByUploadFile(String giteaApiDomain, String giteaApiBaseUrl, String owner, String repoName, MultipartFile multipartFile, String fileName, String giteaToken) {
String suffix = fileName.lastIndexOf(".") > -1 ? fileName.substring(fileName.lastIndexOf(".")) : "";
if (!(".md".equals(suffix) || ".markdown".equals(suffix) || ".txt".equals(suffix))) {
throw new RuntimeException("仅支持导入txt、markdown格式文件");
}
Wiki wiki = new Wiki();
this.buildWiki(owner, repoName, fileName, multipartFile, wiki);
HttpClientResult httpClientResult = null;
try {
httpClientResult = this.createWiki(wiki, giteaToken, giteaApiDomain + giteaApiBaseUrl);
} catch (Exception e) {
throw new RuntimeException(e);
}
return httpClientResult;
}
public boolean canViewWiki(Integer currentUserId, Integer projectId) {
Projects projects = projectsMapper.getProjectById(projectId);
//仓库不存在不可访问
if (projectId == null) {
logger.info("projectId is null");
return false;
}
//仓库公有可访问
if (projects != null && projects.getIsPublic()) {
return true;
}
//判断是否为仓库成员
if (projects != null) {
return (membersMapper.doesMemberExist(currentUserId, projectId) > 0)
|| (teamProjectsMapper.doesMemberExist(currentUserId, projectId) > 0);
}
return false;
}
public Boolean StringExist(String str){
return str.startsWith("-");
}
private void downLoadZip(HttpServletResponse response, String repoName, String dirPath) {
String completeDestPath = dirPath + ".zip";
String zipFileName = repoName + ".zip";
ZipUtil.zip(dirPath, completeDestPath, true);
try {
fileUtils.downLoadFile(response, completeDestPath, zipFileName);
//文件下载完毕删除临时文件
org.apache.commons.io.FileUtils.forceDelete(new File(completeDestPath));
org.apache.commons.io.FileUtils.forceDelete(new File(dirPath));
} catch (IOException e) {
logger.warn("delete scratch zip file fail: " + completeDestPath);
}
}
// 修改获取用户头像信息的方法
private String getRemoteUserLogoByUserLoginWithCache(String userName) {
return userLogoCache.computeIfAbsent(userName, userService::getRemoteUserLogoByUserLogin);
}
private void buildWiki(String owner, String repoName, String fileName, MultipartFile file, Wiki wiki) {
try {
String fileContent = new String(file.getBytes(), StandardCharsets.UTF_8);
String base64Content = Base64.getEncoder().encodeToString(fileContent.getBytes(StandardCharsets.UTF_8));
wiki.setOwner(owner);
wiki.setRepo(repoName);
wiki.setTitle(fileName.substring(0, fileName.lastIndexOf(".")));
wiki.setContent_base64(base64Content);
} catch (IOException e) {
logger.error("导入文件转字节流异常");
throw new RuntimeException("上传文件失败");
}
}
private void deleteScratchFile(String filePath) {
if(!filePath.isEmpty()){
try {
org.apache.commons.io.FileUtils.forceDelete(new File(filePath));
} catch (IOException e) {
logger.warn("delete scratch file fail: " + filePath);
}
}
}
private String initHtmlContent(String replaceString) {
if (replaceString == null) {
replaceString = "Trustie 3.0";
}
String htmlContent = "<!DOCTYPE html>\n" +
"<html lang=\"en\">\n" +
"\n" +
"<head>\n" +
" <meta charset=\"UTF-8\">\n" +
" <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n" +
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n" +
" <title>trustie 3.0</title>\n".replace("trustie 3.0", replaceString) +
" <style type=\"text/css\">\n" +
" body {\n" +
" margin: 0;\n" +
" padding: 0;\n" +
" overflow-y: scroll;\n" +
" }\n" +
"\n" +
" .preview-head {\n" +
" display: flex;\n" +
" justify-content: space-between;\n" +
" align-items: center;\n" +
" padding: 0 12rem 0 2rem;\n" +
" width: 100%;\n" +
" height: 80px;\n" +
" background: #272f4c;\n" +
" color: #fff;\n" +
" }\n" +
"\n" +
" .preview-head-left {\n" +
" display: inline-flex;\n" +
" align-items: center;\n" +
" font-size: 24px;\n" +
" cursor: pointer;\n" +
" }\n" +
"\n" +
" .preview-head-left svg {\n" +
" margin-right: 10px;\n" +
" font-size: 24px !important;\n" +
" font-weight: 700;\n" +
" }\n" +
"\n" +
" .content {\n" +
" width: 1200px;\n" +
" min-height: 400px;\n" +
" margin: 20px auto;\n" +
" }\n" +
"\n" +
" .wiki-content-title{\n" +
" margin-bottom: 10px;\n" +
" padding: 10px 0;\n" +
" font-size: 20px;\n" +
" font-weight: 700;\n" +
" border-bottom: 1px solid #bbb;\n" +
" }\n" +
"\n" +
" .wiki-content-detail {\n" +
" margin-bottom: 30px;\n" +
" word-break: break-all;\n" +
" }\n" +
"\n" +
" .markdown-body img{\n" +
" max-width: 100%;\n" +
" }\n" +
" @media screen and (max-width: 1200px){\n" +
" .content {\n" +
" width: 96%;\n" +
" }\n" +
" }\n" +
"\n" +
" </style>\n" +
"</head>\n" +
"\n" +
"<body>\n" +
" <div class=\"preview-head\">\n" +
" <div class=\"preview-head-left\"><svg width=\"26px\" height=\"26px\" viewBox=\"0 0 26 26\" version=\"1.1\">\n" +
" <title>文档预览_icon</title>\n" +
" <g id=\"页面设计\" stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n" +
" <g id=\"12-预览\" transform=\"translate(-53.000000, -27.000000)\" fill=\"#FFFFFF\" fill-rule=\"nonzero\">\n" +
" <g id=\"文档预览_icon\" transform=\"translate(53.000000, 27.000000)\">\n" +
" <g id=\"编组-3\" transform=\"translate(1.000000, 1.000000)\">\n" +
" <path\n" +
" d=\"M16.5,1.5 C16.0857864,1.5 15.75,1.16421356 15.75,0.749999997 C15.75,0.335786436 16.0857864,0 16.5,0 L20.8815,0 C22.605,0 24,1.39499999 24,3.11850001 L24,7.5 C24,7.7679492 23.8570508,8.01554448 23.625,8.14951908 C23.3929492,8.28349369 23.1070508,8.28349369 22.875,8.14951908 C22.6429492,8.01554448 22.5,7.7679492 22.5,7.5 L22.5,3.11850001 C22.5,2.22449999 21.7755,1.5 20.8815,1.5 L16.5,1.5 Z M22.5,16.1445 C22.5,15.8765508 22.6429492,15.6289555 22.875,15.4949809 C23.1070508,15.3610063 23.3929492,15.3610063 23.625,15.4949809 C23.8570508,15.6289555 24,15.8765508 24,16.1445 L24,20.8815 C24,22.605 22.605,24 20.8815,24 L17.9205,24 C17.6525508,24 17.4049555,23.8570508 17.2709809,23.625 C17.1370063,23.3929492 17.1370063,23.1070508 17.2709809,22.875 C17.4049555,22.6429492 17.6525508,22.5 17.9205,22.5 L20.8815,22.5 C21.7755,22.5 22.5,21.7755 22.5,20.8815 L22.5,16.1445 L22.5,16.1445 Z M7.85549999,22.5 C8.12344919,22.5 8.37104447,22.6429492 8.50501908,22.875 C8.63899369,23.1070508 8.63899369,23.3929492 8.50501908,23.625 C8.37104447,23.8570508 8.12344919,24 7.85549999,24 L3.11850001,24 C1.39620001,24 0,22.6038 0,20.8815 L0,16.5 C0,16.0857864 0.335786436,15.75 0.749999997,15.75 C1.16421356,15.75 1.5,16.0857864 1.5,16.5 L1.5,20.8815 C1.5,21.7755 2.22449999,22.5 3.11850001,22.5 L7.85549999,22.5 Z M1.5,7.5 C1.5,7.91421355 1.16421356,8.24999999 0.749999997,8.24999999 C0.335786436,8.24999999 0,7.91421355 0,7.5 L0,3.11850001 C0,1.39499999 1.39499999,0 3.11850001,0 L7.5,0 C7.91421355,0 8.24999999,0.335786436 8.24999999,0.749999997 C8.24999999,1.16421356 7.91421355,1.5 7.5,1.5 L3.11850001,1.5 C2.22449999,1.5 1.5,2.22449999 1.5,3.11850001 L1.5,7.5 Z M12,15.75 C14.5695,15.75 16.9605,14.4165 19.227,11.625 C16.9605,8.83349999 14.5695,7.49999999 12,7.49999999 C9.43050001,7.49999999 7.0395,8.83349999 4.773,11.625 C7.0395,14.4165 9.43050001,15.75 12,15.75 Z M12,17.25 C8.93849999,17.25 6.141,15.69 3.60900001,12.57 C3.16219028,12.0192218 3.16219028,11.2307782 3.60900001,10.68 C6.141,7.55999999 8.93849999,6 12,6 C15.0615,6 17.859,7.55999999 20.391,10.68 C20.8378097,11.2307782 20.8378097,12.0192218 20.391,12.57 C17.859,15.69 15.0615,17.25 12,17.25 Z\"\n" +
" id=\"形状\" stroke=\"#FFFFFF\" stroke-width=\"0.5\"></path>\n" +
" <path\n" +
" d=\"M12,13.5 C13.0355339,13.5 13.875,12.6605339 13.875,11.625 C13.875,10.5894661 13.0355339,9.75000001 12,9.75000001 C10.9644661,9.75000001 10.125,10.5894661 10.125,11.625 C10.125,12.6605339 10.9644661,13.5 12,13.5 Z M12,15 C10.7941616,15.0001005 9.67987806,14.3568511 9.07692987,13.3125812 C8.47398168,12.2683113 8.47398168,10.9816887 9.07692987,9.93741879 C9.67987806,8.89314889 10.7941616,8.2498995 12,8.24999999 C13.8638512,8.25015532 15.3747188,9.76114879 15.3747188,11.625 C15.3747188,13.4888512 13.8638512,14.9998447 12,15 Z\"\n" +
" id=\"形状\"></path>\n" +
" </g>\n" +
" </g>\n" +
" </g>\n" +
" </g>\n" +
" </svg>\n" +
" <!-- 项目名,请替换 -->\n" +
" <span class=\"ml10\">Trustie 3.0</span></div>\n".replace("Trustie 3.0", replaceString) +
" </div>\n" +
" <div class=\"content\">";
return htmlContent;
}
}

View File

@ -0,0 +1,27 @@
# Tomcat
server:
port: 9199
# Spring
spring:
application:
# 应用名称
name: ruoyi-wiki
config:
activate:
# 环境配置
on-profile:
prod
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: ${nacos_ip}:${nacos_port}
config:
# 配置中心地址
server-addr: ${nacos_ip}:${nacos_port}
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,25 @@
# Tomcat
server:
port: 9199
# Spring
spring:
application:
# 应用名称
name: ruoyi-wiki
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/ruoyi-wiki"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.wiki.mapper.members.MembersMapper" >
<resultMap id="BaseResultMap" type="com.ruoyi.wiki.domain.members.Members" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="project_id" property="projectId" jdbcType="INTEGER" />
<result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
<result column="mail_notification" property="mailNotification" jdbcType="BIT" />
<result column="course_id" property="courseId" jdbcType="INTEGER" />
<result column="course_group_id" property="courseGroupId" jdbcType="INTEGER" />
<result column="is_collect" property="isCollect" jdbcType="INTEGER" />
<result column="graduation_group_id" property="graduationGroupId" jdbcType="INTEGER" />
<result column="is_apply_signature" property="isApplySignature" jdbcType="BIT" />
</resultMap>
<sql id="Base_Column_List" >
id, user_id, project_id, created_on, mail_notification, course_id, course_group_id,
is_collect, graduation_group_id, is_apply_signature
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from members
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from members
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.ruoyi.wiki.domain.members.Members" >
insert into members (id, user_id, project_id,
created_on, mail_notification, course_id,
course_group_id, is_collect, graduation_group_id,
is_apply_signature)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{projectId,jdbcType=INTEGER},
#{createdOn,jdbcType=TIMESTAMP}, #{mailNotification,jdbcType=BIT}, #{courseId,jdbcType=INTEGER},
#{courseGroupId,jdbcType=INTEGER}, #{isCollect,jdbcType=INTEGER}, #{graduationGroupId,jdbcType=INTEGER},
#{isApplySignature,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="com.ruoyi.wiki.domain.members.Members" >
insert into members
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="userId != null" >
user_id,
</if>
<if test="projectId != null" >
project_id,
</if>
<if test="createdOn != null" >
created_on,
</if>
<if test="mailNotification != null" >
mail_notification,
</if>
<if test="courseId != null" >
course_id,
</if>
<if test="courseGroupId != null" >
course_group_id,
</if>
<if test="isCollect != null" >
is_collect,
</if>
<if test="graduationGroupId != null" >
graduation_group_id,
</if>
<if test="isApplySignature != null" >
is_apply_signature,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="projectId != null" >
#{projectId,jdbcType=INTEGER},
</if>
<if test="createdOn != null" >
#{createdOn,jdbcType=TIMESTAMP},
</if>
<if test="mailNotification != null" >
#{mailNotification,jdbcType=BIT},
</if>
<if test="courseId != null" >
#{courseId,jdbcType=INTEGER},
</if>
<if test="courseGroupId != null" >
#{courseGroupId,jdbcType=INTEGER},
</if>
<if test="isCollect != null" >
#{isCollect,jdbcType=INTEGER},
</if>
<if test="graduationGroupId != null" >
#{graduationGroupId,jdbcType=INTEGER},
</if>
<if test="isApplySignature != null" >
#{isApplySignature,jdbcType=BIT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.wiki.domain.members.Members" >
update members
<set >
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="projectId != null" >
project_id = #{projectId,jdbcType=INTEGER},
</if>
<if test="createdOn != null" >
created_on = #{createdOn,jdbcType=TIMESTAMP},
</if>
<if test="mailNotification != null" >
mail_notification = #{mailNotification,jdbcType=BIT},
</if>
<if test="courseId != null" >
course_id = #{courseId,jdbcType=INTEGER},
</if>
<if test="courseGroupId != null" >
course_group_id = #{courseGroupId,jdbcType=INTEGER},
</if>
<if test="isCollect != null" >
is_collect = #{isCollect,jdbcType=INTEGER},
</if>
<if test="graduationGroupId != null" >
graduation_group_id = #{graduationGroupId,jdbcType=INTEGER},
</if>
<if test="isApplySignature != null" >
is_apply_signature = #{isApplySignature,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.wiki.domain.members.Members" >
update members
set user_id = #{userId,jdbcType=INTEGER},
project_id = #{projectId,jdbcType=INTEGER},
created_on = #{createdOn,jdbcType=TIMESTAMP},
mail_notification = #{mailNotification,jdbcType=BIT},
course_id = #{courseId,jdbcType=INTEGER},
course_group_id = #{courseGroupId,jdbcType=INTEGER},
is_collect = #{isCollect,jdbcType=INTEGER},
graduation_group_id = #{graduationGroupId,jdbcType=INTEGER},
is_apply_signature = #{isApplySignature,jdbcType=BIT}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="doesMemberExist" resultType="java.lang.Integer">
select count(*)
from members
where user_id = #{userId} and project_id = #{projectId}
</select>
</mapper>

View File

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.wiki.mapper.projects.ProjectsMapper" >
<resultMap id="BaseResultMap" type="com.ruoyi.wiki.domain.projects.Projects" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="description" property="description" jdbcType="LONGVARCHAR" />
<result column="homepage" property="homepage" jdbcType="VARCHAR" />
<result column="is_public" property="isPublic" jdbcType="BIT" />
<result column="parent_id" property="parentId" jdbcType="INTEGER" />
<result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
<result column="updated_on" property="updatedOn" jdbcType="TIMESTAMP" />
<result column="identifier" property="identifier" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="lft" property="lft" jdbcType="INTEGER" />
<result column="rgt" property="rgt" jdbcType="INTEGER" />
<result column="inherit_members" property="inheritMembers" jdbcType="BIT" />
<result column="project_type" property="projectType" jdbcType="INTEGER" />
<result column="hidden_repo" property="hiddenRepo" jdbcType="BIT" />
<result column="attachmenttype" property="attachmenttype" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="dts_test" property="dtsTest" jdbcType="INTEGER" />
<result column="enterprise_name" property="enterpriseName" jdbcType="VARCHAR" />
<result column="organization_id" property="organizationId" jdbcType="INTEGER" />
<result column="project_new_type" property="projectNewType" jdbcType="INTEGER" />
<result column="gpid" property="gpid" jdbcType="INTEGER" />
<result column="forked_from_project_id" property="forkedFromProjectId" jdbcType="INTEGER" />
<result column="forked_count" property="forkedCount" jdbcType="INTEGER" />
<result column="publish_resource" property="publishResource" jdbcType="INTEGER" />
<result column="visits" property="visits" jdbcType="INTEGER" />
<result column="hot" property="hot" jdbcType="INTEGER" />
<result column="invite_code" property="inviteCode" jdbcType="VARCHAR" />
<result column="qrcode" property="qrcode" jdbcType="VARCHAR" />
<result column="qrcode_expiretime" property="qrcodeExpiretime" jdbcType="INTEGER" />
<result column="script" property="script" jdbcType="LONGVARCHAR" />
<result column="training_status" property="trainingStatus" jdbcType="TINYINT" />
<result column="rep_identifier" property="repIdentifier" jdbcType="VARCHAR" />
<result column="project_category_id" property="projectCategoryId" jdbcType="INTEGER" />
<result column="project_language_id" property="projectLanguageId" jdbcType="INTEGER" />
<result column="license_id" property="licenseId" jdbcType="INTEGER" />
<result column="ignore_id" property="ignoreId" jdbcType="INTEGER" />
<result column="praises_count" property="praisesCount" jdbcType="INTEGER" />
<result column="watchers_count" property="watchersCount" jdbcType="INTEGER" />
<result column="issues_count" property="issuesCount" jdbcType="INTEGER" />
<result column="pull_requests_count" property="pullRequestsCount" jdbcType="INTEGER" />
<result column="language" property="language" jdbcType="VARCHAR" />
<result column="versions_count" property="versionsCount" jdbcType="INTEGER" />
<result column="issue_tags_count" property="issueTagsCount" jdbcType="INTEGER" />
<result column="closed_issues_count" property="closedIssuesCount" jdbcType="INTEGER" />
<result column="open_devops" property="openDevops" jdbcType="BIT" />
<result column="gitea_webhook_id" property="giteaWebhookId" jdbcType="INTEGER" />
<result column="open_devops_count" property="openDevopsCount" jdbcType="INTEGER" />
<result column="recommend" property="recommend" jdbcType="BIT" />
<result column="platform" property="platform" jdbcType="INTEGER" />
<result column="order_index" property="orderIndex" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, name, description, homepage, is_public, parent_id, created_on, updated_on, identifier, status,
lft, rgt, inherit_members, project_type, hidden_repo, attachmenttype, user_id, dts_test,
enterprise_name, organization_id, project_new_type, gpid, forked_from_project_id,
forked_count, publish_resource, visits, hot, invite_code, qrcode, qrcode_expiretime,
script, training_status, rep_identifier, project_category_id, project_language_id, license_id,
ignore_id, praises_count, watchers_count, issues_count, pull_requests_count, language,
versions_count, issue_tags_count, closed_issues_count, open_devops, gitea_webhook_id,
open_devops_count, recommend, platform, order_index
</sql>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from projects
where id = #{id,jdbcType=INTEGER}
</delete>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.wiki.domain.projects.Projects" >
update projects
set name = #{name,jdbcType=VARCHAR},
homepage = #{homepage,jdbcType=VARCHAR},
is_public = #{isPublic,jdbcType=BIT},
parent_id = #{parentId,jdbcType=INTEGER},
created_on = #{createdOn,jdbcType=TIMESTAMP},
updated_on = #{updatedOn,jdbcType=TIMESTAMP},
identifier = #{identifier,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
lft = #{lft,jdbcType=INTEGER},
rgt = #{rgt,jdbcType=INTEGER},
inherit_members = #{inheritMembers,jdbcType=BIT},
project_type = #{projectType,jdbcType=INTEGER},
hidden_repo = #{hiddenRepo,jdbcType=BIT},
attachmenttype = #{attachmenttype,jdbcType=INTEGER},
user_id = #{userId,jdbcType=INTEGER},
dts_test = #{dtsTest,jdbcType=INTEGER},
enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
organization_id = #{organizationId,jdbcType=INTEGER},
project_new_type = #{projectNewType,jdbcType=INTEGER},
gpid = #{gpid,jdbcType=INTEGER},
forked_from_project_id = #{forkedFromProjectId,jdbcType=INTEGER},
forked_count = #{forkedCount,jdbcType=INTEGER},
publish_resource = #{publishResource,jdbcType=INTEGER},
visits = #{visits,jdbcType=INTEGER},
hot = #{hot,jdbcType=INTEGER},
invite_code = #{inviteCode,jdbcType=VARCHAR},
qrcode = #{qrcode,jdbcType=VARCHAR},
qrcode_expiretime = #{qrcodeExpiretime,jdbcType=INTEGER},
training_status = #{trainingStatus,jdbcType=TINYINT},
rep_identifier = #{repIdentifier,jdbcType=VARCHAR},
project_category_id = #{projectCategoryId,jdbcType=INTEGER},
project_language_id = #{projectLanguageId,jdbcType=INTEGER},
license_id = #{licenseId,jdbcType=INTEGER},
ignore_id = #{ignoreId,jdbcType=INTEGER},
praises_count = #{praisesCount,jdbcType=INTEGER},
watchers_count = #{watchersCount,jdbcType=INTEGER},
issues_count = #{issuesCount,jdbcType=INTEGER},
pull_requests_count = #{pullRequestsCount,jdbcType=INTEGER},
language = #{language,jdbcType=VARCHAR},
versions_count = #{versionsCount,jdbcType=INTEGER},
issue_tags_count = #{issueTagsCount,jdbcType=INTEGER},
closed_issues_count = #{closedIssuesCount,jdbcType=INTEGER},
open_devops = #{openDevops,jdbcType=BIT},
gitea_webhook_id = #{giteaWebhookId,jdbcType=INTEGER},
open_devops_count = #{openDevopsCount,jdbcType=INTEGER},
recommend = #{recommend,jdbcType=BIT},
platform = #{platform,jdbcType=INTEGER},
order_index = #{orderIndex,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getProjectByLoginAndIdentifier" resultMap="BaseResultMap" parameterType="com.ruoyi.wiki.domain.projects.Projects" >
select
id, is_public
from projects
where identifier = #{identifier} or identifier = #{identifier1}
</select>
<select id="getProjectById" resultMap="BaseResultMap" parameterType="com.ruoyi.wiki.domain.projects.Projects" >
select
is_public
from projects
where id = #{projectId}
</select>
</mapper>

View File

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.wiki.mapper.sys.TokenMapper" >
<resultMap id="BaseResultMap" type="com.ruoyi.wiki.domain.sys.Token" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="action" property="action" jdbcType="VARCHAR" />
<result column="value" property="value" jdbcType="VARCHAR" />
<result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
id, user_id, action, value, created_on
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from tokens
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from tokens
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.ruoyi.wiki.domain.sys.Token" >
insert into tokens (id, user_id, action,
value, created_on)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{action,jdbcType=VARCHAR},
#{value,jdbcType=VARCHAR}, #{createdOn,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.ruoyi.wiki.domain.sys.Token" >
insert into tokens
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="userId != null" >
user_id,
</if>
<if test="action != null" >
action,
</if>
<if test="value != null" >
value,
</if>
<if test="createdOn != null" >
created_on,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="action != null" >
#{action,jdbcType=VARCHAR},
</if>
<if test="value != null" >
#{value,jdbcType=VARCHAR},
</if>
<if test="createdOn != null" >
#{createdOn,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.wiki.domain.sys.Token" >
update tokens
<set >
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="action != null" >
action = #{action,jdbcType=VARCHAR},
</if>
<if test="value != null" >
value = #{value,jdbcType=VARCHAR},
</if>
<if test="createdOn != null" >
created_on = #{createdOn,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.wiki.domain.sys.Token" >
update tokens
set user_id = #{userId,jdbcType=INTEGER},
action = #{action,jdbcType=VARCHAR},
value = #{value,jdbcType=VARCHAR},
created_on = #{createdOn,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.wiki.mapper.sys.UserExtensionMapper" >
<resultMap id="BaseResultMap" type="com.ruoyi.wiki.domain.sys.UserExtension" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="birthday" property="birthday" jdbcType="DATE" />
<result column="brief_introduction" property="briefIntroduction" jdbcType="VARCHAR" />
<result column="gender" property="gender" jdbcType="INTEGER" />
<result column="location" property="location" jdbcType="VARCHAR" />
<result column="occupation" property="occupation" jdbcType="VARCHAR" />
<result column="work_experience" property="workExperience" jdbcType="INTEGER" />
<result column="zip_code" property="zipCode" jdbcType="INTEGER" />
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP" />
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP" />
<result column="identity" property="identity" jdbcType="INTEGER" />
<result column="technical_title" property="technicalTitle" jdbcType="VARCHAR" />
<result column="student_id" property="studentId" jdbcType="VARCHAR" />
<result column="teacher_realname" property="teacherRealname" jdbcType="VARCHAR" />
<result column="student_realname" property="studentRealname" jdbcType="VARCHAR" />
<result column="location_city" property="locationCity" jdbcType="VARCHAR" />
<result column="school_id" property="schoolId" jdbcType="INTEGER" />
<result column="description" property="description" jdbcType="VARCHAR" />
<result column="department_id" property="departmentId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="ResultMapWithBLOBs" type="com.ruoyi.wiki.domain.sys.UserExtension" extends="BaseResultMap" >
<result column="province" property="province" jdbcType="LONGVARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, user_id, birthday, brief_introduction, gender, location, occupation, work_experience,
zip_code, created_at, updated_at, identity, technical_title, student_id, teacher_realname,
student_realname, location_city, school_id, description, department_id
</sql>
<sql id="Blob_Column_List" >
province
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from user_extensions
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from user_extensions
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.ruoyi.wiki.domain.sys.UserExtension" >
insert into user_extensions (id, user_id, birthday,
brief_introduction, gender, location,
occupation, work_experience, zip_code,
created_at, updated_at, identity,
technical_title, student_id, teacher_realname,
student_realname, location_city, school_id,
description, department_id, province
)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{birthday,jdbcType=DATE},
#{briefIntroduction,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER}, #{location,jdbcType=VARCHAR},
#{occupation,jdbcType=VARCHAR}, #{workExperience,jdbcType=INTEGER}, #{zipCode,jdbcType=INTEGER},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{identity,jdbcType=INTEGER},
#{technicalTitle,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{teacherRealname,jdbcType=VARCHAR},
#{studentRealname,jdbcType=VARCHAR}, #{locationCity,jdbcType=VARCHAR}, #{schoolId,jdbcType=INTEGER},
#{description,jdbcType=VARCHAR}, #{departmentId,jdbcType=INTEGER}, #{province,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.ruoyi.wiki.domain.sys.UserExtension" >
insert into user_extensions
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="userId != null" >
user_id,
</if>
<if test="birthday != null" >
birthday,
</if>
<if test="briefIntroduction != null" >
brief_introduction,
</if>
<if test="gender != null" >
gender,
</if>
<if test="location != null" >
location,
</if>
<if test="occupation != null" >
occupation,
</if>
<if test="workExperience != null" >
work_experience,
</if>
<if test="zipCode != null" >
zip_code,
</if>
<if test="createdAt != null" >
created_at,
</if>
<if test="updatedAt != null" >
updated_at,
</if>
<if test="identity != null" >
identity,
</if>
<if test="technicalTitle != null" >
technical_title,
</if>
<if test="studentId != null" >
student_id,
</if>
<if test="teacherRealname != null" >
teacher_realname,
</if>
<if test="studentRealname != null" >
student_realname,
</if>
<if test="locationCity != null" >
location_city,
</if>
<if test="schoolId != null" >
school_id,
</if>
<if test="description != null" >
description,
</if>
<if test="departmentId != null" >
department_id,
</if>
<if test="province != null" >
province,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="birthday != null" >
#{birthday,jdbcType=DATE},
</if>
<if test="briefIntroduction != null" >
#{briefIntroduction,jdbcType=VARCHAR},
</if>
<if test="gender != null" >
#{gender,jdbcType=INTEGER},
</if>
<if test="location != null" >
#{location,jdbcType=VARCHAR},
</if>
<if test="occupation != null" >
#{occupation,jdbcType=VARCHAR},
</if>
<if test="workExperience != null" >
#{workExperience,jdbcType=INTEGER},
</if>
<if test="zipCode != null" >
#{zipCode,jdbcType=INTEGER},
</if>
<if test="createdAt != null" >
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null" >
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="identity != null" >
#{identity,jdbcType=INTEGER},
</if>
<if test="technicalTitle != null" >
#{technicalTitle,jdbcType=VARCHAR},
</if>
<if test="studentId != null" >
#{studentId,jdbcType=VARCHAR},
</if>
<if test="teacherRealname != null" >
#{teacherRealname,jdbcType=VARCHAR},
</if>
<if test="studentRealname != null" >
#{studentRealname,jdbcType=VARCHAR},
</if>
<if test="locationCity != null" >
#{locationCity,jdbcType=VARCHAR},
</if>
<if test="schoolId != null" >
#{schoolId,jdbcType=INTEGER},
</if>
<if test="description != null" >
#{description,jdbcType=VARCHAR},
</if>
<if test="departmentId != null" >
#{departmentId,jdbcType=INTEGER},
</if>
<if test="province != null" >
#{province,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.wiki.domain.sys.UserExtension" >
update user_extensions
<set >
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="birthday != null" >
birthday = #{birthday,jdbcType=DATE},
</if>
<if test="briefIntroduction != null" >
brief_introduction = #{briefIntroduction,jdbcType=VARCHAR},
</if>
<if test="gender != null" >
gender = #{gender,jdbcType=INTEGER},
</if>
<if test="location != null" >
location = #{location,jdbcType=VARCHAR},
</if>
<if test="occupation != null" >
occupation = #{occupation,jdbcType=VARCHAR},
</if>
<if test="workExperience != null" >
work_experience = #{workExperience,jdbcType=INTEGER},
</if>
<if test="zipCode != null" >
zip_code = #{zipCode,jdbcType=INTEGER},
</if>
<if test="createdAt != null" >
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null" >
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="identity != null" >
identity = #{identity,jdbcType=INTEGER},
</if>
<if test="technicalTitle != null" >
technical_title = #{technicalTitle,jdbcType=VARCHAR},
</if>
<if test="studentId != null" >
student_id = #{studentId,jdbcType=VARCHAR},
</if>
<if test="teacherRealname != null" >
teacher_realname = #{teacherRealname,jdbcType=VARCHAR},
</if>
<if test="studentRealname != null" >
student_realname = #{studentRealname,jdbcType=VARCHAR},
</if>
<if test="locationCity != null" >
location_city = #{locationCity,jdbcType=VARCHAR},
</if>
<if test="schoolId != null" >
school_id = #{schoolId,jdbcType=INTEGER},
</if>
<if test="description != null" >
description = #{description,jdbcType=VARCHAR},
</if>
<if test="departmentId != null" >
department_id = #{departmentId,jdbcType=INTEGER},
</if>
<if test="province != null" >
province = #{province,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.ruoyi.wiki.domain.sys.UserExtension" >
update user_extensions
set user_id = #{userId,jdbcType=INTEGER},
birthday = #{birthday,jdbcType=DATE},
brief_introduction = #{briefIntroduction,jdbcType=VARCHAR},
gender = #{gender,jdbcType=INTEGER},
location = #{location,jdbcType=VARCHAR},
occupation = #{occupation,jdbcType=VARCHAR},
work_experience = #{workExperience,jdbcType=INTEGER},
zip_code = #{zipCode,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
identity = #{identity,jdbcType=INTEGER},
technical_title = #{technicalTitle,jdbcType=VARCHAR},
student_id = #{studentId,jdbcType=VARCHAR},
teacher_realname = #{teacherRealname,jdbcType=VARCHAR},
student_realname = #{studentRealname,jdbcType=VARCHAR},
location_city = #{locationCity,jdbcType=VARCHAR},
school_id = #{schoolId,jdbcType=INTEGER},
description = #{description,jdbcType=VARCHAR},
department_id = #{departmentId,jdbcType=INTEGER},
province = #{province,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.wiki.domain.sys.UserExtension" >
update user_extensions
set user_id = #{userId,jdbcType=INTEGER},
birthday = #{birthday,jdbcType=DATE},
brief_introduction = #{briefIntroduction,jdbcType=VARCHAR},
gender = #{gender,jdbcType=INTEGER},
location = #{location,jdbcType=VARCHAR},
occupation = #{occupation,jdbcType=VARCHAR},
work_experience = #{workExperience,jdbcType=INTEGER},
zip_code = #{zipCode,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
identity = #{identity,jdbcType=INTEGER},
technical_title = #{technicalTitle,jdbcType=VARCHAR},
student_id = #{studentId,jdbcType=VARCHAR},
teacher_realname = #{teacherRealname,jdbcType=VARCHAR},
student_realname = #{studentRealname,jdbcType=VARCHAR},
location_city = #{locationCity,jdbcType=VARCHAR},
school_id = #{schoolId,jdbcType=INTEGER},
description = #{description,jdbcType=VARCHAR},
department_id = #{departmentId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,587 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.wiki.mapper.sys.UserMapper" >
<resultMap id="BaseResultMap" type="com.ruoyi.wiki.domain.sys.User" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="login" property="login" jdbcType="VARCHAR" />
<result column="hashed_password" property="hashedPassword" jdbcType="VARCHAR" />
<result column="firstname" property="firstname" jdbcType="VARCHAR" />
<result column="lastname" property="lastname" jdbcType="VARCHAR" />
<result column="mail" property="mail" jdbcType="VARCHAR" />
<result column="admin" property="admin" jdbcType="BIT" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="last_login_on" property="lastLoginOn" jdbcType="TIMESTAMP" />
<result column="language" property="language" jdbcType="VARCHAR" />
<result column="auth_source_id" property="authSourceId" jdbcType="INTEGER" />
<result column="created_on" property="createdOn" jdbcType="TIMESTAMP" />
<result column="updated_on" property="updatedOn" jdbcType="TIMESTAMP" />
<result column="type" property="type" jdbcType="VARCHAR" />
<result column="identity_url" property="identityUrl" jdbcType="VARCHAR" />
<result column="mail_notification" property="mailNotification" jdbcType="VARCHAR" />
<result column="salt" property="salt" jdbcType="VARCHAR" />
<result column="gid" property="gid" jdbcType="INTEGER" />
<result column="visits" property="visits" jdbcType="INTEGER" />
<result column="excellent_teacher" property="excellentTeacher" jdbcType="INTEGER" />
<result column="excellent_student" property="excellentStudent" jdbcType="INTEGER" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="authentication" property="authentication" jdbcType="BIT" />
<result column="grade" property="grade" jdbcType="INTEGER" />
<result column="experience" property="experience" jdbcType="INTEGER" />
<result column="nickname" property="nickname" jdbcType="VARCHAR" />
<result column="show_realname" property="showRealname" jdbcType="BIT" />
<result column="professional_certification" property="professionalCertification" jdbcType="BIT" />
<result column="ID_number" property="idNumber" jdbcType="VARCHAR" />
<result column="certification" property="certification" jdbcType="INTEGER" />
<result column="homepage_teacher" property="homepageTeacher" jdbcType="BIT" />
<result column="homepage_engineer" property="homepageEngineer" jdbcType="BIT" />
<result column="is_test" property="isTest" jdbcType="TINYINT" />
<result column="ecoder_user_id" property="ecoderUserId" jdbcType="INTEGER" />
<result column="business" property="business" jdbcType="BIT" />
<result column="profile_completed" property="profileCompleted" jdbcType="BIT" />
<result column="laboratory_id" property="laboratoryId" jdbcType="BIGINT" />
<result column="platform" property="platform" jdbcType="VARCHAR" />
<result column="gitea_token" property="giteaToken" jdbcType="VARCHAR" />
<result column="gitea_uid" property="giteaUid" jdbcType="INTEGER" />
<result column="is_shixun_marker" property="isShixunMarker" jdbcType="BIT" />
<result column="is_sync_pwd" property="isSyncPwd" jdbcType="BIT" />
<result column="watchers_count" property="watchersCount" jdbcType="INTEGER" />
<result column="devops_step" property="devopsStep" jdbcType="INTEGER" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion" >
<choose >
<when test="criterion.noValue" >
and ${criterion.condition}
</when>
<when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue" >
and ${criterion.condition}
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
id, login, hashed_password, firstname, lastname, mail, admin, status, last_login_on,
language, auth_source_id, created_on, updated_on, type, identity_url, mail_notification,
salt, gid, visits, nickname, gitea_token
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from users
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from users
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.ruoyi.wiki.domain.sys.User" >
insert into users (id, login, hashed_password,
firstname, lastname, mail,
admin, status, last_login_on,
language, auth_source_id, created_on,
updated_on, type, identity_url,
mail_notification, salt, gid,
visits, excellent_teacher, excellent_student,
phone, authentication, grade,
experience, nickname, show_realname,
professional_certification, ID_number, certification,
homepage_teacher, homepage_engineer, is_test,
ecoder_user_id, business, profile_completed,
laboratory_id, platform, gitea_token,
gitea_uid, is_shixun_marker, is_sync_pwd,
watchers_count,
devops_step)
values (#{id,jdbcType=INTEGER}, #{login,jdbcType=VARCHAR}, #{hashedPassword,jdbcType=VARCHAR},
#{firstname,jdbcType=VARCHAR}, #{lastname,jdbcType=VARCHAR}, #{mail,jdbcType=VARCHAR},
#{admin,jdbcType=BIT}, #{status,jdbcType=INTEGER}, #{lastLoginOn,jdbcType=TIMESTAMP},
#{language,jdbcType=VARCHAR}, #{authSourceId,jdbcType=INTEGER}, #{createdOn,jdbcType=TIMESTAMP},
#{updatedOn,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR}, #{identityUrl,jdbcType=VARCHAR},
#{mailNotification,jdbcType=VARCHAR}, #{salt,jdbcType=VARCHAR}, #{gid,jdbcType=INTEGER},
#{visits,jdbcType=INTEGER}, #{excellentTeacher,jdbcType=INTEGER}, #{excellentStudent,jdbcType=INTEGER},
#{phone,jdbcType=VARCHAR}, #{authentication,jdbcType=BIT}, #{grade,jdbcType=INTEGER},
#{experience,jdbcType=INTEGER}, #{nickname,jdbcType=VARCHAR}, #{showRealname,jdbcType=BIT},
#{professionalCertification,jdbcType=BIT}, #{idNumber,jdbcType=VARCHAR}, #{certification,jdbcType=INTEGER},
#{homepageTeacher,jdbcType=BIT}, #{homepageEngineer,jdbcType=BIT}, #{isTest,jdbcType=TINYINT},
#{ecoderUserId,jdbcType=INTEGER}, #{business,jdbcType=BIT}, #{profileCompleted,jdbcType=BIT},
#{laboratoryId,jdbcType=BIGINT}, #{platform,jdbcType=VARCHAR}, #{giteaToken,jdbcType=VARCHAR},
#{giteaUid,jdbcType=INTEGER}, #{isShixunMarker,jdbcType=BIT}, #{isSyncPwd,jdbcType=BIT},
#{watchersCount,jdbcType=INTEGER}, #{enterpriseCertification,jdbcType=BIT}, #{adminRole,jdbcType=TINYINT},
#{devopsStep,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.ruoyi.wiki.domain.sys.User" >
insert into users
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="login != null" >
login,
</if>
<if test="hashedPassword != null" >
hashed_password,
</if>
<if test="firstname != null" >
firstname,
</if>
<if test="lastname != null" >
lastname,
</if>
<if test="mail != null" >
mail,
</if>
<if test="admin != null" >
admin,
</if>
<if test="status != null" >
status,
</if>
<if test="lastLoginOn != null" >
last_login_on,
</if>
<if test="language != null" >
language,
</if>
<if test="authSourceId != null" >
auth_source_id,
</if>
<if test="createdOn != null" >
created_on,
</if>
<if test="updatedOn != null" >
updated_on,
</if>
<if test="type != null" >
type,
</if>
<if test="identityUrl != null" >
identity_url,
</if>
<if test="mailNotification != null" >
mail_notification,
</if>
<if test="salt != null" >
salt,
</if>
<if test="gid != null" >
gid,
</if>
<if test="visits != null" >
visits,
</if>
<if test="excellentTeacher != null" >
excellent_teacher,
</if>
<if test="excellentStudent != null" >
excellent_student,
</if>
<if test="phone != null" >
phone,
</if>
<if test="authentication != null" >
authentication,
</if>
<if test="grade != null" >
grade,
</if>
<if test="experience != null" >
experience,
</if>
<if test="nickname != null" >
nickname,
</if>
<if test="showRealname != null" >
show_realname,
</if>
<if test="professionalCertification != null" >
professional_certification,
</if>
<if test="idNumber != null" >
ID_number,
</if>
<if test="certification != null" >
certification,
</if>
<if test="homepageTeacher != null" >
homepage_teacher,
</if>
<if test="homepageEngineer != null" >
homepage_engineer,
</if>
<if test="isTest != null" >
is_test,
</if>
<if test="ecoderUserId != null" >
ecoder_user_id,
</if>
<if test="business != null" >
business,
</if>
<if test="profileCompleted != null" >
profile_completed,
</if>
<if test="laboratoryId != null" >
laboratory_id,
</if>
<if test="platform != null" >
platform,
</if>
<if test="giteaToken != null" >
gitea_token,
</if>
<if test="giteaUid != null" >
gitea_uid,
</if>
<if test="isShixunMarker != null" >
is_shixun_marker,
</if>
<if test="isSyncPwd != null" >
is_sync_pwd,
</if>
<if test="watchersCount != null" >
watchers_count,
</if>
<if test="devopsStep != null" >
devops_step,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="login != null" >
#{login,jdbcType=VARCHAR},
</if>
<if test="hashedPassword != null" >
#{hashedPassword,jdbcType=VARCHAR},
</if>
<if test="firstname != null" >
#{firstname,jdbcType=VARCHAR},
</if>
<if test="lastname != null" >
#{lastname,jdbcType=VARCHAR},
</if>
<if test="mail != null" >
#{mail,jdbcType=VARCHAR},
</if>
<if test="admin != null" >
#{admin,jdbcType=BIT},
</if>
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
<if test="lastLoginOn != null" >
#{lastLoginOn,jdbcType=TIMESTAMP},
</if>
<if test="language != null" >
#{language,jdbcType=VARCHAR},
</if>
<if test="authSourceId != null" >
#{authSourceId,jdbcType=INTEGER},
</if>
<if test="createdOn != null" >
#{createdOn,jdbcType=TIMESTAMP},
</if>
<if test="updatedOn != null" >
#{updatedOn,jdbcType=TIMESTAMP},
</if>
<if test="type != null" >
#{type,jdbcType=VARCHAR},
</if>
<if test="identityUrl != null" >
#{identityUrl,jdbcType=VARCHAR},
</if>
<if test="mailNotification != null" >
#{mailNotification,jdbcType=VARCHAR},
</if>
<if test="salt != null" >
#{salt,jdbcType=VARCHAR},
</if>
<if test="gid != null" >
#{gid,jdbcType=INTEGER},
</if>
<if test="visits != null" >
#{visits,jdbcType=INTEGER},
</if>
<if test="excellentTeacher != null" >
#{excellentTeacher,jdbcType=INTEGER},
</if>
<if test="excellentStudent != null" >
#{excellentStudent,jdbcType=INTEGER},
</if>
<if test="phone != null" >
#{phone,jdbcType=VARCHAR},
</if>
<if test="authentication != null" >
#{authentication,jdbcType=BIT},
</if>
<if test="grade != null" >
#{grade,jdbcType=INTEGER},
</if>
<if test="experience != null" >
#{experience,jdbcType=INTEGER},
</if>
<if test="nickname != null" >
#{nickname,jdbcType=VARCHAR},
</if>
<if test="showRealname != null" >
#{showRealname,jdbcType=BIT},
</if>
<if test="professionalCertification != null" >
#{professionalCertification,jdbcType=BIT},
</if>
<if test="idNumber != null" >
#{idNumber,jdbcType=VARCHAR},
</if>
<if test="certification != null" >
#{certification,jdbcType=INTEGER},
</if>
<if test="homepageTeacher != null" >
#{homepageTeacher,jdbcType=BIT},
</if>
<if test="homepageEngineer != null" >
#{homepageEngineer,jdbcType=BIT},
</if>
<if test="isTest != null" >
#{isTest,jdbcType=TINYINT},
</if>
<if test="ecoderUserId != null" >
#{ecoderUserId,jdbcType=INTEGER},
</if>
<if test="business != null" >
#{business,jdbcType=BIT},
</if>
<if test="profileCompleted != null" >
#{profileCompleted,jdbcType=BIT},
</if>
<if test="laboratoryId != null" >
#{laboratoryId,jdbcType=BIGINT},
</if>
<if test="platform != null" >
#{platform,jdbcType=VARCHAR},
</if>
<if test="giteaToken != null" >
#{giteaToken,jdbcType=VARCHAR},
</if>
<if test="giteaUid != null" >
#{giteaUid,jdbcType=INTEGER},
</if>
<if test="isShixunMarker != null" >
#{isShixunMarker,jdbcType=BIT},
</if>
<if test="isSyncPwd != null" >
#{isSyncPwd,jdbcType=BIT},
</if>
<if test="watchersCount != null" >
#{watchersCount,jdbcType=INTEGER},
</if>
<if test="enterpriseCertification != null" >
#{enterpriseCertification,jdbcType=BIT},
</if>
<if test="adminRole != null" >
#{adminRole,jdbcType=TINYINT},
</if>
<if test="devopsStep != null" >
#{devopsStep,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.wiki.domain.sys.User" >
update users
<set >
<if test="login != null" >
login = #{login,jdbcType=VARCHAR},
</if>
<if test="hashedPassword != null" >
hashed_password = #{hashedPassword,jdbcType=VARCHAR},
</if>
<if test="firstname != null" >
firstname = #{firstname,jdbcType=VARCHAR},
</if>
<if test="lastname != null" >
lastname = #{lastname,jdbcType=VARCHAR},
</if>
<if test="mail != null" >
mail = #{mail,jdbcType=VARCHAR},
</if>
<if test="admin != null" >
admin = #{admin,jdbcType=BIT},
</if>
<if test="status != null" >
status = #{status,jdbcType=INTEGER},
</if>
<if test="lastLoginOn != null" >
last_login_on = #{lastLoginOn,jdbcType=TIMESTAMP},
</if>
<if test="language != null" >
language = #{language,jdbcType=VARCHAR},
</if>
<if test="authSourceId != null" >
auth_source_id = #{authSourceId,jdbcType=INTEGER},
</if>
<if test="createdOn != null" >
created_on = #{createdOn,jdbcType=TIMESTAMP},
</if>
<if test="updatedOn != null" >
updated_on = #{updatedOn,jdbcType=TIMESTAMP},
</if>
<if test="type != null" >
type = #{type,jdbcType=VARCHAR},
</if>
<if test="identityUrl != null" >
identity_url = #{identityUrl,jdbcType=VARCHAR},
</if>
<if test="mailNotification != null" >
mail_notification = #{mailNotification,jdbcType=VARCHAR},
</if>
<if test="salt != null" >
salt = #{salt,jdbcType=VARCHAR},
</if>
<if test="gid != null" >
gid = #{gid,jdbcType=INTEGER},
</if>
<if test="visits != null" >
visits = #{visits,jdbcType=INTEGER},
</if>
<if test="excellentTeacher != null" >
excellent_teacher = #{excellentTeacher,jdbcType=INTEGER},
</if>
<if test="excellentStudent != null" >
excellent_student = #{excellentStudent,jdbcType=INTEGER},
</if>
<if test="phone != null" >
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="authentication != null" >
authentication = #{authentication,jdbcType=BIT},
</if>
<if test="grade != null" >
grade = #{grade,jdbcType=INTEGER},
</if>
<if test="experience != null" >
experience = #{experience,jdbcType=INTEGER},
</if>
<if test="nickname != null" >
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="showRealname != null" >
show_realname = #{showRealname,jdbcType=BIT},
</if>
<if test="professionalCertification != null" >
professional_certification = #{professionalCertification,jdbcType=BIT},
</if>
<if test="idNumber != null" >
ID_number = #{idNumber,jdbcType=VARCHAR},
</if>
<if test="certification != null" >
certification = #{certification,jdbcType=INTEGER},
</if>
<if test="homepageTeacher != null" >
homepage_teacher = #{homepageTeacher,jdbcType=BIT},
</if>
<if test="homepageEngineer != null" >
homepage_engineer = #{homepageEngineer,jdbcType=BIT},
</if>
<if test="isTest != null" >
is_test = #{isTest,jdbcType=TINYINT},
</if>
<if test="ecoderUserId != null" >
ecoder_user_id = #{ecoderUserId,jdbcType=INTEGER},
</if>
<if test="business != null" >
business = #{business,jdbcType=BIT},
</if>
<if test="profileCompleted != null" >
profile_completed = #{profileCompleted,jdbcType=BIT},
</if>
<if test="laboratoryId != null" >
laboratory_id = #{laboratoryId,jdbcType=BIGINT},
</if>
<if test="platform != null" >
platform = #{platform,jdbcType=VARCHAR},
</if>
<if test="giteaToken != null" >
gitea_token = #{giteaToken,jdbcType=VARCHAR},
</if>
<if test="giteaUid != null" >
gitea_uid = #{giteaUid,jdbcType=INTEGER},
</if>
<if test="isShixunMarker != null" >
is_shixun_marker = #{isShixunMarker,jdbcType=BIT},
</if>
<if test="isSyncPwd != null" >
is_sync_pwd = #{isSyncPwd,jdbcType=BIT},
</if>
<if test="watchersCount != null" >
watchers_count = #{watchersCount,jdbcType=INTEGER},
</if>
<if test="devopsStep != null" >
devops_step = #{devopsStep,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.wiki.domain.sys.User" >
update users
set login = #{login,jdbcType=VARCHAR},
hashed_password = #{hashedPassword,jdbcType=VARCHAR},
firstname = #{firstname,jdbcType=VARCHAR},
lastname = #{lastname,jdbcType=VARCHAR},
mail = #{mail,jdbcType=VARCHAR},
admin = #{admin,jdbcType=BIT},
status = #{status,jdbcType=INTEGER},
last_login_on = #{lastLoginOn,jdbcType=TIMESTAMP},
language = #{language,jdbcType=VARCHAR},
auth_source_id = #{authSourceId,jdbcType=INTEGER},
created_on = #{createdOn,jdbcType=TIMESTAMP},
updated_on = #{updatedOn,jdbcType=TIMESTAMP},
type = #{type,jdbcType=VARCHAR},
identity_url = #{identityUrl,jdbcType=VARCHAR},
mail_notification = #{mailNotification,jdbcType=VARCHAR},
salt = #{salt,jdbcType=VARCHAR},
gid = #{gid,jdbcType=INTEGER},
visits = #{visits,jdbcType=INTEGER},
excellent_teacher = #{excellentTeacher,jdbcType=INTEGER},
excellent_student = #{excellentStudent,jdbcType=INTEGER},
phone = #{phone,jdbcType=VARCHAR},
authentication = #{authentication,jdbcType=BIT},
grade = #{grade,jdbcType=INTEGER},
experience = #{experience,jdbcType=INTEGER},
nickname = #{nickname,jdbcType=VARCHAR},
show_realname = #{showRealname,jdbcType=BIT},
professional_certification = #{professionalCertification,jdbcType=BIT},
ID_number = #{idNumber,jdbcType=VARCHAR},
certification = #{certification,jdbcType=INTEGER},
homepage_teacher = #{homepageTeacher,jdbcType=BIT},
homepage_engineer = #{homepageEngineer,jdbcType=BIT},
is_test = #{isTest,jdbcType=TINYINT},
ecoder_user_id = #{ecoderUserId,jdbcType=INTEGER},
business = #{business,jdbcType=BIT},
profile_completed = #{profileCompleted,jdbcType=BIT},
laboratory_id = #{laboratoryId,jdbcType=BIGINT},
platform = #{platform,jdbcType=VARCHAR},
gitea_token = #{giteaToken,jdbcType=VARCHAR},
gitea_uid = #{giteaUid,jdbcType=INTEGER},
is_shixun_marker = #{isShixunMarker,jdbcType=BIT},
is_sync_pwd = #{isSyncPwd,jdbcType=BIT},
watchers_count = #{watchersCount,jdbcType=INTEGER},
devops_step = #{devopsStep,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

View File

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.wiki.mapper.team_projects.TeamProjectsMapper" >
<resultMap id="BaseResultMap" type="com.ruoyi.wiki.domain.team_projects.TeamProjects" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="organization_id" property="organizationId" jdbcType="BIGINT" />
<result column="project_id" property="projectId" jdbcType="BIGINT" />
<result column="team_id" property="teamId" jdbcType="BIGINT" />
<result column="created_at" property="createdAt" jdbcType="TIMESTAMP" />
<result column="updated_at" property="updatedAt" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, organization_id, project_id, team_id, created_at, updated_at
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from team_projects
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from team_projects
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.ruoyi.wiki.domain.team_projects.TeamProjects" >
insert into team_projects (id, organization_id, project_id,
team_id, created_at, updated_at
)
values (#{id,jdbcType=BIGINT}, #{organizationId,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT},
#{teamId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.ruoyi.wiki.domain.team_projects.TeamProjects" >
insert into team_projects
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="organizationId != null" >
organization_id,
</if>
<if test="projectId != null" >
project_id,
</if>
<if test="teamId != null" >
team_id,
</if>
<if test="createdAt != null" >
created_at,
</if>
<if test="updatedAt != null" >
updated_at,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="organizationId != null" >
#{organizationId,jdbcType=BIGINT},
</if>
<if test="projectId != null" >
#{projectId,jdbcType=BIGINT},
</if>
<if test="teamId != null" >
#{teamId,jdbcType=BIGINT},
</if>
<if test="createdAt != null" >
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null" >
#{updatedAt,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.wiki.domain.team_projects.TeamProjects" >
update team_projects
<set >
<if test="organizationId != null" >
organization_id = #{organizationId,jdbcType=BIGINT},
</if>
<if test="projectId != null" >
project_id = #{projectId,jdbcType=BIGINT},
</if>
<if test="teamId != null" >
team_id = #{teamId,jdbcType=BIGINT},
</if>
<if test="createdAt != null" >
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null" >
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ruoyi.wiki.domain.team_projects.TeamProjects" >
update team_projects
set organization_id = #{organizationId,jdbcType=BIGINT},
project_id = #{projectId,jdbcType=BIGINT},
team_id = #{teamId,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="doesMemberExist" resultType="java.lang.Integer">
SELECT count(*)
FROM `team_projects`
INNER JOIN `teams` ON `teams`.`id` = `team_projects`.`team_id`
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`id`
WHERE `team_projects`.`project_id` = #{projectId} AND `team_users`.`user_id` = #{userId}
</select>
</mapper>