de6ca4db131b73eda9010b27be6354c2d1f88543.svn-base
4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.test.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.test.entity.Test;
import com.thinkgem.jeesite.modules.test.service.TestService;
/**
* 测试Controller
* @author ThinkGem
* @version 2013-10-17
*/
@Controller
@RequestMapping(value = "${adminPath}/test/test")
public class TestController extends BaseController {
@Autowired
private TestService testService;
@ModelAttribute
public Test get(@RequestParam(required=false) String id) {
if (StringUtils.isNotBlank(id)){
return testService.get(id);
}else{
return new Test();
}
}
/**
* 显示列表页
* @param test
* @param request
* @param response
* @param model
* @return
*/
@RequiresPermissions("test:test:view")
@RequestMapping(value = {"list", ""})
public String list(Test test, HttpServletRequest request, HttpServletResponse response, Model model) {
return "modules/test/testList";
}
/**
* 获取硕正列表数据(JSON)
* @param test
* @param request
* @param response
* @param model
* @return
*/
@RequiresPermissions("test:test:view")
@RequestMapping(value = "listData")
@ResponseBody
public Page<Test> listData(Test test, HttpServletRequest request, HttpServletResponse response, Model model) {
User user = UserUtils.getUser();
if (!user.isAdmin()){
test.setCreateBy(user);
}
Page<Test> page = testService.findPage(new Page<Test>(request, response), test);
return page;
}
/**
* 新建或修改表单
* @param test
* @param model
* @return
*/
@RequiresPermissions("test:test:view")
@RequestMapping(value = "form")
public String form(Test test, Model model) {
model.addAttribute("test", test);
return "modules/test/testForm";
}
/**
* 表单保存方法
* @param test
* @param model
* @param redirectAttributes
* @return
*/
@RequiresPermissions("test:test:edit")
@RequestMapping(value = "save")
public String save(Test test, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, test)){
return form(test, model);
}
// testService.save(test);
addMessage(redirectAttributes, "保存测试'" + test.getName() + "'成功");
return "redirect:" + adminPath + "/test/test/?repage";
}
/**
* 删除数据方法
* @param id
* @param redirectAttributes
* @return
*/
@RequiresPermissions("test:test:edit")
@RequestMapping(value = "delete")
@ResponseBody
public String delete(Test test, RedirectAttributes redirectAttributes) {
// testService.delete(test);
// addMessage(redirectAttributes, "删除测试成功");
// return "redirect:" + adminPath + "/test/test/?repage";
return "true";
}
@RequestMapping(value = "hetu")
public String hetu( HttpServletRequest request, HttpServletResponse response, Model model) {
return "modules/test/hetu";
}
@RequestMapping(value = "printImage")
public String printImage( HttpServletRequest request, HttpServletResponse response, Model model) {
String height_fw = request.getParameter("heightfw");
String fwimgname = request.getParameter("fwimgname");
String zdimgname = request.getParameter("zdimgname");
String zsbs = request.getParameter("zsbs");
Double fw = StringUtils.isEmpty(height_fw)?0.5:Double.parseDouble(height_fw);
Double beishu = StringUtils.isEmpty(zsbs)?0.95:Double.parseDouble(zsbs);
Double zd = fw>1?0.1:1 - fw;
model.addAttribute("fwHeight", 297*beishu*fw);
model.addAttribute("zdHeight", 297*beishu*zd);
model.addAttribute("fwimgname", fwimgname);
model.addAttribute("zdimgname", zdimgname);
logger.info("fwHeight==={},zdHeight===={}",297*beishu*fw, 297*beishu*zd);
logger.info("images info fw==={} zd==={}",fwimgname,zdimgname);
return "modules/test/printImage";
}
}