Expand EasyCode front workbench features
This commit is contained in:
@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.generator.domain.front.dto.DatabaseDesignResponse;
|
||||
import com.ruoyi.generator.domain.front.dto.FrontProjectCreateRequest;
|
||||
import com.ruoyi.generator.domain.front.dto.FrontProjectUpdateRequest;
|
||||
@@ -117,10 +118,12 @@ public class FrontProjectController extends BaseController
|
||||
}
|
||||
|
||||
@GetMapping("/{projectId}/download")
|
||||
public void download(@PathVariable Long projectId, @RequestParam String templateType, HttpServletResponse response) throws IOException
|
||||
public void download(@PathVariable Long projectId, @RequestParam(required = false) String templateType, HttpServletResponse response) throws IOException
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
byte[] data = frontProjectPreviewService.download(userId, projectId, templateType);
|
||||
byte[] data = StringUtils.isNotEmpty(templateType)
|
||||
? frontProjectPreviewService.download(userId, projectId, templateType)
|
||||
: frontProjectPreviewService.downloadAll(userId, projectId);
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"project.zip\"");
|
||||
response.addHeader("Content-Length", "" + data.length);
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.ruoyi.web.controller.front;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDictData;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.generator.domain.SourceProject;
|
||||
import com.ruoyi.generator.service.ISourceProjectService;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/front/source")
|
||||
public class FrontSourceController extends BaseController
|
||||
{
|
||||
private static final String SOURCE_PROJECT_CATEGORY_DICT_TYPE = "source_project_category";
|
||||
|
||||
@Autowired
|
||||
private ISourceProjectService sourceProjectService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@GetMapping("/categories")
|
||||
public AjaxResult categories()
|
||||
{
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(SOURCE_PROJECT_CATEGORY_DICT_TYPE);
|
||||
if (data == null)
|
||||
{
|
||||
data = new ArrayList<SysDictData>();
|
||||
}
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@GetMapping("/projects")
|
||||
public AjaxResult projects(SourceProject query)
|
||||
{
|
||||
return success(sourceProjectService.listPublicProjects(optionalUserId(), query));
|
||||
}
|
||||
|
||||
@GetMapping("/projects/{slug}")
|
||||
public AjaxResult detail(@PathVariable String slug)
|
||||
{
|
||||
return success(sourceProjectService.getPublicProject(optionalUserId(), slug, true));
|
||||
}
|
||||
|
||||
@PostMapping("/projects/{projectId}/purchase")
|
||||
public AjaxResult purchase(@PathVariable Long projectId)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(sourceProjectService.purchase(userId, projectId));
|
||||
}
|
||||
|
||||
@GetMapping("/purchases")
|
||||
public AjaxResult purchases()
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(sourceProjectService.listPurchases(userId));
|
||||
}
|
||||
|
||||
@GetMapping("/projects/{projectId}/download")
|
||||
public AjaxResult download(@PathVariable Long projectId)
|
||||
{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
return success(sourceProjectService.getDownloadInfo(userId, projectId));
|
||||
}
|
||||
|
||||
private Long optionalUserId()
|
||||
{
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || authentication.getPrincipal() == null
|
||||
|| "anonymousUser".equals(authentication.getPrincipal()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (authentication.getPrincipal() instanceof LoginUser)
|
||||
{
|
||||
return ((LoginUser) authentication.getPrincipal()).getUserId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,13 @@ ruoyi:
|
||||
captchaType: math
|
||||
|
||||
deepseek:
|
||||
apiKey: ${DEEPSEEK_API_KEY:}
|
||||
apiKey: sk-2aef3231d45048a9a0ba6f0367a072ca
|
||||
baseUrl: https://api.deepseek.com
|
||||
model: deepseek-chat
|
||||
timeout: 60000
|
||||
model: deepseek-v4-flash
|
||||
timeout: ${DEEPSEEK_TIMEOUT:180000}
|
||||
maxTables: 12
|
||||
maxColumnsPerTable: 30
|
||||
skipSslVerify: true
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
|
||||
Reference in New Issue
Block a user