当前位置: 首页 > news >正文

SpringBoot打造企业级进销存储系统 第七讲

	@Transientprivate String roles; // 所拥有的角色
package com.java1234.entity;import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;import org.hibernate.validator.constraints.NotEmpty;/*** 用户实体* @author Administrator**/
@Entity
@Table(name="t_user")
public class User {@Id@GeneratedValueprivate Integer id; // 编号@NotEmpty(message="请输入用户名!")@Column(length=50)private String userName; // 用户名@NotEmpty(message="请输入密码!")@Column(length=50)private String password; // 密码@Column(length=50)private String trueName; // 真实姓名@Column(length=1000)private String remarks; // 备注@Transientprivate String roles; // 所拥有的角色public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName = userName;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getTrueName() {return trueName;}public void setTrueName(String trueName) {this.trueName = trueName;}public String getRemarks() {return remarks;}public void setRemarks(String remarks) {this.remarks = remarks;}public String getRoles() {return roles;}public void setRoles(String roles) {this.roles = roles;}}
package com.java1234.controller.admin;import java.util.HashMap;
import java.util.List;
import java.util.Map;import javax.annotation.Resource;import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;import com.java1234.entity.Role;
import com.java1234.entity.User;
import com.java1234.service.RoleService;
import com.java1234.service.UserService;@Controller
@RequestMapping("/admin/user")
public class UserAdminController {@Resourceprivate UserService userService;@Resourceprivate RoleService roleService;/*** 分页查询用户信息* @param user* @param page* @param rows* @return* @throws Exception*/@ResponseBody@RequestMapping("/list")public Map<String,Object> list(User user,@RequestParam(value="page",required=false)Integer page,@RequestParam(value="rows",required=false)Integer rows)throws Exception{Map<String,Object> resultMap=new HashMap<>();List<User> userList=userService.list(user, page, rows, Direction.ASC, "id");for(User u:userList){List<Role> roleList=roleService.findByUserId(u.getId());StringBuffer sb=new StringBuffer();for(Role r:roleList){sb.append(","+r.getName());}u.setRoles(sb.toString().replaceFirst(",", ""));}Long total=userService.getCount(user);resultMap.put("rows", userList);resultMap.put("total", total);return resultMap;}}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户管理</title>
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/default/easyui.css"></link>
<link rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.3.3/themes/icon.css"></link>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">function formatEdit(val,row){return "<a href=''><img style='margin-top:4px' src='/static/images/edit.gif'/></a>";}function searchUser(){$("#dg").datagrid('load',{"userName":$("#s_userName").val()});}
</script>
</head>
<body style="margin: 1px"><table id="dg" title="用户管理" class="easyui-datagrid"fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"url="/admin/user/list" fit="true" toolbar="#tb"><thead><th field="id" width="20" align="center">编号</th><th field="userName" width="50" align="center">用户名</th><th field="password" width="50" align="center">密码</th><th field="trueName" width="50" align="center">真实姓名</th><th field="remarks" width="80" align="center">备注</th><th field="roles" width="150" align="center">拥有角色</th><th field="aa" width="50" align="center" formatter="formatEdit">角色设置</th></thead></table><div id="tb"><div><a href="javascript:openUserAddDialog()" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a><a href="javascript:openUserModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改</a><a href="javascript:deleteUser()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除</a></div><div>&nbsp;用户名:&nbsp;<input type="text" id="s_userName" size="20" onkeydown="if(event.keyCode==13) searchUser()"/><a href="javascript:searchUser()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a></div></div>
</body>
</html>
http://www.lryc.cn/news/319913.html

相关文章:

  • 1.实用Qt:解决绘制圆角边框时,圆角锯齿问题
  • JavaWeb08-Filter和Listener
  • 关于ClickHouse的一些小技巧
  • 有来团队后台项目-解析7
  • 用户数据的FLASH存储与应用(FPGA架构)
  • Chrome的V8引擎 和操作系统交互介绍
  • Redis:持久化、线程模型、大 key
  • Linux 16个常用脚本(初级)练习
  • 接口测试及接口测试工具【Postman】相关的面试题
  • android 怎么自定义view
  • JavaScript的事件
  • android 简单快速 自定义dialog(简单好用,不需要设置样式)
  • JAVA代理模式梳理
  • 推荐几个线上兼职,每天两小时收入几十到一百
  • excel封装和ddt D17
  • PHP8编译安装
  • 3D Gaussian Splatting for Real-Time Radiance Field Rendering(慢慢啃,还是挺复杂的)
  • 二叉树<II>:二叉树的四种遍历方式代码实现Python3
  • vite ts vue 项目提示 . Projects must list all files or use an include pattern.
  • 鲸鱼优化算法改进风储机组一次调频出力分配系数,以频率偏差最小为目标优化函数,结合鲸鱼算法WOA捕食过程,改进风储出力分配系数simulink与matlab联合
  • C语言经典面试题目(七)
  • 2024华为春招Django面试题大全,最全知识点揭秘,面试必备!
  • 搜维尔科技:使用SenseGlove Nova手套操纵其“CAVE”投影室中的虚拟对象
  • 独立服务器的优势
  • 前端框架vue的样式操作,以及vue提供的属性功能应用实战
  • 【自动化测试】如何在jenkins中搭建allure
  • 2.域控如何强制转移操作主机角色?使用命令如何强制转移域控的操作角色?
  • C# event的使用
  • 外包干了9天,技术退步明显。。。。。
  • Android Framework 之 Python