| | |
| | | package com.ots.project.demo.controller; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ots.common.utils.DateUtils; |
| | | import com.ots.common.utils.StringUtils; |
| | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 表格相关 |
| | | * |
| | | * @author ots |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/demo/table") |
| | | public class DemoTableController extends BaseController { |
| | | private String prefix = "demo/table"; |
| | | |
| | | private final static List<UserTableModel> users = new ArrayList<UserTableModel>(); |
| | | |
| | | { |
| | | users.add(new UserTableModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0")); |
| | | users.add(new UserTableModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1")); |
| | |
| | | users.add(new UserTableModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1")); |
| | | } |
| | | |
| | | /** |
| | | * 搜索相关 |
| | | */ |
| | | @GetMapping("/search") |
| | | public String search() { |
| | | return prefix + "/search"; |
| | | } |
| | | |
| | | /** |
| | | * 数据汇总 |
| | | */ |
| | | @GetMapping("/footer") |
| | | public String footer() { |
| | | return prefix + "/footer"; |
| | | } |
| | | |
| | | /** |
| | | * 组合表头 |
| | | */ |
| | | @GetMapping("/groupHeader") |
| | | public String groupHeader() { |
| | | return prefix + "/groupHeader"; |
| | | } |
| | | |
| | | /** |
| | | * 表格导出 |
| | | */ |
| | | @GetMapping("/export") |
| | | public String export() { |
| | | return prefix + "/export"; |
| | | } |
| | | |
| | | /** |
| | | * 翻页记住选择 |
| | | */ |
| | | @GetMapping("/remember") |
| | | public String remember() { |
| | | return prefix + "/remember"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转至指定页 |
| | | */ |
| | | @GetMapping("/pageGo") |
| | | public String pageGo() { |
| | | return prefix + "/pageGo"; |
| | | } |
| | | |
| | | /** |
| | | * 自定义查询参数 |
| | | */ |
| | | @GetMapping("/params") |
| | | public String params() { |
| | | return prefix + "/params"; |
| | | } |
| | | |
| | | /** |
| | | * 多表格 |
| | | */ |
| | | @GetMapping("/multi") |
| | | public String multi() { |
| | | return prefix + "/multi"; |
| | | } |
| | | |
| | | /** |
| | | * 点击按钮加载表格 |
| | | */ |
| | | @GetMapping("/button") |
| | | public String button() { |
| | | return prefix + "/button"; |
| | | } |
| | | |
| | | /** |
| | | * 表格冻结列 |
| | | */ |
| | | @GetMapping("/fixedColumns") |
| | | public String fixedColumns() { |
| | | return prefix + "/fixedColumns"; |
| | | } |
| | | |
| | | /** |
| | | * 自定义触发事件 |
| | | */ |
| | | @GetMapping("/event") |
| | | public String event() { |
| | | return prefix + "/event"; |
| | | } |
| | | |
| | | /** |
| | | * 表格细节视图 |
| | | */ |
| | | @GetMapping("/detail") |
| | | public String detail() { |
| | | return prefix + "/detail"; |
| | | } |
| | | |
| | | /** |
| | | * 表格图片预览 |
| | | */ |
| | | @GetMapping("/image") |
| | | public String image() { |
| | | return prefix + "/image"; |
| | | } |
| | | |
| | | /** |
| | | * 动态增删改查 |
| | | */ |
| | | @GetMapping("/curd") |
| | | public String curd() { |
| | | return prefix + "/curd"; |
| | | } |
| | | |
| | | /** |
| | | * 表格拖拽操作 |
| | | */ |
| | | @GetMapping("/reorder") |
| | | public String reorder() { |
| | | return prefix + "/reorder"; |
| | | } |
| | | |
| | | /** |
| | | * 表格其他操作 |
| | | */ |
| | | @GetMapping("/other") |
| | | public String other() { |
| | | return prefix + "/other"; |
| | | } |
| | | |
| | | /** |
| | | * 查询数据 |
| | | */ |
| | | @PostMapping("/list") |
| | | @ResponseBody |
| | | public TableDataInfo list(UserTableModel userModel) { |
| | | TableDataInfo rspData = new TableDataInfo(); |
| | | List<UserTableModel> userList = new ArrayList<UserTableModel>(Arrays.asList(new UserTableModel[users.size()])); |
| | | Collections.copy(userList, users); |
| | | |
| | | // 查询条件过滤 |
| | | if (StringUtils.isNotEmpty(userModel.getUserName())) { |
| | | userList.clear(); |
| | | for (UserTableModel user : users) { |
| | |
| | | return rspData; |
| | | } |
| | | } |
| | | class UserTableModel { |
| | | |
| | | class UserTableModel { |
| | | /** |
| | | * 用户ID |
| | | */ |
| | | private int userId; |
| | | |
| | | /** |
| | | * 用户编号 |
| | | */ |
| | | private String userCode; |
| | | |
| | | /** |
| | | * 用户姓名 |
| | | */ |
| | | private String userName; |
| | | |
| | | /** |
| | | * 用户性别 |
| | | */ |
| | | private String userSex; |
| | | |
| | | /** |
| | | * 用户手机 |
| | | */ |
| | | private String userPhone; |
| | | |
| | | /** |
| | | * 用户邮箱 |
| | | */ |
| | | private String userEmail; |
| | | |
| | | /** |
| | | * 用户余额 |
| | | */ |
| | | private double userBalance; |
| | | |
| | | /** |
| | | * 用户状态(0正常 1停用) |
| | | */ |
| | | private String status; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | public UserTableModel() { |
| | | |
| | | } |
| | | |
| | | public UserTableModel(int userId, String userCode, String userName, String userSex, String userPhone, |
| | | String userEmail, double userBalance, String status) { |
| | | this.userId = userId; |
| | |
| | | this.status = status; |
| | | this.createTime = DateUtils.getNowDate(); |
| | | } |
| | | |
| | | public int getUserId() { |
| | | return userId; |
| | | } |
| | | |
| | | public void setUserId(int userId) { |
| | | this.userId = userId; |
| | | } |
| | | |
| | | public String getUserCode() { |
| | | return userCode; |
| | | } |
| | | |
| | | public void setUserCode(String userCode) { |
| | | this.userCode = userCode; |
| | | } |
| | | |
| | | public String getUserName() { |
| | | return userName; |
| | | } |
| | | |
| | | public void setUserName(String userName) { |
| | | this.userName = userName; |
| | | } |
| | | |
| | | public String getUserSex() { |
| | | return userSex; |
| | | } |
| | | |
| | | public void setUserSex(String userSex) { |
| | | this.userSex = userSex; |
| | | } |
| | | |
| | | public String getUserPhone() { |
| | | return userPhone; |
| | | } |
| | | |
| | | public void setUserPhone(String userPhone) { |
| | | this.userPhone = userPhone; |
| | | } |
| | | |
| | | public String getUserEmail() { |
| | | return userEmail; |
| | | } |
| | | |
| | | public void setUserEmail(String userEmail) { |
| | | this.userEmail = userEmail; |
| | | } |
| | | |
| | | public double getUserBalance() { |
| | | return userBalance; |
| | | } |
| | | |
| | | public void setUserBalance(double userBalance) { |
| | | this.userBalance = userBalance; |
| | | } |
| | | |
| | | public String getStatus() { |
| | | return status; |
| | | } |
| | | |
| | | public void setStatus(String status) { |
| | | this.status = status; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | | |
| | | public void setCreateTime(Date createTime) { |
| | | this.createTime = createTime; |
| | | } |