界面如下,前端layui完成分页,有对应查询,编辑,删除接口

用户多角色分页展示的实现:

mapper.xml文件相关代码(直接在sql语句进行分页查询)

mybatis一对多映射

<resultMap id="userdetailResult"  type="com.cc.vo.VUser">
  <id property="id"  column="id" />
  <result property="no" column="no"/>
  <result property="name" column="name"/>
  <result property="flag" column="flag"/>
  <collection property="roles"  ofType="com.cc.entity.Role" javaType="java.util.ArrayList">
    <id property="id"  column="rid"/>
    <result property="info"  column="info"/>
  </collection>
</resultMap>

<select id="findAll" parameterType="map" resultMap="userdetailResult">
    select u.id,u.no,u.name,r.id rid,r.info,u.flag from (SELECT * from t_user
      <where>
        <if test="no != null and no != ''">
          and no LIKE CONCAT('%',#{no},'%' )
        </if>
        <if test="flag != null">
          and flag = #{flag}
        </if>
      </where>

    limit #{page},#{limit}) u
    inner join
    t_userrole ur ON
    ur.uid=u.id
    inner join t_role r
    on r.id=ur.rid
    ORDER BY u.id ASC
</select>

 


layui对后台传来的的roles集合进行遍历展示职位:
userlimit.html部分代码
{field: 'id', title: '序号', sort: true, fixed: 'left'}
, {field: 'no', title: '工号'}
, {field: 'name', title: '姓名', sort: true}
, {field: 'roles', title: '职位', sort: true, templet:function(info){
    var rlist = info.roles;
    var infos = "";
    for(var i = 0; i < rlist.length; i++){
        infos = infos + " "+rlist[i].info;
    }
    return infos;
    }}

 





内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!