From b0c9fda95f8d3d9ccdc6d70ee5fe067321e5757c Mon Sep 17 00:00:00 2001 From: tianea Date: Wed, 16 Feb 2022 21:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E9=99=86=E3=80=81=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=20=E5=90=8E=E5=8F=B0=E8=8F=9C=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E7=9C=81=E4=BB=BD=E5=9C=B0=E5=9F=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20excel=E6=93=8D=E4=BD=9C=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/base/BaseController.java | 76 +++++++++++++++++++ .../user/pc/PcUserInfoController.java | 21 +++++ 2 files changed, 97 insertions(+) create mode 100644 tz/common/common-core/src/main/java/com/tz/platform/common/core/base/BaseController.java create mode 100644 tz/user/user-service/src/main/java/com/tz/platform/user/pc/PcUserInfoController.java diff --git a/tz/common/common-core/src/main/java/com/tz/platform/common/core/base/BaseController.java b/tz/common/common-core/src/main/java/com/tz/platform/common/core/base/BaseController.java new file mode 100644 index 0000000..c9b2d48 --- /dev/null +++ b/tz/common/common-core/src/main/java/com/tz/platform/common/core/base/BaseController.java @@ -0,0 +1,76 @@ +package com.tz.platform.common.core.base; + +import com.tz.platform.common.core.tools.JSUtil; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.ModelAttribute; + +import javax.servlet.http.HttpServletRequest; +import java.io.DataInputStream; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.Map; +import java.util.TreeMap; + +public class BaseController extends Base { + public static final String TEXT_UTF8 = "text/html;charset=UTF-8"; + public static final String JSON_UTF8 = "application/json;charset=UTF-8"; + public static final String XML_UTF8 = "application/xml;charset=UTF-8"; + + public static final int OK = 200; + public static final int ER = 300; + public static final int TO = 301; + public static final boolean CLOSE = true; + public static final boolean OPEN = false; + + @ModelAttribute + public void enums(ModelMap modelMap) { + + } + + /** + * 重定向 + * + * @param format + * @param arguments + * @return + */ + public static String redirect(String format, Object... arguments) { + return new StringBuffer("redirect:").append(MessageFormat.format(format, arguments)).toString(); + } + + public static String getString(HttpServletRequest request) { + DataInputStream in = null; + try { + in = new DataInputStream(request.getInputStream()); + byte[] buf = new byte[request.getContentLength()]; + in.readFully(buf); + return new String(buf, "UTF-8"); + } catch (Exception e) { + return ""; + } finally { + if (null != in){ + try { + in.close();// 关闭数据流 + } catch (IOException e) { + } + } + + } + } + + @SuppressWarnings("unchecked") + public static TreeMap getParamMap(HttpServletRequest request) { + TreeMap paramMap = new TreeMap<>(); + Map map = request.getParameterMap(); + for (String key : map.keySet()) { + paramMap.put(key, map.get(key)[0]); + } + if (paramMap.isEmpty()) { + return new TreeMap<>(JSUtil.parseObject(getString(request), TreeMap.class)); + } + return paramMap; + } + + + +} diff --git a/tz/user/user-service/src/main/java/com/tz/platform/user/pc/PcUserInfoController.java b/tz/user/user-service/src/main/java/com/tz/platform/user/pc/PcUserInfoController.java new file mode 100644 index 0000000..1af1582 --- /dev/null +++ b/tz/user/user-service/src/main/java/com/tz/platform/user/pc/PcUserInfoController.java @@ -0,0 +1,21 @@ +package com.tz.platform.user.pc; + +import com.tz.platform.common.core.base.BaseController; +import com.tz.platform.entity.User; +import com.tz.platform.user.pc.biz.PcUserInfoBiz; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping(path = "/pc/user") +public class PcUserInfoController extends BaseController { + + @Autowired + private PcUserInfoBiz pcUserInfoBiz; + + @GetMapping(path = "list/{pageNo}") + public Page listUser(@PathVariable("pageNo") Integer pageNo){ + return pcUserInfoBiz.listPage(pageNo); + } +}