AlarmFlowController.java
5.49 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package com.huaheng.common.mail.alarmmail.controller;
import com.huaheng.common.mail.alarmmail.domain.AlarmFlow;
import com.huaheng.common.mail.alarmmail.domain.AlarmType;
import com.huaheng.common.mail.alarmmail.mapper.AlarmFlowMapper;
import com.huaheng.common.mail.alarmmail.mapper.AlarmFlowMapperAuto;
import com.huaheng.common.mail.alarmmail.mapper.AlarmTypeMapperAuto;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.TableDataInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import com.huaheng.framework.web.controller.BaseController;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.thymeleaf.spring5.webflow.view.AjaxEnabledView;
import javax.annotation.Resource;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 报警收件人 处理接口
*
* @author ZengBo
* @date 2019-03-15
*/
@Controller
@RequestMapping("/administration/alarmFlow")
public class AlarmFlowController extends BaseController{
private String prefix = "administration/alarmFlow";
@Resource
private AlarmFlowMapperAuto alarmFlowMapperAuto;
@Resource
private AlarmFlowMapper alarmFlowMapper;
@Resource
private AlarmTypeMapperAuto alarmTypeMapperAuto;
@RequiresPermissions("administration:alarmFlow:view")
@GetMapping()
public String AlarmFlow()
{
return prefix + "/alarmFlow";
}
/**
*条件查询
*/
@RequiresPermissions("administration:alarmFlow:list")
@Log(title = "管理-报警收件人列表", operating = "报警收件人列表", action = BusinessType.GRANT)
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(AlarmFlow alarmFlow)
{
startPage();
List<AlarmFlow> list = alarmFlowMapperAuto.selectListEntityByLike(alarmFlow) ;
return getDataTable(list);
}
/**
*
*/
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
* 新增保存报警收件人
*/
@RequiresPermissions("administration:alarmFlow:add")
@Log(title = "管理-报警收件人新增", operating = "管理-报警收件人新增", action = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
@Transactional
public AjaxResult addSave(AlarmFlow alarmFlow){
String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern p;
Matcher m;
p = Pattern.compile(regEx1);
m = p.matcher(alarmFlow.getAddresseeemail());
if (m.matches()){
alarmFlow.setCreatedBy(ShiroUtils.getLoginName());
alarmFlow.setWarehouseId(ShiroUtils.getWarehouseId());
alarmFlow.setWarehouseCode(ShiroUtils.getWarehouseCode());
return toAjax(alarmFlowMapperAuto.insert(alarmFlow));
}else {
return AjaxResult.error("邮箱格式输入错误!");
}
}
/**
* 获取Type
*/
@RequiresPermissions("administration:alarmFlow:add")
// @Log(title = "", operating = "", action = BusinessType.INSERT)
@PostMapping("/type")
@ResponseBody
@Transactional
public AjaxResult type(){
List<AlarmType> list = alarmFlowMapper.getTypeList();
return AjaxResult.success(list);
}
/**
* 获取Name
*/
@RequiresPermissions("administration:alarmFlow:add")
// @Log(title = "", operating = "", action = BusinessType.INSERT)
@PostMapping("/name")
@ResponseBody
@Transactional
public AjaxResult name(String type){
List<AlarmType> list = alarmFlowMapper.getNameList(type);
return AjaxResult.success(list);
}
/**
* id查询
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Integer id, ModelMap mmap)
{
AlarmFlow alarmFlow = alarmFlowMapperAuto.selectEntityById(id);
mmap.put("alarmFlow", alarmFlow);
AlarmType alarmType = alarmTypeMapperAuto.selectEntityById(alarmFlow.getAlarmid());
mmap.put("alarmName",alarmType.getName());
return prefix + "/edit";
}
/**
* 修改
*/
@RequiresPermissions("administration:alarmFlow:edit")
@Log(title = "管理-报警收件人修改", operating = "报警收件人修改", action = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(AlarmFlow alarmFlow)
{
// containerCapacity.setLastUpdatedBy(ShiroUtils.getLoginName());
return toAjax(alarmFlowMapperAuto.updateByModel(alarmFlow));
}
/**
* 删除
*/
@RequiresPermissions("administration:alarmFlow:remove")
@Log(title = "管理-报警收件人删除", operating ="报警收件人删除", action = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids) {
if (StringUtils.isEmpty(ids))
return AjaxResult.error("id不能为空");
for (Integer id : Convert.toIntArray(ids))
{
alarmFlowMapperAuto.deleteById(id);
}
return AjaxResult.success("删除成功!");
}
}