浏览代码

git-svn-id: https://192.168.57.71/svn/jsgkj@708 931142cf-59ea-a443-aa0e-51397b428577

ld_zhoutl 8 年之前
父节点
当前提交
e96a42d8f9

+ 28 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/common/BaseVo.java

@@ -0,0 +1,28 @@
+package com.xt.js.gkaq.common;
+
+public class BaseVo{
+	/** 当前页码 */
+	private Integer page;
+	/** 每页行数 */
+	private Integer rows;
+	/** 当前操作 */
+	private String opt;
+	public Integer getPage() {
+		return page;
+	}
+	public void setPage(Integer page) {
+		this.page = page;
+	}
+	public Integer getRows() {
+		return rows;
+	}
+	public void setRows(Integer rows) {
+		this.rows = rows;
+	}
+	public String getOpt() {
+		return opt;
+	}
+	public void setOpt(String opt) {
+		this.opt = opt;
+	}
+}

+ 13 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/common/GlobalData.java

@@ -0,0 +1,13 @@
+package com.xt.js.gkaq.common;
+
+
+
+/**
+ * 全局信息设置
+ */
+public class GlobalData {
+	
+	/** session中保存验证码 */
+	public static final String USER_SESSION_CHECK_CODE = "USER_SESSION_CHECK_CODE";
+
+}

+ 15 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/web/ctl/LoginCtl.java

@@ -24,6 +24,21 @@ public class LoginCtl extends BaseCtl {
 		return "sys/index";
 	}
 
