| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package com.template.services.impl;
- import com.template.mapper.SystemMenuMapper;
- import com.template.model.pojo.SystemMenu;
- import com.template.model.result.CommonResult;
- import com.template.model.vo.SystemMenuVo;
- import com.template.services.SystemMenuService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- 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.HashMap;
- import java.util.List;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author ceshi
- * @since 2023-03-30
- */
- @Service
- public class SystemMenuServiceImpl extends ServiceImpl<SystemMenuMapper, SystemMenu> implements SystemMenuService {
- @Autowired
- private SystemMenuMapper systemMenuMapper;
- /*
- 查询获取所有菜单
- * */
- @Override
- @Cacheable(value = {"getSystemMenus"})
- public CommonResult<List<SystemMenu>> getSystemMenus() {
- List<SystemMenu> result = systemMenuMapper.selectList(null);
- return CommonResult.ok().setResult(result);
- }
- @Override
- //根据参数清除名为roomThirdSetting的缓存
- @CacheEvict(value = "getSystemMenus")
- public CommonResult insertSystemMenus(SystemMenu systemMenu) {
- int result = systemMenuMapper.insert(systemMenu);
- return result > 0 ? CommonResult.ok() : CommonResult.fail();
- }
- @Override
- public CommonResult deleteSystemMenu(Integer userID) {
- int result = systemMenuMapper.deleteById(Long.valueOf(userID));
- return result > 0 ? CommonResult.ok() : CommonResult.fail();
- }
- @Override
- public CommonResult<List<SystemMenu>> getSystemMenusByParentId(Long parentId) {
- HashMap<String, Object> map = new HashMap<>();
- // 自定义要查询
- map.put("menu_parent_id",parentId);
- List<SystemMenu> result = systemMenuMapper.selectByMap(map);
- return CommonResult.ok().setResult(result);
- }
- @Override
- @CacheEvict(value = "insertPlaybackRecord", allEntries = true)//allEntries清除整个缓存区
- public CommonResult<Integer> insertPlaybackRecord(SystemMenu systemMenu) {
- Integer result = systemMenuMapper.insert(systemMenu); // 帮我们自动生成id
- return CommonResult.ok().setResult(result);// 发现,id会自动回填
- }
- @Override
- @Cacheable("insertPlaybackRecord")
- public CommonResult<List<SystemMenu>> getPlaybackRecords() {
- List<SystemMenu> result = systemMenuMapper.selectList(null);
- return CommonResult.ok().setResult(result);
- }
- @Override
- public CommonResult<List<SystemMenuVo>> getPlaybackRecordBySql() {
- List<SystemMenuVo> result = systemMenuMapper.querySystemMenuAll();
- return CommonResult.ok().setResult(result);
- }
- }
|