若依 3.4
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package com.ruoyi.web.controller.demo.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* 模态窗口
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/demo/modal")
|
||||
public class DemoDialogController
|
||||
{
|
||||
private String prefix = "demo/modal";
|
||||
|
||||
/**
|
||||
* 模态窗口
|
||||
*/
|
||||
@GetMapping("/dialog")
|
||||
public String dialog()
|
||||
{
|
||||
return prefix + "/dialog";
|
||||
}
|
||||
|
||||
/**
|
||||
* 弹层组件
|
||||
*/
|
||||
@GetMapping("/layer")
|
||||
public String layer()
|
||||
{
|
||||
return prefix + "/layer";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单
|
||||
*/
|
||||
@GetMapping("/form")
|
||||
public String form()
|
||||
{
|
||||
return prefix + "/form";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格
|
||||
*/
|
||||
@GetMapping("/table")
|
||||
public String table()
|
||||
{
|
||||
return prefix + "/table";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格check
|
||||
*/
|
||||
@GetMapping("/check")
|
||||
public String check()
|
||||
{
|
||||
return prefix + "/table/check";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格radio
|
||||
*/
|
||||
@GetMapping("/radio")
|
||||
public String radio()
|
||||
{
|
||||
return prefix + "/table/radio";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格回传父窗体
|
||||
*/
|
||||
@GetMapping("/parent")
|
||||
public String parent()
|
||||
{
|
||||
return prefix + "/table/parent";
|
||||
}
|
||||
}
|
@@ -0,0 +1,243 @@
|
||||
package com.ruoyi.web.controller.demo.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
||||
/**
|
||||
* 表单相关
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/demo/form")
|
||||
public class DemoFormController
|
||||
{
|
||||
private String prefix = "demo/form";
|
||||
|
||||
private final static List<UserFormModel> users = new ArrayList<UserFormModel>();
|
||||
{
|
||||
users.add(new UserFormModel(1, "1000001", "测试1", "15888888888"));
|
||||
users.add(new UserFormModel(2, "1000002", "测试2", "15666666666"));
|
||||
users.add(new UserFormModel(3, "1000003", "测试3", "15666666666"));
|
||||
users.add(new UserFormModel(4, "1000004", "测试4", "15666666666"));
|
||||
users.add(new UserFormModel(5, "1000005", "测试5", "15666666666"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按钮页
|
||||
*/
|
||||
@GetMapping("/button")
|
||||
public String button()
|
||||
{
|
||||
return prefix + "/button";
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框
|
||||
*/
|
||||
@GetMapping("/select")
|
||||
public String select()
|
||||
{
|
||||
return prefix + "/select";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单校验
|
||||
*/
|
||||
@GetMapping("/validate")
|
||||
public String validate()
|
||||
{
|
||||
return prefix + "/validate";
|
||||
}
|
||||
|
||||
/**
|
||||
* 功能扩展(包含文件上传)
|
||||
*/
|
||||
@GetMapping("/jasny")
|
||||
public String jasny()
|
||||
{
|
||||
return prefix + "/jasny";
|
||||
}
|
||||
|
||||
/**
|
||||
* 拖动排序
|
||||
*/
|
||||
@GetMapping("/sortable")
|
||||
public String sortable()
|
||||
{
|
||||
return prefix + "/sortable";
|
||||
}
|
||||
|
||||
/**
|
||||
* 选项卡 & 面板
|
||||
*/
|
||||
@GetMapping("/tabs_panels")
|
||||
public String tabs_panels()
|
||||
{
|
||||
return prefix + "/tabs_panels";
|
||||
}
|
||||
|
||||
/**
|
||||
* 栅格
|
||||
*/
|
||||
@GetMapping("/grid")
|
||||
public String grid()
|
||||
{
|
||||
return prefix + "/grid";
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单向导
|
||||
*/
|
||||
@GetMapping("/wizard")
|
||||
public String wizard()
|
||||
{
|
||||
return prefix + "/wizard";
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
*/
|
||||
@GetMapping("/upload")
|
||||
public String upload()
|
||||
{
|
||||
return prefix + "/upload";
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期和时间页
|
||||
*/
|
||||
@GetMapping("/datetime")
|
||||
public String datetime()
|
||||
{
|
||||
return prefix + "/datetime";
|
||||
}
|
||||
|
||||
/**
|
||||
* 左右互选组件
|
||||
*/
|
||||
@GetMapping("/duallistbox")
|
||||
public String duallistbox()
|
||||
{
|
||||
return prefix + "/duallistbox";
|
||||
}
|
||||
|
||||
/**
|
||||
* 基本表单
|
||||
*/
|
||||
@GetMapping("/basic")
|
||||
public String basic()
|
||||
{
|
||||
return prefix + "/basic";
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索自动补全
|
||||
*/
|
||||
@GetMapping("/autocomplete")
|
||||
public String autocomplete()
|
||||
{
|
||||
return prefix + "/autocomplete";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户数据
|
||||
*/
|
||||
@GetMapping("/userModel")
|
||||
@ResponseBody
|
||||
public AjaxResult userModel()
|
||||
{
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
|
||||
ajax.put("code", 200);
|
||||
ajax.put("value", users);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据集合
|
||||
*/
|
||||
@GetMapping("/collection")
|
||||
@ResponseBody
|
||||
public AjaxResult collection()
|
||||
{
|
||||
String[] array = { "ruoyi 1", "ruoyi 2", "ruoyi 3", "ruoyi 4", "ruoyi 5" };
|
||||
AjaxResult ajax = new AjaxResult();
|
||||
ajax.put("value", array);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
||||
class UserFormModel
|
||||
{
|
||||
/** 用户ID */
|
||||
private int userId;
|
||||
|
||||
/** 用户编号 */
|
||||
private String userCode;
|
||||
|
||||
/** 用户姓名 */
|
||||
private String userName;
|
||||
|
||||
/** 用户手机 */
|
||||
private String userPhone;
|
||||
|
||||
public UserFormModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UserFormModel(int userId, String userCode, String userName, String userPhone)
|
||||
{
|
||||
this.userId = userId;
|
||||
this.userCode = userCode;
|
||||
this.userName = userName;
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
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 getUserPhone()
|
||||
{
|
||||
return userPhone;
|
||||
}
|
||||
|
||||
public void setUserPhone(String userPhone)
|
||||
{
|
||||
this.userPhone = userPhone;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.ruoyi.web.controller.demo.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* 图标相关
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/demo/icon")
|
||||
public class DemoIconController
|
||||
{
|
||||
private String prefix = "demo/icon";
|
||||
|
||||
/**
|
||||
* FontAwesome图标
|
||||
*/
|
||||
@GetMapping("/fontawesome")
|
||||
public String fontAwesome()
|
||||
{
|
||||
return prefix + "/fontawesome";
|
||||
}
|
||||
|
||||
/**
|
||||
* Glyphicons图标
|
||||
*/
|
||||
@GetMapping("/glyphicons")
|
||||
public String glyphicons()
|
||||
{
|
||||
return prefix + "/glyphicons";
|
||||
}
|
||||
}
|
@@ -0,0 +1,303 @@
|
||||
package com.ruoyi.web.controller.demo.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.web.controller.demo.domain.UserOperateModel;
|
||||
|
||||
/**
|
||||
* 操作控制
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/demo/operate")
|
||||
public class DemoOperateController extends BaseController
|
||||
{
|
||||
private String prefix = "demo/operate";
|
||||
|
||||
private final static Map<Integer, UserOperateModel> users = new LinkedHashMap<Integer, UserOperateModel>();
|
||||
{
|
||||
users.put(1, new UserOperateModel(1, "1000001", "测试1", "0", "15888888888", "ry@qq.com", 150.0, "0"));
|
||||
users.put(2, new UserOperateModel(2, "1000002", "测试2", "1", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||
users.put(3, new UserOperateModel(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||
users.put(4, new UserOperateModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||
users.put(5, new UserOperateModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
|
||||
users.put(6, new UserOperateModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
|
||||
users.put(7, new UserOperateModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||
users.put(8, new UserOperateModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
|
||||
users.put(9, new UserOperateModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||
users.put(10, new UserOperateModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||
users.put(11, new UserOperateModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||
users.put(12, new UserOperateModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||
users.put(13, new UserOperateModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
|
||||
users.put(14, new UserOperateModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
|
||||
users.put(15, new UserOperateModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||
users.put(16, new UserOperateModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
|
||||
users.put(17, new UserOperateModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||
users.put(18, new UserOperateModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
|
||||
users.put(19, new UserOperateModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||
users.put(20, new UserOperateModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||
users.put(21, new UserOperateModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||
users.put(22, new UserOperateModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
|
||||
users.put(23, new UserOperateModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
|
||||
users.put(24, new UserOperateModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||
users.put(25, new UserOperateModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
||||
users.put(26, new UserOperateModel(26, "1000026", "测试26", "1", "15666666666", "ry@qq.com", 250.0, "1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格
|
||||
*/
|
||||
@GetMapping("/table")
|
||||
public String table()
|
||||
{
|
||||
return prefix + "/table";
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他
|
||||
*/
|
||||
@GetMapping("/other")
|
||||
public String other()
|
||||
{
|
||||
return prefix + "/other";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*/
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(UserOperateModel userModel)
|
||||
{
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
List<UserOperateModel> userList = new ArrayList<UserOperateModel>(users.values());
|
||||
// 查询条件过滤
|
||||
if (StringUtils.isNotEmpty(userModel.getSearchValue()))
|
||||
{
|
||||
userList.clear();
|
||||
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
||||
{
|
||||
if (entry.getValue().getUserName().equals(userModel.getSearchValue()))
|
||||
{
|
||||
userList.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
|
||||
{
|
||||
rspData.setRows(userList);
|
||||
rspData.setTotal(userList.size());
|
||||
return rspData;
|
||||
}
|
||||
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
|
||||
Integer pageSize = pageDomain.getPageNum() * 10;
|
||||
if (pageSize > userList.size())
|
||||
{
|
||||
pageSize = userList.size();
|
||||
}
|
||||
rspData.setRows(userList.subList(pageNum, pageSize));
|
||||
rspData.setTotal(userList.size());
|
||||
return rspData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add(ModelMap mmap)
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存用户
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(UserOperateModel user)
|
||||
{
|
||||
Integer userId = users.size() + 1;
|
||||
user.setUserId(userId);
|
||||
return AjaxResult.success(users.put(userId, user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@GetMapping("/edit/{userId}")
|
||||
public String edit(@PathVariable("userId") Integer userId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("user", users.get(userId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存用户
|
||||
*/
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(UserOperateModel user)
|
||||
{
|
||||
return AjaxResult.success(users.put(user.getUserId(), user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出
|
||||
*/
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(UserOperateModel user)
|
||||
{
|
||||
List<UserOperateModel> list = new ArrayList<UserOperateModel>(users.values());
|
||||
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
||||
return util.exportExcel(list, "用户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载模板
|
||||
*/
|
||||
@GetMapping("/importTemplate")
|
||||
@ResponseBody
|
||||
public AjaxResult importTemplate()
|
||||
{
|
||||
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
||||
return util.importTemplateExcel("用户数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*/
|
||||
@PostMapping("/importData")
|
||||
@ResponseBody
|
||||
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
|
||||
{
|
||||
ExcelUtil<UserOperateModel> util = new ExcelUtil<UserOperateModel>(UserOperateModel.class);
|
||||
List<UserOperateModel> userList = util.importExcel(file.getInputStream());
|
||||
String message = importUser(userList, updateSupport);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
Integer[] userIds = Convert.toIntArray(ids);
|
||||
for (Integer userId : userIds)
|
||||
{
|
||||
users.remove(userId);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看详细
|
||||
*/
|
||||
@GetMapping("/detail/{userId}")
|
||||
public String detail(@PathVariable("userId") Integer userId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("user", users.get(userId));
|
||||
return prefix + "/detail";
|
||||
}
|
||||
|
||||
@PostMapping("/clean")
|
||||
@ResponseBody
|
||||
public AjaxResult clean()
|
||||
{
|
||||
users.clear();
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入用户数据
|
||||
*
|
||||
* @param userList 用户数据列表
|
||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<UserOperateModel> userList, Boolean isUpdateSupport)
|
||||
{
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
||||
{
|
||||
throw new BusinessException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
for (UserOperateModel user : userList)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 验证是否存在这个用户
|
||||
boolean userFlag = false;
|
||||
for (Map.Entry<Integer, UserOperateModel> entry : users.entrySet())
|
||||
{
|
||||
if (entry.getValue().getUserName().equals(user.getUserName()))
|
||||
{
|
||||
userFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!userFlag)
|
||||
{
|
||||
Integer userId = users.size() + 1;
|
||||
user.setUserId(userId);
|
||||
users.put(userId, user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 导入成功");
|
||||
}
|
||||
else if (isUpdateSupport)
|
||||
{
|
||||
users.put(user.getUserId(), user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、用户 " + user.getUserName() + " 更新成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、用户 " + user.getUserName() + " 已存在");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
}
|
||||
}
|
||||
if (failureNum > 0)
|
||||
{
|
||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||
throw new BusinessException(failureMsg.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,367 @@
|
||||
package com.ruoyi.web.controller.demo.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.page.TableSupport;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 表格相关
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@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(3, "1000003", "测试3", "0", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||
users.add(new UserTableModel(4, "1000004", "测试4", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||
users.add(new UserTableModel(5, "1000005", "测试5", "0", "15666666666", "ry@qq.com", 140.0, "1"));
|
||||
users.add(new UserTableModel(6, "1000006", "测试6", "1", "15666666666", "ry@qq.com", 330.0, "1"));
|
||||
users.add(new UserTableModel(7, "1000007", "测试7", "0", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||
users.add(new UserTableModel(8, "1000008", "测试8", "1", "15666666666", "ry@qq.com", 170.0, "1"));
|
||||
users.add(new UserTableModel(9, "1000009", "测试9", "0", "15666666666", "ry@qq.com", 180.0, "1"));
|
||||
users.add(new UserTableModel(10, "1000010", "测试10", "0", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||
users.add(new UserTableModel(11, "1000011", "测试11", "1", "15666666666", "ry@qq.com", 110.0, "1"));
|
||||
users.add(new UserTableModel(12, "1000012", "测试12", "0", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||
users.add(new UserTableModel(13, "1000013", "测试13", "1", "15666666666", "ry@qq.com", 380.0, "1"));
|
||||
users.add(new UserTableModel(14, "1000014", "测试14", "0", "15666666666", "ry@qq.com", 280.0, "1"));
|
||||
users.add(new UserTableModel(15, "1000015", "测试15", "0", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||
users.add(new UserTableModel(16, "1000016", "测试16", "1", "15666666666", "ry@qq.com", 260.0, "1"));
|
||||
users.add(new UserTableModel(17, "1000017", "测试17", "1", "15666666666", "ry@qq.com", 210.0, "1"));
|
||||
users.add(new UserTableModel(18, "1000018", "测试18", "1", "15666666666", "ry@qq.com", 340.0, "1"));
|
||||
users.add(new UserTableModel(19, "1000019", "测试19", "1", "15666666666", "ry@qq.com", 160.0, "1"));
|
||||
users.add(new UserTableModel(20, "1000020", "测试20", "1", "15666666666", "ry@qq.com", 220.0, "1"));
|
||||
users.add(new UserTableModel(21, "1000021", "测试21", "1", "15666666666", "ry@qq.com", 120.0, "1"));
|
||||
users.add(new UserTableModel(22, "1000022", "测试22", "1", "15666666666", "ry@qq.com", 130.0, "1"));
|
||||
users.add(new UserTableModel(23, "1000023", "测试23", "1", "15666666666", "ry@qq.com", 490.0, "1"));
|
||||
users.add(new UserTableModel(24, "1000024", "测试24", "1", "15666666666", "ry@qq.com", 570.0, "1"));
|
||||
users.add(new UserTableModel(25, "1000025", "测试25", "1", "15666666666", "ry@qq.com", 250.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("/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)
|
||||
{
|
||||
if (user.getUserName().equals(userModel.getUserName()))
|
||||
{
|
||||
userList.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
if (null == pageDomain.getPageNum() || null == pageDomain.getPageSize())
|
||||
{
|
||||
rspData.setRows(userList);
|
||||
rspData.setTotal(userList.size());
|
||||
return rspData;
|
||||
}
|
||||
Integer pageNum = (pageDomain.getPageNum() - 1) * 10;
|
||||
Integer pageSize = pageDomain.getPageNum() * 10;
|
||||
if (pageSize > userList.size())
|
||||
{
|
||||
pageSize = userList.size();
|
||||
}
|
||||
rspData.setRows(userList.subList(pageNum, pageSize));
|
||||
rspData.setTotal(userList.size());
|
||||
return rspData;
|
||||
}
|
||||
}
|
||||
|
||||
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.userCode = userCode;
|
||||
this.userName = userName;
|
||||
this.userSex = userSex;
|
||||
this.userPhone = userPhone;
|
||||
this.userEmail = userEmail;
|
||||
this.userBalance = userBalance;
|
||||
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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
package com.ruoyi.web.controller.demo.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.Type;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
|
||||
public class UserOperateModel extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int userId;
|
||||
|
||||
@Excel(name = "用户编号")
|
||||
private String userCode;
|
||||
|
||||
@Excel(name = "用户姓名")
|
||||
private String userName;
|
||||
|
||||
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
|
||||
private String userSex;
|
||||
|
||||
@Excel(name = "用户手机")
|
||||
private String userPhone;
|
||||
|
||||
@Excel(name = "用户邮箱")
|
||||
private String userEmail;
|
||||
|
||||
@Excel(name = "用户余额")
|
||||
private double userBalance;
|
||||
|
||||
@Excel(name = "用户状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||
private Date createTime;
|
||||
|
||||
public UserOperateModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public UserOperateModel(int userId, String userCode, String userName, String userSex, String userPhone,
|
||||
String userEmail, double userBalance, String status)
|
||||
{
|
||||
this.userId = userId;
|
||||
this.userCode = userCode;
|
||||
this.userName = userName;
|
||||
this.userSex = userSex;
|
||||
this.userPhone = userPhone;
|
||||
this.userEmail = userEmail;
|
||||
this.userBalance = userBalance;
|
||||
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;
|
||||
}
|
||||
}
|
@@ -34,6 +34,7 @@ public class SysIndexController extends BaseController
|
||||
mmap.put("menus", menus);
|
||||
mmap.put("user", user);
|
||||
mmap.put("copyrightYear", Global.getCopyrightYear());
|
||||
mmap.put("demoEnabled", Global.isDemoEnabled());
|
||||
return "index";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user