server/company/src/main/java/com/doumee/CompanyApplication.java
@@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.context.ApplicationContext; import org.springframework.scheduling.annotation.EnableAsync; /** * 启动类 @@ -15,6 +16,7 @@ @Slf4j @SpringBootApplication @MapperScan("com.doumee.dao") @EnableAsync public class CompanyApplication { public static void main(String[] args) { ApplicationContext context = SpringApplication.run(CompanyApplication.class); server/company/src/main/java/com/doumee/api/business/GoodsController.java
@@ -10,6 +10,7 @@ import com.doumee.dao.business.model.dto.BatchDisableDTO; import com.doumee.dao.business.model.dto.GoodCreatePlatRequest; import com.doumee.dao.business.model.dto.GoodsRequest; import com.doumee.service.CateParamSelectService; import com.doumee.service.business.GoodsService; import io.swagger.annotations.*; import org.apache.shiro.SecurityUtils; @@ -36,6 +37,8 @@ @Autowired private GoodsService goodsService; @Autowired private CateParamSelectService cateParamSelectService; @PreventRepeat @ApiOperation("新建") @@ -52,7 +55,9 @@ @PostMapping("/companyCreate") // @RequiresPermissions("business:goods:create") public ApiResponse companyCreate(@RequestBody Goods goods) { return ApiResponse.success(goodsService.companyCreate(goods)); goodsService.companyCreate(goods); cateParamSelectService.dealGroupVals(goods.getCompanyId()); return ApiResponse.success("操作成功"); } @PreventRepeat server/service/src/main/java/com/doumee/service/CateParamSelectService.java
@@ -95,4 +95,6 @@ * @return long */ long count(CateParamSelect cateParamSelect); void dealGroupVals(Integer companyId); } server/service/src/main/java/com/doumee/service/impl/CateParamSelectServiceImpl.java
@@ -11,6 +11,8 @@ import com.doumee.dao.business.model.CateParamSelect; import com.doumee.service.CateParamSelectService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -24,6 +26,8 @@ @Service public class CateParamSelectServiceImpl implements CateParamSelectService { @Autowired private RedisTemplate redisTemplate; @Autowired private CateParamSelectMapper cateParamSelectMapper; @@ -142,4 +146,25 @@ QueryWrapper<CateParamSelect> wrapper = new QueryWrapper<>(cateParamSelect); return cateParamSelectMapper.selectCount(wrapper); } @Override @Async public void dealGroupVals(Integer companyId) { Boolean isGrouping = (Boolean)redisTemplate.opsForValue().get(companyId+"_isGrouping"); if(isGrouping!=null && isGrouping ){ return; } redisTemplate.opsForValue().set(companyId+"_isGrouping",true); try { //---------TODO-------任康 }catch (Exception e){ }finally { redisTemplate.opsForValue().set(companyId+"_isGrouping",false); } } }