+	@RequestMapping(value = "/main")
+	public String main() {
+		return "layouts/main";
+	}
+
+	@RequestMapping(value = "/navbar")
+	public String navbar() {
+		return "layouts/navbar";
+	}
+
+	@RequestMapping(value = "/sidebar")
+	public String sidebar() {
+		return "layouts/sidebar";
+	}
+
 	/**
 	 * ²âÊÔȨÏÞ-ûÓнÇɫʱ
 	 * 

+ 27 - 1
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/web/ctl/UserCtl.java

@@ -1,13 +1,19 @@
 package com.xt.js.gkaq.web.ctl;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.xt.js.gkaq.common.BaseCtl;
 import com.xt.js.gkaq.frame.model.UserModel;
 import com.xt.js.gkaq.frame.service.UserService;
+import com.xt.js.gkaq.web.vo.UserVo;
+import com.yuanxd.tools.pagehelper.PageHelper;
+import com.yuanxd.tools.pagehelper.PageInfo;
 import com.yuanxd.tools.utils.WebJsonResult;
 
 @Controller
@@ -17,10 +23,30 @@ public class UserCtl extends BaseCtl {
     private UserService userService;
 
     @RequestMapping("")
-    public String index() {
+    public String index(Model model, UserVo vo) {
+//    	model.addAttribute("pageInfo", getPageInfo(vo));
         return "user/index";
     }
 
+	/**
+	 * 初始化页面加载数据
+	 */
+    @RequestMapping("list")
+    @ResponseBody
+	public PageInfo<UserModel> getPageInfo(UserVo vo) {
+		// 初始化参数
+		if (null == vo.getPage() || vo.getPage() < 1) {
+			vo.setPage(1);
+		}
+		if (null == vo.getRows() || vo.getRows() < 1) {
+			vo.setRows(1);
+		}
+		PageHelper.startPage(vo.getPage(), vo.getRows());
+		List<UserModel> list = userService.findAll();
+		PageInfo<UserModel> pageResult = new PageInfo<>(list);
+		return pageResult;
+	}
+
     @RequestMapping("add")
     @ResponseBody
     public WebJsonResult add() {

+ 150 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/web/ctl/auth/AuthenticateController.java

@@ -0,0 +1,150 @@
+package com.xt.js.gkaq.web.ctl.auth;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.util.Random;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.xt.js.gkaq.common.BaseCtl;
+import com.xt.js.gkaq.common.GlobalData;
+
+/**
+ * 控制器
+ * 
+ * @author 
+ */
+@Controller
+@RequestMapping(value = "/authCtl")
+public class AuthenticateController extends BaseCtl {
+
+	private Font font = new Font("Arial", Font.PLAIN, 18);
+	private int width = 60;
+	private int height = 20;
+
+	@RequestMapping(value = "checkcode")
+	@ResponseBody
+	public void checkcode(@RequestParam(value="checkcode",required=false) String checkcode,
+			HttpServletResponse response, HttpServletRequest request) {
+		try {
+			response.reset();
+			// 响应类型,即MIME类型
+			response.setContentType("image/jpeg");
+
+			// 不缓存
+			response.setHeader("Pragma", "No-cache");
+			response.setHeader("Cache-Control", "no-cache");
+			response.setDateHeader("Expires", 0);
+
+			BufferedImage image = new BufferedImage(width, height,
+					BufferedImage.TYPE_INT_RGB);
+			Graphics2D g = (Graphics2D) image.getGraphics();
+			Random random = new Random();
+			g.setColor(getRandColor(200, 250));
+			g.fillRect(0, 0, width, height);
+			g.setFont(font);
+			g.setColor(getRandColor(160, 230));
+
+			// 生成随机干扰线
+			for (int i = 0; i < 3; i++) {
+				g.setColor(getRandColor(100, 200));
+				int x = random.nextInt(5);
+				int y = random.nextInt(height);
+				int xl = width - random.nextInt(5);
+				int yl = random.nextInt(height);
+				g.drawLine(x, y, xl, yl);
+				// System.out.println("(" + x + "," + y + ")-(" + xl + "," + yl
+				// + ")");
+			}
+			// 生成随机字符
+			String sRand = "";
+			for (int i = 0; i < 4; i++) {
+				String rand = String.valueOf(random.nextInt(10));
+				sRand += rand;
+			}
+			for (int i = 0; i < sRand.length(); i++) {
+				String rand = sRand.substring(i, i + 1);
+				g.setColor(new Color(20 + random.nextInt(110), 20 + random
+						.nextInt(110), 20 + random.nextInt(110)));
+				g.drawString(rand, 13 * i + 6, 16);
+			}
+			// 将随机验证码放入session
+			request.getSession().setAttribute(
+					GlobalData.USER_SESSION_CHECK_CODE, checkcode);
+			// 关闭画笔
+			g.dispose();
+			// 写出
+			ImageIO.write(image, "JPEG", response.getOutputStream());
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * 生成随机颜色
+	 * 
+	 * @param fc
+	 * @param bc
+	 * @return
+	 */
+	private Color getRandColor(int fc, int bc) {
+		Random random = new Random();
+		if (fc > 255)
+			fc = 255;
+		if (bc > 255)
+			bc = 255;
+		int r = fc + random.nextInt(bc - fc);
+		int g = fc + random.nextInt(bc - fc);
+		int b = fc + random.nextInt(bc - fc);
+		return new Color(r, g, b);
+	}
+
+	/**
+	 * 用户手册下载
+	 * 
+	 * @param request
+	 * @param response
+	 * @throws Exception
+	 */
+	@RequestMapping(value = "downloadYhsc", method = RequestMethod.GET)
+	@ResponseBody
+	public void downloadYhsc(HttpServletResponse response,
+			HttpServletRequest request) throws Exception {
+		String filename = "";
+		String filepath = "";
+		filename = "江苏省港口安全监管与应急管理系统用户手册";
+		filepath = "/files/yhsc.pdf";
+		if (request.getHeader("USER-AGENT").toLowerCase().indexOf("firefox") > 0) { // 火狐浏览器
+			filename = new String(filename.getBytes("UTF-8"), "iso-8859-1");
+		} else {// ie浏览器
+			filename = URLEncoder.encode(filename, "UTF-8");
+		}
+		response.setCharacterEncoding("utf-8");
+		response.setContentType("multipart/form-data");
+		response.setHeader("Content-Disposition", "attachment;fileName="
+				+ filename + ".pdf");
+		try {
+			OutputStream out = response.getOutputStream();
+			out.write(IOUtils.toByteArray(this.getClass().getResourceAsStream(
+					filepath)));
+			out.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

+ 55 - 0
gkaqv2/trunk/modules/web/src/main/java/com/xt/js/gkaq/web/vo/UserVo.java

@@ -0,0 +1,55 @@
+package com.xt.js.gkaq.web.vo;
+
+import com.xt.js.gkaq.common.BaseVo;
+
+public class UserVo extends BaseVo{
+	private String id;
+	private String name;
+	private String code;
+	private String jobCode;
+	private String type;
+	private String cacheFolder;
+	private String cacheUse;
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public String getCode() {
+		return code;
+	}
+	public void setCode(String code) {
+		this.code = code;
+	}
+	public String getJobCode() {
+		return jobCode;
+	}
+	public void setJobCode(String jobCode) {
+		this.jobCode = jobCode;
+	}
+	public String getType() {
+		return type;
+	}
+	public void setType(String type) {
+		this.type = type;
+	}
+	public String getCacheFolder() {
+		return cacheFolder;
+	}
+	public void setCacheFolder(String cacheFolder) {
+		this.cacheFolder = cacheFolder;
+	}
+	public String getCacheUse() {
+		return cacheUse;
+	}
+	public void setCacheUse(String cacheUse) {
+		this.cacheUse = cacheUse;
+	}
+}