New file |
| | |
| | | package com.ycl.service.user.impl; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.entity.user.UmsResource; |
| | | import com.ycl.mapper.user.UmsResourceMapper; |
| | | import com.ycl.service.user.UmsAdminCacheService; |
| | | import com.ycl.service.user.UmsResourceService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 后台资源管理Service实现类 |
| | | * Created by macro on 2020/2/2. |
| | | */ |
| | | @Service |
| | | public class UmsResourceServiceImpl extends ServiceImpl<UmsResourceMapper, UmsResource>implements UmsResourceService { |
| | | @Autowired |
| | | private UmsAdminCacheService adminCacheService; |
| | | @Override |
| | | public boolean create(UmsResource umsResource) { |
| | | umsResource.setCreateTime(new Date()); |
| | | return save(umsResource); |
| | | } |
| | | |
| | | @Override |
| | | public boolean update(Long id, UmsResource umsResource) { |
| | | umsResource.setId(id); |
| | | boolean success = updateById(umsResource); |
| | | adminCacheService.delResourceListByResource(id); |
| | | return success; |
| | | } |
| | | |
| | | @Override |
| | | public boolean delete(Long id) { |
| | | boolean success = removeById(id); |
| | | adminCacheService.delResourceListByResource(id); |
| | | return success; |
| | | } |
| | | |
| | | @Override |
| | | public Page<UmsResource> list(Long categoryId, String nameKeyword, String urlKeyword, Integer pageSize, Integer pageNum) { |
| | | Page<UmsResource> page = new Page<>(pageNum,pageSize); |
| | | QueryWrapper<UmsResource> wrapper = new QueryWrapper<>(); |
| | | LambdaQueryWrapper<UmsResource> lambda = wrapper.lambda(); |
| | | if(categoryId!=null){ |
| | | lambda.eq(UmsResource::getCategoryId,categoryId); |
| | | } |
| | | if(StrUtil.isNotEmpty(nameKeyword)){ |
| | | lambda.like(UmsResource::getName,nameKeyword); |
| | | } |
| | | if(StrUtil.isNotEmpty(urlKeyword)){ |
| | | lambda.like(UmsResource::getUrl,urlKeyword); |
| | | } |
| | | return page(page,wrapper); |
| | | } |
| | | } |