Add sensitive word filter
This commit is contained in:
@@ -3,18 +3,21 @@ package top.fatweb.oxygen.api.controller.system
|
||||
import io.swagger.v3.oas.annotations.Operation
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.security.access.prepost.PreAuthorize
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
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.PutMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import top.fatweb.oxygen.api.annotation.BaseController
|
||||
import top.fatweb.oxygen.api.entity.common.ResponseCode
|
||||
import top.fatweb.oxygen.api.entity.common.ResponseResult
|
||||
import top.fatweb.oxygen.api.param.system.BaseSettingsParam
|
||||
import top.fatweb.oxygen.api.param.system.MailSendParam
|
||||
import top.fatweb.oxygen.api.param.system.MailSettingsParam
|
||||
import top.fatweb.oxygen.api.param.system.*
|
||||
import top.fatweb.oxygen.api.service.system.ISensitiveWordService
|
||||
import top.fatweb.oxygen.api.service.system.ISettingsService
|
||||
import top.fatweb.oxygen.api.vo.system.BaseSettingsVo
|
||||
import top.fatweb.oxygen.api.vo.system.MailSettingsVo
|
||||
import top.fatweb.oxygen.api.vo.system.SensitiveWordVo
|
||||
|
||||
/**
|
||||
* System settings controller
|
||||
@@ -25,7 +28,8 @@ import top.fatweb.oxygen.api.vo.system.MailSettingsVo
|
||||
*/
|
||||
@BaseController(path = ["/system/settings"], name = "系统设置", description = "系统设置相关接口")
|
||||
class SettingsController(
|
||||
private val settingsService: ISettingsService
|
||||
private val settingsService: ISettingsService,
|
||||
private val sensitiveWordService: ISensitiveWordService
|
||||
) {
|
||||
/**
|
||||
* Get base settings
|
||||
@@ -97,4 +101,58 @@ class SettingsController(
|
||||
settingsService.sendMail(mailSendParam)
|
||||
return ResponseResult.success()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sensitive word settings
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Operation(summary = "获取敏感词配置")
|
||||
@GetMapping("/sensitive")
|
||||
@PreAuthorize("hasAnyAuthority('system:settings:query:sensitive')")
|
||||
fun getSensitive(): ResponseResult<List<SensitiveWordVo>> =
|
||||
ResponseResult.databaseSuccess(ResponseCode.DATABASE_SELECT_SUCCESS, data = sensitiveWordService.get())
|
||||
|
||||
/**
|
||||
* Add sensitive word
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Operation(summary = "添加敏感词")
|
||||
@PostMapping("/sensitive")
|
||||
@PreAuthorize("hasAnyAuthority('system:settings:modify:sensitive')")
|
||||
fun addSensitive(@RequestBody @Valid sensitiveWordAddParam: SensitiveWordAddParam): ResponseResult<Nothing> {
|
||||
sensitiveWordService.add(sensitiveWordAddParam)
|
||||
return ResponseResult.databaseSuccess(ResponseCode.DATABASE_INSERT_SUCCESS)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sensitive word
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Operation(summary = "修改敏感词")
|
||||
@PutMapping("/sensitive")
|
||||
@PreAuthorize("hasAnyAuthority('system:settings:modify:sensitive')")
|
||||
fun updateSensitive(@RequestBody sensitiveWordUpdateParam: SensitiveWordUpdateParam): ResponseResult<Nothing> {
|
||||
sensitiveWordService.update(sensitiveWordUpdateParam)
|
||||
return ResponseResult.databaseSuccess(ResponseCode.DATABASE_UPDATE_SUCCESS)
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete sensitive word
|
||||
*
|
||||
* @author FatttSnake, fatttsnake@gmail.com
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Operation(summary = "删除敏感词")
|
||||
@DeleteMapping("/sensitive/{id}")
|
||||
@PreAuthorize("hasAnyAuthority('system:settings:modify:sensitive')")
|
||||
fun deleteSensitive(@PathVariable id: Long): ResponseResult<Nothing> {
|
||||
sensitiveWordService.delete(id)
|
||||
return ResponseResult.databaseSuccess(ResponseCode.DATABASE_DELETE_SUCCESS)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user