214 lines
7.7 KiB
Java
214 lines
7.7 KiB
Java
package com.ruoyi.system.controller;
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.select.Ids;
|
|
import com.ruoyi.common.select.SelectItem;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.system.domain.Apps;
|
|
import com.ruoyi.system.domain.AppsPlus;
|
|
import com.ruoyi.system.service.IAppsService;
|
|
import com.ruoyi.system.domain.dto.AppPublicKeyRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 应用管理Controller
|
|
*
|
|
* @author luqj
|
|
* @date 2025-11-25
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/system/apps")
|
|
public class AppsController extends BaseController {
|
|
@Autowired
|
|
private IAppsService appsService;
|
|
|
|
/** 返回管理员新增应用时固定使用的全局归集地址。 */
|
|
@PreAuthorize("@ss.hasPermi('system:apps:add')")
|
|
@GetMapping("/aggregation-address")
|
|
public AjaxResult aggregationAddress() {
|
|
return AjaxResult.success(appsService.getGlobalAggregationAddress());
|
|
}
|
|
|
|
/** 返回商户新增应用时固定使用的全局归集地址。 */
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-add')")
|
|
@GetMapping("/user/aggregation-address")
|
|
public AjaxResult userAggregationAddress() {
|
|
return AjaxResult.success(appsService.getGlobalAggregationAddress());
|
|
}
|
|
|
|
/**
|
|
* 生成 RSA 密钥对。私钥只在本次响应中返回,因此禁止操作日志保存响应体。
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:add')")
|
|
@Log(title = "生成商户 RSA 密钥对", businessType = BusinessType.OTHER,
|
|
isSaveRequestData = false, isSaveResponseData = false)
|
|
@PostMapping("/generate-key-pair")
|
|
public AjaxResult generateKeyPair() {
|
|
return AjaxResult.success(appsService.generateKeyPair());
|
|
}
|
|
|
|
/** 商户端生成 RSA 密钥对,私钥同样不保存。 */
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-add')")
|
|
@Log(title = "商户生成 RSA 密钥对", businessType = BusinessType.OTHER,
|
|
isSaveRequestData = false, isSaveResponseData = false)
|
|
@PostMapping("/user/generate-key-pair")
|
|
public AjaxResult userGenerateKeyPair() {
|
|
return AjaxResult.success(appsService.generateKeyPair());
|
|
}
|
|
|
|
/** 单独设置商户公钥。 */
|
|
@PreAuthorize("@ss.hasPermi('system:apps:edit')")
|
|
@Log(title = "设置商户公钥", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/{id}/public-key")
|
|
public AjaxResult updatePublicKey(@PathVariable("id") Long id,
|
|
@RequestBody AppPublicKeyRequest request) {
|
|
return toAjax(appsService.updatePublicKey(id,
|
|
request == null ? null : request.getPublicKey(), false));
|
|
}
|
|
|
|
/** 商户端单独设置自己的公钥。 */
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-edit')")
|
|
@Log(title = "商户设置公钥", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/user/{id}/public-key")
|
|
public AjaxResult userUpdatePublicKey(@PathVariable("id") Long id,
|
|
@RequestBody AppPublicKeyRequest request) {
|
|
return toAjax(appsService.updatePublicKey(id,
|
|
request == null ? null : request.getPublicKey(), true));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:apps:getByIds')")
|
|
@PostMapping("/getByIds")
|
|
public AjaxResult getByIds(@RequestBody Ids ids) {
|
|
List<AppsPlus> list = appsService.getByIds(ids.getLongIds(), false, AppsPlus::getName, AppsPlus::getId);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-getByIds')")
|
|
@PostMapping("/user/getByIds")
|
|
public AjaxResult userGetByIds(@RequestBody Ids ids) {
|
|
List<AppsPlus> list = appsService.getByIds(ids.getLongIds(), true, AppsPlus::getName, AppsPlus::getUserId, AppsPlus::getId);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:apps:select')")
|
|
@GetMapping("/select")
|
|
public AjaxResult select(String keyword) {
|
|
List<SelectItem> list = appsService.select(keyword, false);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-select')")
|
|
@GetMapping("/user/select")
|
|
public AjaxResult userSelect(String keyword) {
|
|
List<SelectItem> list = appsService.select(keyword, true);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
/**
|
|
* 查询应用管理列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:list')")
|
|
@GetMapping("/list")
|
|
public TableDataInfo list(Apps apps) {
|
|
startPage();
|
|
List<Apps> list = appsService.selectAppsList(apps, false);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
/**
|
|
* 查询应用管理列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-list')")
|
|
@GetMapping("/user/list")
|
|
public TableDataInfo userList(Apps apps) {
|
|
startPage();
|
|
List<Apps> list = appsService.selectAppsList(apps, true);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
/**
|
|
* 导出应用管理列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:export')")
|
|
@Log(title = "应用管理", businessType = BusinessType.EXPORT)
|
|
@GetMapping("/export")
|
|
public AjaxResult export(Apps apps) {
|
|
List<Apps> list = appsService.selectAppsList(apps, false);
|
|
ExcelUtil<Apps> util = new ExcelUtil<Apps>(Apps.class);
|
|
return util.exportExcel(list, "apps");
|
|
}
|
|
|
|
/**
|
|
* 获取应用管理详细信息
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:query')")
|
|
@GetMapping(value = "/{id}")
|
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
return AjaxResult.success(appsService.selectAppsById(id, false));
|
|
}
|
|
|
|
/**
|
|
* 获取应用管理详细信息
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-query')")
|
|
@GetMapping(value = "/user/{id}")
|
|
public AjaxResult userGetInfo(@PathVariable("id") Long id) {
|
|
return AjaxResult.success(appsService.selectAppsById(id, true));
|
|
}
|
|
|
|
/**
|
|
* 新增应用管理
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:add')")
|
|
@Log(title = "应用管理", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
public AjaxResult add(@RequestBody Apps apps) {
|
|
return toAjax(appsService.insertApps(apps, false));
|
|
}
|
|
|
|
/**
|
|
* 修改应用管理
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:edit')")
|
|
@Log(title = "应用管理", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
public AjaxResult edit(@RequestBody Apps apps) {
|
|
return toAjax(appsService.updateApps(apps, false));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-edit')")
|
|
@Log(title = "应用管理", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/user")
|
|
public AjaxResult userEdit(@RequestBody Apps apps) {
|
|
return toAjax(appsService.updateApps(apps, true));
|
|
}
|
|
|
|
/**
|
|
* 删除应用管理
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:remove')")
|
|
@Log(title = "应用管理", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{ids}")
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
return toAjax(appsService.deleteAppsByIds(ids, false));
|
|
}
|
|
|
|
/**
|
|
* 删除应用管理
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:apps:user-remove')")
|
|
@Log(title = "应用管理", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/user/{ids}")
|
|
public AjaxResult userRemove(@PathVariable Long[] ids) {
|
|
return toAjax(appsService.deleteAppsByIds(ids, true));
|
|
}
|
|
}
|