| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringPool; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xcong.farmer.cms.common.response.Result; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminAddBelongDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminBelongDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminDeleteDto; |
| | | import com.xcong.farmer.cms.modules.system.dto.AdminUpdateBelongDto; |
| | | import com.xcong.farmer.cms.modules.system.entity.BelongEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.UserEntity; |
| | | import com.xcong.farmer.cms.modules.system.entity.UserRoleEntity; |
| | | import com.xcong.farmer.cms.modules.system.mapper.BelongMapper; |
| | | import com.xcong.farmer.cms.modules.system.service.IBelongService; |
| | | import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; |
| | |
| | | public class BelongServiceImpl extends ServiceImpl<BelongMapper, BelongEntity> implements IBelongService { |
| | | @Override |
| | | public Result getBelongInPage(AdminBelongDto adminBelongDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | Long belongId = userlogin.getBelongId(); |
| | | Page<AdminBelongVo> page = new Page<>(adminBelongDto.getPageNum(), adminBelongDto.getPageSize()); |
| | | BelongEntity belongEntity = new BelongEntity(); |
| | | String name = adminBelongDto.getName(); |
| | | if(StrUtil.isNotEmpty(name)){ |
| | | belongEntity.setName(name); |
| | | } |
| | | if(belongId != UserEntity.USER_BELONG_TOP){ |
| | | belongEntity.setId(belongId); |
| | | } |
| | | IPage<AdminBelongVo> list = this.baseMapper.selectAdminBelongInPage(page,belongEntity); |
| | | return Result.ok(list); |
| | |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | Long belongId = userlogin.getBelongId(); |
| | | QueryWrapper<BelongEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | if(belongId != 0L){ |
| | | if(belongId != UserEntity.USER_BELONG_TOP){ |
| | | objectQueryWrapper.eq("id",belongId); |
| | | } |
| | | List<BelongEntity> belongEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | |
| | | } |
| | | return Result.ok(adminBelongVos); |
| | | } |
| | | |
| | | @Override |
| | | public Result delObjs(AdminDeleteDto adminDeleteDto) { |
| | | String ids = adminDeleteDto.getIds(); |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | if(userlogin.getBelongId() != UserEntity.USER_BELONG_TOP){ |
| | | return Result.fail("没有删除权限"); |
| | | } |
| | | if(StrUtil.isNotEmpty(ids)){ |
| | | String[] belongIds = ids.split(StringPool.COMMA); |
| | | for(String belongIdStr : belongIds){ |
| | | Long belongId = Long.valueOf(belongIdStr); |
| | | this.baseMapper.deleteById(belongId); |
| | | } |
| | | } |
| | | return Result.ok("删除成功"); |
| | | } |
| | | } |