首页 > 其他分享 >后台管理增删查改统一性代码--若依前后端分离版本

后台管理增删查改统一性代码--若依前后端分离版本

时间:2022-11-24 19:00:45浏览次数:40  
标签:rows -- List list role 增删 查改 total public


controller:
@PreAuthorize("@ss.hasPermi('system:role:list')") //和数据库中的menu中的字段有关系
@GetMapping("list")
public TableDataInfo list(SysRole role){
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataInfo(list);
}

表格分页数据对象
public class TableDataInfo implements Serializable{
private static final long serialVersionUID = 1L;
//总记录数量
private long total;
//列表数据
private List<?> rows;
//消息状态码
private int code;
//消息内容
private String msg;

//表格数据对象 ==无参构造
public TableDataInfo(){}

//有参数构造,分页,list列表数据,total总记录数
public TableDataInfo(List<?> list,int total){
this.rows = list;
this.total = total;
}
public long getTotal(){
return total;
}
public void setTotal(long total){
this.total = total;
}
public List<?> getRows(){
return rows;
}
public List<?> setRows(List<?> rows){
this.rows = rows
}
public int getCode(){
return code;
}
public void setCode(int code){
this.code = code;
}
public String getMsg(){
return msg;
}
public void setMsg(String msg){
this.msg = msg;
}

}

mapper.xml
<sql id="selectRoleVo"> 连表查询的sql语句,写一遍就不用在单独写了 </sql>
列表展示和列表查询展示角色信息的sql
<select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult">
<include refid="selectRoleVo"/>
where r.del_flag='0'
<if test="roleName !=null and roleName!=''">
and r.role_name like concat('%',#{roleName},'%')
</if>
<if test="beginTime !=null and beginTime !=''">
and r.create_time >= TO_DATE(#{beginTime},'YYYY-MM-DD HH24-MI-SS')
</if>
</select>
统一性修改角色信息表的sql
<update id="updateRole" parameterType="SysRole">
update sys_role
<set>
<if test="roleName!=null and roleName!=''">role_name=#{roleName},</if>
<if test="status!=null and status!=''">status=#{status},</if>
update_time= now() 或者是 current_timestamp
</set>
where role_id=#{roleId}
</update>
批量删除角色信息的sql
<delete id="deleteRoleByIds" parameterType="String">
update sys_role set del_flag = '2' where role_id in
<foreach collection="array" item="roleId" open="(" separator="," close=")">
#{roleId}
</foreach>
</delete>
增加角色信息的统一性sql
<insert id="insertRole" parameterType="SysRole">
insert into sys_role(
<if test="roleId!=null and roleId!=''">role_id,</if>
<if test="roleName!=null and roleName!=''">role_name,</if>
create_time
) values(
<if test="roleId!=null and roleId!=''">#{roleId},</if>
<if test="roleName!=null and roleName!=''">#{roleName},</if>
current_timestamp
)
</insert>

 

标签:rows,--,List,list,role,增删,查改,total,public
From: https://blog.51cto.com/u_15890333/5884514

相关文章

  • MySQL 3 字段约束条件
    今日内容详细字段约束条件无符号、零填充unsigned idintunsignedzerofill idint(5)zerofill非空createtablet1( idint, namevarchar(16));insertint......
  • springboot初步整合web(一)
    1、整合filterspringboot-整合filter方式1@WebFilter(filternameurlpattern="拦截多个请求,{"*.do","*.action","/firstServlet",}")publicclsssFirstFilterimplementsF......
  • nginx处理options请求
    运维=nginx处理options请求发表于2019-09-29 | 分类于前端  | 没有评论禁止OPTIONS请求响应200运维:补漏洞-禁止OPTIONS请求响应200。安全扫描检测到部分请......
  • Jsoup爬取网络内容(包括图片文件),保存到本地和保存到数据库(一)
    背景:项目需要某个区县的天气数据,需要从中国气象局的官网中进行爬取。但是,中国气象局服务器调用接口返回的数据没有我想要的信息,比如说是未来24小时的天气温度,气压,风速等信息......
  • 实验五
    实验内容四pets.hpp#include<iostream>usingnamespacestd;//abstractclassclassMachinePets{public:MachinePets(conststrings){nickname=s......
  • springboot 与 k8s结合使用
    https://juejin.cn/post/7138975184114941965https://techdozo.dev/deploying-a-restful-spring-boot-microservice-on-kubernetes/https://piotrminkowski.com/2017/05/......
  • 第七章11
    【题目描述】编写一个程序,输入奥运会参赛国的个数及国家名称,输出按照字典顺序的入场次序。【输入】多行,第一行是一个数字,表示参赛国的个数n(n<200)。下面是n个参赛国的国......
  • 11.24
    今日内容1.无符号、零填充2.非空3.默认值4.唯一值5.主键6.自增7.外键简介8.关系的判断9.一对多关系10.外键字段的建立11.多对多关系12一对一关系1.无符号、零......
  • 字典树
    如上图根节点什么都不存其余结点存各自对应的一个字符从根节点往下遍历,遍历的字符组成了存储的字符串建树\(next[i][c]\)表示字符串与之对应的(\(s[j]=c\))下一......
  • 【Java】将枚举类转换为Redis字典缓存
     字典翻译框架实现看这篇:https://www.cnblogs.com/mindzone/p/16890632.html枚举的特性首先是枚举的一些特性:1、枚举实例直接在枚举类中声明2、重载构造器,......