169 lines
5.9 KiB
Java
169 lines
5.9 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.AppApiKeys;
|
|
import com.ruoyi.system.domain.AppApiKeysPlus;
|
|
import com.ruoyi.system.service.IAppApiKeysService;
|
|
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/keys" )
|
|
public class AppApiKeysController extends BaseController {
|
|
@Autowired
|
|
private IAppApiKeysService appApiKeysService;
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:keys:getByIds')" )
|
|
@PostMapping("/getByIds" )
|
|
public AjaxResult getByIds(@RequestBody Ids ids) {
|
|
List<AppApiKeysPlus> list = appApiKeysService.getByIds(ids.getLongIds(), false, AppApiKeysPlus::getApiSecret, AppApiKeysPlus::getId);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-getByIds')" )
|
|
@PostMapping("/user/getByIds" )
|
|
public AjaxResult userGetByIds(@RequestBody Ids ids) {
|
|
List<AppApiKeysPlus> list = appApiKeysService.getByIds(ids.getLongIds(), true, AppApiKeysPlus::getApiSecret,AppApiKeysPlus::getUserId, AppApiKeysPlus::getId);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:keys:select')" )
|
|
@GetMapping("/select" )
|
|
public AjaxResult select(String keyword) {
|
|
List<SelectItem> list = appApiKeysService.select(keyword, false);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-select')" )
|
|
@GetMapping("/user/select" )
|
|
public AjaxResult userSelect(String keyword) {
|
|
List<SelectItem> list = appApiKeysService.select(keyword, true);
|
|
return AjaxResult.success(list);
|
|
}
|
|
|
|
/**
|
|
* 查询应用密钥列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:list')" )
|
|
@GetMapping("/list" )
|
|
public TableDataInfo list(AppApiKeys appApiKeys) {
|
|
startPage();
|
|
List<AppApiKeys> list = appApiKeysService.selectAppApiKeysList(appApiKeys, false);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
/**
|
|
* 查询应用密钥列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-list')" )
|
|
@GetMapping("/user/list" )
|
|
public TableDataInfo userList(AppApiKeys appApiKeys) {
|
|
startPage();
|
|
List<AppApiKeys> list = appApiKeysService.selectAppApiKeysList(appApiKeys, true);
|
|
return getDataTable(list);
|
|
}
|
|
|
|
/**
|
|
* 导出应用密钥列表
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:export')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.EXPORT)
|
|
@GetMapping("/export" )
|
|
public AjaxResult export(AppApiKeys appApiKeys) {
|
|
List<AppApiKeys> list = appApiKeysService.selectAppApiKeysList(appApiKeys, false);
|
|
ExcelUtil<AppApiKeys> util = new ExcelUtil<AppApiKeys>(AppApiKeys.class);
|
|
return util.exportExcel(list, "keys" );
|
|
}
|
|
|
|
/**
|
|
* 获取应用密钥详细信息
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:query')" )
|
|
@GetMapping(value = "/{id}" )
|
|
public AjaxResult getInfo(@PathVariable("id" ) Long id) {
|
|
return AjaxResult.success(appApiKeysService.selectAppApiKeysById(id, false));
|
|
}
|
|
|
|
/**
|
|
* 获取应用密钥详细信息
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-query')" )
|
|
@GetMapping(value = "/user/{id}" )
|
|
public AjaxResult userGetInfo(@PathVariable("id" ) Long id) {
|
|
return AjaxResult.success(appApiKeysService.selectAppApiKeysById(id, true));
|
|
}
|
|
|
|
/**
|
|
* 新增应用密钥
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:add')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
public AjaxResult add(@RequestBody AppApiKeys appApiKeys) {
|
|
return toAjax(appApiKeysService.insertAppApiKeys(appApiKeys, false));
|
|
}
|
|
|
|
/**
|
|
* 新增应用密钥
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-add')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.INSERT)
|
|
@PostMapping("/user" )
|
|
public AjaxResult userAdd(@RequestBody AppApiKeys appApiKeys) {
|
|
return toAjax(appApiKeysService.insertAppApiKeys(appApiKeys, true));
|
|
}
|
|
|
|
/**
|
|
* 修改应用密钥
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:edit')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
public AjaxResult edit(@RequestBody AppApiKeys appApiKeys) {
|
|
return toAjax(appApiKeysService.updateAppApiKeys(appApiKeys, false));
|
|
}
|
|
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-edit')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.UPDATE)
|
|
@PutMapping("/user" )
|
|
public AjaxResult userEdit(@RequestBody AppApiKeys appApiKeys) {
|
|
return toAjax(appApiKeysService.updateAppApiKeys(appApiKeys, true));
|
|
}
|
|
|
|
/**
|
|
* 删除应用密钥
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:remove')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{ids}" )
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
return toAjax(appApiKeysService.deleteAppApiKeysByIds(ids, false));
|
|
}
|
|
|
|
/**
|
|
* 删除应用密钥
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:keys:user-remove')" )
|
|
@Log(title = "应用密钥" , businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/user/{ids}" )
|
|
public AjaxResult userRemove(@PathVariable Long[] ids) {
|
|
return toAjax(appApiKeysService.deleteAppApiKeysByIds(ids, true));
|
|
}
|
|
}
|