parent
ec33e6fc92
commit
b0c9fda95f
@ -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<String, Object> getParamMap(HttpServletRequest request) {
|
||||
TreeMap<String, Object> paramMap = new TreeMap<>();
|
||||
Map<String, String[]> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -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<User> listUser(@PathVariable("pageNo") Integer pageNo){
|
||||
return pcUserInfoBiz.listPage(pageNo);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue