| | |
| | | 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.contants.AppContants; |
| | | import com.xcong.farmer.cms.common.response.Result; |
| | | import com.xcong.farmer.cms.modules.system.dto.*; |
| | | import com.xcong.farmer.cms.modules.system.entity.*; |
| | |
| | | import com.xcong.farmer.cms.modules.system.service.IUserService; |
| | | import com.xcong.farmer.cms.modules.system.util.LoginUserUtil; |
| | | import com.xcong.farmer.cms.modules.system.vo.*; |
| | | import com.xcong.farmer.cms.utils.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | |
| | | private MessageBoardMapper messageBoardMapper; |
| | | @Resource |
| | | private MenuMapper menuMapper; |
| | | @Resource |
| | | private RedisUtils redisUtils; |
| | | |
| | | @Override |
| | | public Result getUserInPage(AdminUserDto adminUserDto) { |
| | |
| | | long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); |
| | | if(companyId > UserEntity.USER_BELONG_TOP){ |
| | | userEntity.setCompanyId(companyId); |
| | | userEntity.setRoleName(RoleEntity.ROLE_ADMIN_NAME); |
| | | userEntity.setRoleId(RoleEntity.ROLE_ADMIN_NAME_ID); |
| | | }else if(companyId == UserEntity.USER_BELONG_TOP){ |
| | | userEntity.setRoleName(RoleEntity.ROLE_SUPER_NAME); |
| | | userEntity.setRoleId(RoleEntity.ROLE_SUPER_NAME_ID); |
| | | } |
| | | if(StrUtil.isNotEmpty(adminUserDto.getUsername())){ |
| | | userEntity.setUsername(adminUserDto.getUsername()); |
| | |
| | | userRoleMapper.delete(objectQueryWrapper); |
| | | |
| | | this.baseMapper.deleteById(userId); |
| | | |
| | | String redisMember = AppContants.APP_LOGIN_PREFIX + userId; |
| | | String token = redisUtils.getString(redisMember); |
| | | redisUtils.del(AppContants.APP_LOGIN_PREFIX + token); |
| | | SecurityContextHolder.clearContext(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | @Override |
| | | public Result viewHomePage() { |
| | | UserEntity loginUser = LoginUserUtil.getLoginUser(); |
| | | Long companyId = LoginUserUtil.getCompanyId(); |
| | | |
| | | AdminHomePageInfoVo adminHomePageInfoVo = new AdminHomePageInfoVo(); |
| | | |
| | | QueryWrapper<UserRoleEntity> userRoleQueryWrapper = new QueryWrapper<>(); |
| | | userRoleQueryWrapper.eq("user_id",loginUser.getId()); |
| | | List<UserRoleEntity> userRoleEntities = userRoleMapper.selectList(userRoleQueryWrapper); |
| | | if(CollUtil.isNotEmpty(userRoleEntities)){ |
| | | List<String> roleNames = new ArrayList<>(); |
| | | for(UserRoleEntity userRoleEntity : userRoleEntities){ |
| | | RoleEntity roleEntity = roleMapper.selectById(userRoleEntity.getRoleId()); |
| | | roleNames.add(roleEntity.getRoleName()); |
| | | } |
| | | adminHomePageInfoVo.setRoleNames(roleNames); |
| | | } |
| | | |
| | | QueryWrapper<ColumnEntity> columnQueryWrapper = new QueryWrapper<>(); |
| | | columnQueryWrapper.eq("company_id",companyId); |
| | |
| | | |
| | | QueryWrapper<ArticleEntity> articleQueryWrapper = new QueryWrapper<>(); |
| | | articleQueryWrapper.eq("company_id",companyId); |
| | | articleQueryWrapper.eq("del_status",ArticleEntity.DELETE_STATUS_NO); |
| | | adminHomePageInfoVo.setArticleNum(articleMapper.selectCount(articleQueryWrapper)); |
| | | |
| | | QueryWrapper<MessageBoardEntity> messageQueryWrapper = new QueryWrapper<>(); |