登录前:

登录后:

用户登录后,首页的图标按键、热门职位、附近职位都不显示。
因为同时在修改后台代码,一开始怀疑是后台接口有问题,没有返回数据,查看前台API函数和后台api接口,未发现异常。
检查/pages/index/index.vue页面代码,发现图标按键、热门职位、附近职位由两个逻辑控制
- <template v-if="hasLogin == false || (hasLogin && userInfo.memberRole == 0)">
- <view style="padding: 20upx 0;background-color: #FFFFFF;">
- <yzb-grid :columnNum="5" :data="grid" show-border="false" @click="handleClickGrid">yzb-grid>
- view>
- <view class="notice">
- <yzb-notice theme="primary" :list="noticeList" theKey="title" :showIcon="true" :showMore="true" @goItem="goItem" @goMore="goMore">yzb-notice>
- view>
- <view class="post">
- <view class="title"><text class="name">热门职位text>view>
- <view class="post-list">
- <view v-for="(item, index) in postList" :key="index" @click="toPost(item)">
- <text class="post-item" :class="index % 4 != 0 ? 'post-item-left' : ''">{{ item.name }}text>
- view>
- view>
- <view class="all" @click="toAllPost">
- <text class="all-text">查看全部职位text>
- <text class="yzb yzb-next post-next">text>
- view>
- view>
-
- <view class="title"><text class="name">附近职位text>view>
- <yzb-position :positions="list" @click="positionDetail">yzb-position>
- template>
- <template v-if="hasLogin && userInfo.memberRole == 1">
- <view class="title"><text class="name">人才列表text>view>
-
- <yzb-resume :list="list" @click="resumeDetail">yzb-resume>
- template>
可能存在一种情况hasLogin为true且userInfo.memberRole不为0(比如undefined),导致同时不满足两个的显示条件,造成页面空白。
出现这个问题的原因有两个,一是后台api接口的UmsLoginUser实体类(jeecg-module-job/src/main/java/org/jeecg/modules/job/ums/entity/UmsLoginUser.java)定义缺少memberRole字段,二是前台判断条件存在漏洞。
后台UmsLoginUser实体类添加memberRole字段后恢复正常显示
- package org.jeecg.modules.job.ums.entity;
-
- import com.baomidou.mybatisplus.annotation.*;
- import com.fasterxml.jackson.annotation.JsonFormat;
- import com.fasterxml.jackson.annotation.JsonIgnore;
- import com.fasterxml.jackson.annotation.JsonProperty;
- import lombok.Data;
- import lombok.EqualsAndHashCode;
- import lombok.experimental.Accessors;
- import org.jeecg.common.aspect.annotation.Dict;
- import org.jeecgframework.poi.excel.annotation.Excel;
- import org.springframework.format.annotation.DateTimeFormat;
-
- import java.io.Serializable;
- import java.util.Date;
-
-
- /**
- * 通过复制org.jeecg.common.system.vo.LoginUser创建
- *
- */
- @Data
- @EqualsAndHashCode(callSuper = false)
- @Accessors(chain = true)
- @TableName("sys_user")
- public class UmsLoginUser implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- /**
- * sys_user表id字段
- */
- @TableId(type = IdType.ASSIGN_ID)
- private String id;
-
- /**
- * 跳过
- * sys_user表user_code字段
- *
- */
-
-
- /**
- * 登录账号
- * sys_user表username字段
- */
- @Excel(name = "登录账号", width = 15)
- private String username;
-
- /**
- * 真实姓名
- * sys_user表realname字段
- */
- @Excel(name = "真实姓名", width = 15)
- private String realname;
-
- /**
- * 跳过
- * sys_user表nickname字段
- *
- */
-
- /**
- * 密码
- * sys_user表password字段
- */
- @JsonIgnore
- private String password;
-
- /**
- * md5密码盐
- * sys_user表salt字段
- */
- @JsonIgnore
- private String salt;
-
- /**
- * 头像
- * sys_user表avatar字段
- */
- @Excel(name = "头像", width = 15,type = 2)
- private String avatar;
-
- /**
- * 生日
- * sys_user表birthday字段
- */
- @Excel(name = "生日", width = 15, format = "yyyy-MM-dd")
- @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
- @DateTimeFormat(pattern = "yyyy-MM-dd")
- private Date birthday;
-
- /**
- * 性别(1:男 2:女)
- * sys_user表sex字段
- */
- @Excel(name = "性别", width = 15,dicCode="sex")
- @Dict(dicCode = "sex")
- private Integer sex;
-
- /**
- * 电子邮件
- * sys_user表email字段
- */
- @Excel(name = "电子邮件", width = 15)
- private String email;
-
- /**
- * 电话
- * sys_user表phone字段
- */
- @Excel(name = "电话", width = 15)
- private String phone;
-
- /**
- * 登录选择部门编码
- * sys_user表org_code字段
- */
- private String orgCode;
-
-
-
- /**
- * sys_user表无此字段
- * sys_user表没有orgCodeTxt字段
- *
- * 部门名称*/
- private transient String orgCodeTxt;
-
- /**
- * 状态(1:正常 2:冻结 )
- * sys_user表status字段
- */
- @Excel(name = "状态", width = 15,dicCode="user_status")
- @Dict(dicCode = "user_status")
- private Integer status;
-
- /**
- * 删除状态(0,正常,1已删除)
- * sys_user表del_flag字段
- */
- @Excel(name = "删除状态", width = 15,dicCode="del_flag")
- @TableLogic
- private Integer delFlag;
-
- /**
- * 跳过
- * sys_user表third_id、third_type字段
- *
- *
- */
-
- /**
- * 同步工作流引擎1同步0不同步
- * sys_user表activiti_sync字段
- */
- private Integer activitiSync;
-
-
- /**
- * 工号,唯一键
- * sys_user表work_no字段
- */
- @Excel(name = "工号", width = 15)
- private String workNo;
-
- /**
- * 职务,关联职务表
- * sys_user表post字段
- */
- @Excel(name = "职务", width = 15)
- @Dict(dictTable ="sys_position",dicText = "name",dicCode = "code")
- private String post;
-
- /**
- * 座机号
- * sys_user表telephone字段
- */
- @Excel(name = "座机号", width = 15)
- private String telephone;
-
- /**
- * 跳过
- * sys_user表integral、total_integral字段
- *
- */
-
-
- /**
- * 创建人
- * sys_user表
- * create_by字段
- */
- private String createBy;
-
- /**
- * 创建时间
- * sys_user表
- * create_time字段
- */
- private Date createTime;
-
- /**
- * 更新人
- * sys_user表
- * update_by字段
- */
- private String updateBy;
-
- /**
- * 更新时间
- * sys_user表
- * update_time字段
- */
- private Date updateTime;
-
-
- /**
- * 身份(0 普通成员 1 上级)
- * sys_user表
- * user_identity字段
- */
- @Excel(name="(1普通成员 2上级)",width = 15)
- private Integer userIdentity;
-
- /**
- * 负责部门
- * sys_user表
- * depart_ids字段
- */
- @Excel(name="负责部门",width = 15,dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
- @Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
- private String departIds;
-
-
- /**
- * 用户角色:0-求职者,1-招聘单位
- * sys_user表
- * member_role字段
- */
- private Integer memberRole;
-
-
- /**
- * 多租户ids临时用,不持久化数据库(数据库字段不存在)
- * sys_user表
- * rel_tenant_ids字段
- */
- @TableField(exist = false)
- private String relTenantIds;
-
- /**设备id uniapp推送用
- * sys_user表
- * client_id字段
- * */
- private String clientId;
-
- /**
- * 登录首页地址
- *
- * sys_user表无此字段
- * 没有homePath字段
- */
- @TableField(exist = false)
- private String homePath;
-
- /**
- * 职位名称
- * sys_user表无此字段
- * 没有postText字段
- */
- @TableField(exist = false)
- private String postText;
-
- /**
- * 登录选择租户ID
- * sys_user表login_tenant_id字段
- */
- private Integer loginTenantId;
-
-
- /**
- * 流程状态
- * sys_user表bpm_status字段
- */
- private String bpmStatus;
-
- /**
- * 缺少字段:
- * company_id
- * company
- *
- */
-
-
-
- }
同时,修改前台判断逻辑,确保有一个兜底的,即不满足时,显示带图标按键、热门职位、附近职位的。
- <template v-if="hasLogin && userInfo.memberRole == 1">
- <view class="title"><text class="name">人才列表text>view>
- <yzb-resume :list="list" @click="resumeDetail">yzb-resume>
- template>
- <template v-else>
- <view style="padding: 20upx 0;background-color: #FFFFFF;">
- <yzb-grid :columnNum="5" :data="grid" show-border="false" @click="handleClickGrid">yzb-grid>
- view>
- <view class="notice">
- <yzb-notice theme="primary" :list="noticeList" theKey="title" :showIcon="true" :showMore="true" @goItem="goItem" @goMore="goMore">yzb-notice>
- view>
- <view class="post">
- <view class="title"><text class="name">热门职位text>view>
- <view class="post-list">
- <view v-for="(item, index) in postList" :key="index" @click="toPost(item)">
- <text class="post-item" :class="index % 4 != 0 ? 'post-item-left' : ''">{{ item.name }}text>
- view>
- view>
- <view class="all" @click="toAllPost">
- <text class="all-text">查看全部职位text>
- <text class="yzb yzb-next post-next">text>
- view>
- view>
- <view class="title"><text class="name">附近职位text>view>
- <yzb-position :positions="list" @click="positionDetail">yzb-position>
- template>