1.用户注册功能实现 2.用户后台登录功能实现
代码思路:
User UserDao add string sql = “insert into t_easyui_user values(?,?,?,?)”; super.executeUpdate(…); list(User user,PageBean pageBean) string sql = “select * from t_easyui_user where true”; if(){ sql + = “…”; } … super.executeQuery(…);
UserAction login User u = UserDao.list(user,pageBean).get(0); if(u!=null){ 跳转到后台主界面(树形菜单界面,main.jsp) } register UserDao.add(…);
login.jsp register.jsp
树形菜单加载 Permission …
PermissionDao 1、查询数据库中的菜单表数据 list(Permission permission,PageBean pageBean){ string sql1 = “select * from t_easyui_permission where true”; //现在希望老板登录可以看到0~9+14这几个菜单 //消费者登录后台只能看到10~13这4个菜单 //分析:就是传入id in (…); //1、通过当前用户的账号获取角色类别 String sql2 = “select * from t_easyui_role_permission where rid = ?”; 上面就获取到了pid的集合 2、给sql1做拼接id in (pids);//pids是通过pid的集合拼成的“,”分割的字符串 } 2、将表数据转换为easyui所能识别的treeVo数据 public List<TreeVo> topNode(Permission permission,PageBean pageBean) 通过BuildTree转成所需格式
PermissionAction topNode(req,resp){ PermissionDao.topNode(permission,pageBean); }
main.jsp(后台管理) main.js $(function(){ $(‘bookMenu’).tree({ url:’/Permission.action?methodName=topNode’ }); })
tab页打开功能 1、绑定tree控件的onClick事件 2、判断被点击的节点是否已经被打开 3、如果是,那么切换到指定的节点 4、如果没有打开过,那么先判断是否是叶子节点。如果是,那么打开, 如果不是,不做任何操作
书籍业务后台功能 layout控件布局
书籍新增界面调试 直接copy easyui的form表单样式调试功能即可 BookDao add(Book book){ string sql = “insert into t_easyui_book values(?,?,?,?)”; } BookAction add(req,resp){ BookDao.add(book); } /bg/addBook.jsp
书籍未上架界面调试 书籍名字查询 BookDao list(Book book,PageBean pageBean){ string sql = “select * from t_easyui_book where true”; if(stringutils.isnotBlank(book.getname)){ sql += “…”; } } BookAction list(req,resp){ bookDao.list(book,pagebean); } /bg/listBook1.jsp book.js $(function(){ $(“dg”).datagrid({ url:’/book.action?methodName=list’ }); }) 首先咱们导jar包! 然后就是实体类: Category 类
package com.huangjie.entity; public class Category { private long id; private String name; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Category(long id, String name) { super(); this.id = id; this.name = name; } public Category() { super(); } @Override public String toString() { return "Category [id=" + id + ", name=" + name + "]"; } }Order 类
package com.huangjie.entity; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; public class Order { private long id; private long uid; @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date orderTime; private String consignee; private String phone; private String postalcode; private String address; private int sendType; @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date sendTime; private float orderPrice; private int orderState; public long getId() { return id; } public void setId(long id) { this.id = id; } public long getUid() { return uid; } public void setUid(long uid) { this.uid = uid; } public Date getOrderTime() { return orderTime; } public void setOrderTime(Date orderTime) { this.orderTime = orderTime; } public String getConsignee() { return consignee; } public void setConsignee(String consignee) { this.consignee = consignee; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getPostalcode() { return postalcode; } public void setPostalcode(String postalcode) { this.postalcode = postalcode; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public int getSendType() { return sendType; } public void setSendType(int sendType) { this.sendType = sendType; } public Date getSendTime() { return sendTime; } public void setSendTime(Date sendTime) { this.sendTime = sendTime; } public float getOrderPrice() { return orderPrice; } public void setOrderPrice(float orderPrice) { this.orderPrice = orderPrice; } public int getOrderState() { return orderState; } public void setOrderState(int orderState) { this.orderState = orderState; } public Order(long id, long uid, Date orderTime, String consignee, String phone, String postalcode, String address, int sendType, Date sendTime, float orderPrice, int orderState) { super(); this.id = id; this.uid = uid; this.orderTime = orderTime; this.consignee = consignee; this.phone = phone; this.postalcode = postalcode; this.address = address; this.sendType = sendType; this.sendTime = sendTime; this.orderPrice = orderPrice; this.orderState = orderState; } public Order() { super(); } @Override public String toString() { return "Order [id=" + id + ", uid=" + uid + ", orderTime=" + orderTime + ", consignee=" + consignee + ", phone=" + phone + ", postalcode=" + postalcode + ", address=" + address + ", sendType=" + sendType + ", sendTime=" + sendTime + ", orderPrice=" + orderPrice + ", orderState=" + orderState + "]"; } }User类
package com.huangjie.entity; public class User { private long id; private String name; private String pwd; private int type; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPwd() { return pwd; } public void setPwd(String pwd) { this.pwd = pwd; } public int getType() { return type; } public void setType(int type) { this.type = type; } public User() { super(); } public User(long id, String name, String pwd, int type) { super(); this.id = id; this.name = name; this.pwd = pwd; this.type = type; } @Override public String toString() { return "User [id=" + id + ", name=" + name + ", pwd=" + pwd + ", type=" + type + "]"; } }RolePermission类
package com.huangjie.entity; public class RolePermission { private long rid; private long pid; public long getRid() { return rid; } public void setRid(long rid) { this.rid = rid; } public long getPid() { return pid; } public void setPid(long pid) { this.pid = pid; } public RolePermission() { super(); } public RolePermission(long rid, long pid) { super(); this.rid = rid; this.pid = pid; } @Override public String toString() { return "RolePermission [rid=" + rid + ", pid=" + pid + "]"; } }Permission类
package com.huangjie.entity; public class Permission { private long id; private String name; private String description; private String url; private long pid; private int ismenu; private long displayno; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public long getPid() { return pid; } public void setPid(long pid) { this.pid = pid; } public int getIsmenu() { return ismenu; } public void setIsmenu(int ismenu) { this.ismenu = ismenu; } public long getDisplayno() { return displayno; } public void setDisplayno(long displayno) { this.displayno = displayno; } public Permission() { super(); } public Permission(long id, String name, String description, String url, long pid, int ismenu, long displayno) { super(); this.id = id; this.name = name; this.description = description; this.url = url; this.pid = pid; this.ismenu = ismenu; this.displayno = displayno; } @Override public String toString() { return "Permission [id=" + id + ", name=" + name + ", description=" + description + ", url=" + url + ", pid=" + pid + ", ismenu=" + ismenu + ", displayno=" + displayno + "]"; } }Orderltem类
package com.huangjie.entity; public class OrderItem { private long id; private long oid; private String bid; private int quantity; public long getId() { return id; } public void setId(long id) { this.id = id; } public long getOid() { return oid; } public void setOid(long oid) { this.oid = oid; } public String getBid() { return bid; } public void setBid(String bid) { this.bid = bid; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public OrderItem(long id, long oid, String bid, int quantity) { super(); this.id = id; this.oid = oid; this.bid = bid; this.quantity = quantity; } public OrderItem() { super(); } @Override public String toString() { return "OrderItem [id=" + id + ", oid=" + oid + ", bid=" + bid + ", quantity=" + quantity + "]"; } }这次的代码非常多 所以我打算分开写博客!