tangchuanxing_branch
CR7 9 months ago
parent 1825daad59
commit 14e3193145

@ -0,0 +1,73 @@
/*
* Copyright (c) 2018-2999 广 All rights reserved.
*
* https://www.mall4j.com/
*
*
*
*
*/
// 定义了一个名为com.yami.shop.service.impl的包用于组织代码
package com.yami.shop.service.impl;
// 导入了MyBatis Plus框架中的LambdaQueryWrapper类用于构建条件查询
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
// 导入了MyBatis Plus框架中的ServiceImpl类用于提供基础的CRUD操作实现
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
// 导入了Area实体类这个类代表了数据库中的一个表
import com.yami.shop.bean.model.Area;
// 导入了AreaMapper接口用于数据库操作
import com.yami.shop.dao.AreaMapper;
// 导入了AreaService接口用于定义业务操作
import com.yami.shop.service.AreaService;
// 导入了Spring框架的注解用于注入依赖和定义服务
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* AreaService
*
* @author lgh on 2018/10/26 lgh20181026
*/
@Service
public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements AreaService {
// 使用Spring的@Autowired注解自动注入AreaMapper
@Autowired
private AreaMapper areaMapper;
/**
* id
* 使MyBatis PlusLambdaQueryWrapperidpid
* 使Spring@Cacheable"area"pid
*
* @param pid id
* @return Areaidpid
*/
@Override
@Cacheable(cacheNames = "area", key = "#pid")
public List<Area> listByPid(Long pid) {
return areaMapper.selectList(new LambdaQueryWrapper<Area>().eq(Area::getParentId, pid));
}
/**
* id
* 使Spring@CacheEvict"area"pid
*
* @param pid id
*/
@Override
@CacheEvict(cacheNames = "area", key = "#pid")
public void removeAreaCacheByParentId(Long pid) {
// 方法体为空清除缓存的逻辑由Spring Cache自动处理
}
}
Loading…
Cancel
Save