zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
package cn.autoform.web.controller.templatecategoryedit;
 
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import cn.autoform.bean.TemplateCategoryOutput;
import cn.autoform.bean.TemplateManagerOutput;
import cn.autoform.bean.page.PageResult;
import cn.autoform.db.entity.TemplateCategoryEntity;
import cn.autoform.db.entity.TenantEntity;
import cn.autoform.fw.exception.RestResult;
import cn.autoform.fw.utility.RestResultGenerator;
import cn.autoform.web.service.formbase.FormBaseService;
import cn.autoform.web.service.templatecategoryedit.TemplateCategoryEditService;
 
/**
 * 模板分类编辑Controller
 * @author lt-zwy
 *
 */
@RestController
public class TemplateCategoryEditController {
    
    @Autowired
    private TemplateCategoryEditService templateCategoryEditService = null;
    
    /**
     * 根据参数查询模板分类信息
     * 
     * @param tenantID 租户id
     * @param businessCategoryID 业务分类id
     * @param templateCategoryID 模板分类id
     * @param pageNum 分頁頁數
     * @return 模板分类信息
     */
    @RequestMapping(value = "${requset.templateCategoryEdit01}", method = RequestMethod.POST)
    public RestResult<List<PageResult<TemplateCategoryOutput>>> getTemplateListService(@RequestBody TenantEntity tenant) {
        //System.out.println(tenant);
        List<PageResult<TemplateCategoryOutput>> list = templateCategoryEditService.queryTemplateList(tenant.getTenantID(),
                tenant.getBusinessCategoryID(), tenant.getSelectFor(),tenant.getPageNum(),tenant.getPageSize(),tenant.getSelectName());
        return RestResultGenerator.genSuccessResult(list);
    }
    /**
     * 新增模板分类
     * @param templateCategoryEntity
     * @return
     */
    @RequestMapping(value = "${requset.templateCategoryEdit02}", method = RequestMethod.POST)
    public RestResult<Object> createTemplateCategoryService(@RequestBody TemplateCategoryEntity templateCategoryEntity) {
        int nRs = templateCategoryEditService.createTemplateCategoryInfo(templateCategoryEntity);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
    
    /**
     * 编辑模板分类
     * @param templateCategoryEntity
     * @return
     */
    @RequestMapping(value = "${requset.templateCategoryEdit03}", method = RequestMethod.POST)
    public RestResult<Object> saveTemplateCategoryService(@RequestBody TemplateCategoryEntity templateCategoryEntity) {
        int nRs = templateCategoryEditService.updateTemlateCategoryInfo(templateCategoryEntity);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
    
    @Autowired
    private FormBaseService formBaseService = null;
    
    /**
     * 新增模板
     * @param templateManagerEntity
     * @return
     */
    @RequestMapping(value = "${requset.templateCategoryEdit04}", method = RequestMethod.POST)
    public RestResult<Object> createTemplateService(@RequestBody TemplateManagerOutput templateManagerOutput) {
        //向formBase表中添加一条数据
        int nRs = templateCategoryEditService.createTemplateInfo(templateManagerOutput);
//        FormBaseEntity formBase = new FormBaseEntity();
//        formBase.setFormID(templateManagerOutput.getFormID());
//        formBase.setCreateUser(templateManagerOutput.getCreateUser());
//        formBase.setUpdateUser(templateManagerOutput.getCreateUser());
//        formBase.setDeleteFlg("0");
//        formBase.setDesignMode("2");
//        formBase.setTemplateID(templateManagerOutput.getTemplateID());
//        formBase.setValidationRuleGroupID(templateManagerOutput.getBusinessCategoryID());
//        formBase.set
//        formBaseService.addFormBase(formBase);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
    
    /**
     * 编辑模板
     * @param templateManagerEntity
     * @return
     */
    @RequestMapping(value = "${requset.templateCategoryEdit05}", method = RequestMethod.POST)
    public RestResult<Object> saveTemplateService(@RequestBody TemplateManagerOutput templateManagerEntity) {
        int nRs = templateCategoryEditService.updateTemplateInfo(templateManagerEntity);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
    
    /**
     * 删除模板分类标签及下属模板
     * @param templateCategoryOutput
     * @return
     */
    @RequestMapping(value = "${requset.templateCategoryEdit06}", method = RequestMethod.POST)
    public RestResult<Object> deleteTemplateCategory(@RequestBody TemplateCategoryOutput templateCategoryOutput) {
        int nRs = templateCategoryEditService.deleteTemplateCategory(templateCategoryOutput);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
    
    /**
     * 删除模板分类标签下的模板
     * @param TemplateManagerOutput
     * return 
     */
    @RequestMapping(value = "${requset.templateCategoryEdit08}",method = RequestMethod.POST)
    public RestResult<Object> deleteTemplate(@RequestBody TemplateManagerOutput templateManagerOutput){
        int nRs = templateCategoryEditService.deleteTemplate(templateManagerOutput);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
    
    
    /**
     * 从该模板创建时,验证当前模板是否已启用,已经停用的模板不可以创建表单
     * @param tenantID
     * @param templateID
     * @return
     */
    @RequestMapping(value = "${requset.templateCategoryEdit07}", method = RequestMethod.GET)
    public RestResult<Object> checkTemplateEnable(String tenantID, String templateID) {
        int nRs = templateCategoryEditService.checkTemplateEnable(tenantID, templateID);
        return RestResultGenerator.genSuccessResult(String.valueOf(nRs));
    }
}