三元运算将后台的数字转换为需要的文字
<el-table-column prop="status" label="状态">
<template slot-scope="scope">
{{scope.row.status==1 ? "启用" : "未启用"}}
</template>
</el-table-column>
三元运算三种情况判断
<el-table-column prop="state" label="评论状态" align="center" width="145">
<template slot-scope="scope">
{{scope.row.state==2?"审核不通过":scope.row.state==1?"审核通过":"未审核"}}
</template>
</el-table-column>
对话框按钮居右
<div slot="footer" class="dialog-footer">
<el-button @click="dialogVisible=false">取消</el-button>
<el-button type="primary" @click="add">确定</el-button>
</div>
通过中间表查询
/**
* @author 庭前云落
* @date 2019/11/16 8:23
* @description
*/
@org.apache.ibatis.annotations.Mapper
public interface AdminMapper extends Mapper<Admin> {
@Select("select * from tb_admin")
@Results({
@Result(property = "id",column = "id"),
@Result(property = "rlist",column = "id",many = @Many(select = "com.czxy.dao.RoleMapper.findAllRole"))
})
List<Admin> findAll();
}
/**
* @author 庭前云落
* @date 2019/11/16 9:14
* @description
*/
@org.apache.ibatis.annotations.Mapper
public interface RoleMapper extends Mapper<Role> {
//SELECT * FROM tb_admin_role ar,tb_role tr WHERE tr.`id`=ar.`role_id` AND ar.`admin_id`=1;
@Select("select * from tb_admin_role ar,tb_role tr where tr.id=ar.role_id and ar.admin_id=#{id}")
List<Role> findAllRole(@Param("id") Integer id);
}
使用@Column,手写SQL查所有,没有填充进去名字
@Column(name = "login_name")
private String loginName;
@Result(property = "loginName",column = "login_name"),