package com.gkhy.hazmat.admin.controller.system; import com.gkhy.hazmat.common.api.CommonResult; import com.gkhy.hazmat.system.domain.SysConfig; import com.gkhy.hazmat.system.service.SysConfigService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @Api(tags = "系统配置前端控制器") @RestController @RequestMapping("/system/config") public class SysConfigController { @Autowired private SysConfigService configService; @PreAuthorize("hasAnyAuthority('hazmat:manage:system')") @ApiOperation(value = "配置列表") @GetMapping("/list") public CommonResult list(SysConfig config){ return CommonResult.success(configService.selectConfigList(config)); } @PreAuthorize("hasAnyAuthority('hazmat:manage:system')") @ApiOperation(value = "新增配置") @PostMapping public CommonResult add(@Validated @RequestBody SysConfig config){ return CommonResult.success(configService.insertConfig(config)); } @PreAuthorize("hasAnyAuthority('hazmat:manage:system')") @ApiOperation(value = "更新配置") @PutMapping public CommonResult edit(@Validated @RequestBody SysConfig config){ return CommonResult.success(configService.updateConfig(config)); } @PreAuthorize("hasAnyAuthority('hazmat:manage:system')") @ApiOperation(value = "删除配置") @DeleteMapping(value = "/{configId}") public CommonResult remove(@PathVariable Long configId){ configService.deleteConfigById(configId); return CommonResult.success(); } @PreAuthorize("hasAnyAuthority('hazmat:manage:company','hazmat:manage:common')") @ApiOperation(value = "查询当前用户公司配置") @GetMapping(value = "/getConfigByUser") public CommonResult getConfigByUser(){ return CommonResult.success(configService.getConfigByUser()); } }