package com.gkhy.fourierSpecialGasMonitor.controller; import com.gkhy.fourierSpecialGasMonitor.annotation.RepeatedClick; import com.gkhy.fourierSpecialGasMonitor.api.controller.common.BaseController; import com.gkhy.fourierSpecialGasMonitor.commons.domain.Result; import com.gkhy.fourierSpecialGasMonitor.commons.enums.SystemCacheKeyEnum; import com.gkhy.fourierSpecialGasMonitor.commons.model.PageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasCategoryPageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.query.FindRegionPageQuery; import com.gkhy.fourierSpecialGasMonitor.entity.req.CreateGasCategoryReqDTO; import com.gkhy.fourierSpecialGasMonitor.entity.req.UpdateGasCategoryReqDTO; import com.gkhy.fourierSpecialGasMonitor.service.GasCategoryService; import org.redisson.api.RBucket; import org.redisson.api.RedissonClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.PostConstruct; @RestController @RequestMapping("/gasCategory") public class GasCategoryController extends BaseController { @Autowired private GasCategoryService gasCategoryService; private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private RedissonClient redissonClient; /** * @decription 新增气体 * @author Mr.huang */ @PostMapping("/add") @RepeatedClick public Result createGasCategory(@RequestBody CreateGasCategoryReqDTO reqDto){ Result result = gasCategoryService.createGasCategory(reqDto); return result; } /** * @decription 更新气体 * @author Mr.huang */ @PostMapping("/update") @RepeatedClick public Result updateGasCategory(@RequestBody UpdateGasCategoryReqDTO reqDto){ Result result = gasCategoryService.updateGasCategory(reqDto); return result; } @GetMapping("/findById") public Result findGasCategoryById(@RequestParam Integer id){ Result result = gasCategoryService.findGasCategoryById(id); return result; } @PostMapping("/page") public Result findGasCategoryPage(@RequestBody PageQuery pageQuery){ Result result = gasCategoryService.findGasCategoryPage(pageQuery); return result; } @PostMapping("/list") public Result gasCategoryList(){ Result result = gasCategoryService.gasCategoryList(); return result; } @PostConstruct private void gasCategoryListCache(){ //清除redis缓存 RBucket bucket = redissonClient.getBucket(SystemCacheKeyEnum.KEY_GAS_CATEGORY.getKey()); if (bucket.isExists()) { bucket.delete(); } this.gasCategoryList(); logger.info("[GasCategoryList] cache complete"); } }