1
2
3
4
5 package gboat2.attachment.action;
6
7 import gboat2.base.core.annotation.Domain;
8 import gboat2.base.core.annotation.ListDomain;
9 import gboat2.base.core.annotation.Module;
10 import gboat2.base.core.annotation.Operation;
11 import gboat2.base.core.annotation.Operations;
12 import gboat2.base.core.annotation.Preference;
13 import gboat2.base.core.dao.QuerySupport;
14 import gboat2.base.core.model.ModuleAttach;
15 import gboat2.base.core.service.IModuleService;
16 import gboat2.base.core.web.BaseActionSupport;
17 import gboat2.base.core.web.JsonResultSupport;
18 import gboat2.attachment.business.IAttachConfigBusiness;
19 import gboat2.attachment.model.AttachConfig;
20
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.commons.lang3.StringUtils;
26 import org.apache.struts2.convention.annotation.ResultPath;
27 import org.springframework.beans.factory.annotation.Autowired;
28
29
30
31
32
33
34
35
36 @ListDomain(value = AttachConfig.class)
37 @Domain(AttachConfig.class)
38 @Module(name = "模块附件配置", code = "ATTACH_CONFIG")
39 @Preference("/系统配置/附件类型设置")
40 @ResultPath("/content/attachConfig")
41 @Operations(value = { @Operation(name = "新增", code = "add", desc = "新增附件类型"), @Operation(name = "编辑", code = "edit", desc = "编辑附件类型"),
42 @Operation(name = "查看", code = "view", desc = "查看"), @Operation(name = "删除", code = "delete", desc = "删除") })
43 public class AttachConfigAction extends BaseActionSupport {
44
45 private static final long serialVersionUID = 1568958760674720749L;
46
47 @Autowired
48 IModuleService moduleService;
49
50 @Autowired
51 IAttachConfigBusiness attachConfigBusiness;
52
53 private List<ModuleAttach> moduleList = new ArrayList<ModuleAttach>();
54
55 @Override
56 protected void initList(Map<String, Object> params) {
57 params.put(QuerySupport.PARAM_ORDERBY, "moduleName,attachOrder");
58 }
59
60 @Override
61 protected void initEdit() {
62 moduleList = (List<ModuleAttach>) moduleService.getModuleAttachList();
63 }
64
65 @Override
66 public String ajaxSave() {
67 AttachConfig attachConfig = (AttachConfig) getModel();
68
69 if (attachConfig != null && StringUtils.isEmpty(attachConfig.getConfigId()) && StringUtils.isNotEmpty(attachConfig.getModuleName())
70 && attachConfigBusiness.isAttachTypeUsedInConfig(attachConfig.getModuleName(), attachConfig.getAttachType())) {
71 JsonResultSupport.outputFailure("此附件类型在该模块中已存在,不可重复增加!");
72 return null;
73 }
74 return super.ajaxSave();
75 }
76
77 @Override
78 public String ajaxDelete() {
79 AttachConfig attachConfig = (AttachConfig) getModel();
80
81 if (attachConfig != null && StringUtils.isNotEmpty(attachConfig.getAttachType())
82 && attachConfigBusiness.isAttachTypeUsedInAttachment(attachConfig.getAttachType())) {
83 JsonResultSupport.outputFailure("此附件类型已使用,不可删除!");
84 return null;
85 }
86 return super.ajaxDelete();
87 }
88
89 public List<ModuleAttach> getModuleList() {
90 return moduleList;
91 }
92
93 public void setModuleList(List<ModuleAttach> moduleList) {
94 this.moduleList = moduleList;
95 }
96
97 }