All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mingsoft.mprint.action.PrintTemplateAction Maven / Gradle / Ivy

The newest version!
package net.mingsoft.mprint.action;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.mprint.biz.IPrintTemplateBiz;
import net.mingsoft.mprint.entity.PrintTemplateEntity;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
	
	
	
	
/**
 * 打印模板管理控制层
 * @author 暗夜
 * 创建日期:2019-11-27 14:44:05
* 历史修订:
*/ @Api(value = "打印模板接口") @Controller("mprintPrintTemplateAction") @RequestMapping("/${ms.manager.path}/mprint/printTemplate") public class PrintTemplateAction extends BaseAction{ /** * 注入打印模板业务层 */ @Autowired private IPrintTemplateBiz printTemplateBiz; /** * 返回主界面index */ @GetMapping("/index") public String index(HttpServletResponse response,HttpServletRequest request){ return "/mprint/print/index"; } /** * 查询打印模板列表 * @param printTemplate 打印模板实体 */ @ApiOperation(value = "查询打印模板列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "模板名称", required =false,paramType="query"), @ApiImplicitParam(name = "type", value = "模板类型", required =false,paramType="query"), @ApiImplicitParam(name = "dataId", value = "业务id", required =false,paramType="query"), @ApiImplicitParam(name = "content", value = "模板内容", required =false,paramType="query"), @ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"), @ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"), @ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"), @ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"), @ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"), @ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"), }) @GetMapping("/list") @ResponseBody public ResultData list(@ModelAttribute @ApiIgnore PrintTemplateEntity printTemplate,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) { BasicUtil.startPage(); List printTemplateList = printTemplateBiz.query(printTemplate); return ResultData.build().success(new EUListBean(printTemplateList,(int)BasicUtil.endPage(printTemplateList).getTotal())); } /** * 返回编辑界面printTemplate_form */ @GetMapping("/form") public String form(@ModelAttribute PrintTemplateEntity printTemplate,HttpServletResponse response,HttpServletRequest request,ModelMap model){ if(printTemplate.getId()!=null){ BaseEntity printTemplateEntity = printTemplateBiz.getEntity(Integer.parseInt(printTemplate.getId())); model.addAttribute("printTemplateEntity",printTemplateEntity); } return "/mprint/print/form"; } /** * 获取打印模板 * @param printTemplate 打印模板实体 */ @ApiOperation(value = "获取打印模板列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"), @ApiImplicitParam(name = "type", value = "类型", required =false,paramType="query"), @ApiImplicitParam(name = "dataId", value = "业务id", required =false,paramType="query") }) @GetMapping("/get") @ResponseBody public ResultData get(@ModelAttribute @ApiIgnore PrintTemplateEntity printTemplate,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){ if(printTemplate.getId()!=null){ PrintTemplateEntity _printTemplate = (PrintTemplateEntity)printTemplateBiz.getEntity(Integer.parseInt(printTemplate.getId())); return ResultData.build().success(_printTemplate); }else { PrintTemplateEntity _printTemplate = (PrintTemplateEntity)printTemplateBiz.getEntity(printTemplate); if (_printTemplate == null){ return ResultData.build().error(); } return ResultData.build().success(_printTemplate); } } @ApiOperation(value = "保存打印模板列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "name", value = "模板名称", required =true,paramType="query"), @ApiImplicitParam(name = "type", value = "模板类型", required =false,paramType="query"), @ApiImplicitParam(name = "dataId", value = "业务id", required =false,paramType="query"), @ApiImplicitParam(name = "content", value = "模板内容", required =false,paramType="query"), @ApiImplicitParam(name = "createBy", value = "创建人", required =false,paramType="query"), @ApiImplicitParam(name = "createDate", value = "创建时间", required =false,paramType="query"), @ApiImplicitParam(name = "updateBy", value = "修改人", required =false,paramType="query"), @ApiImplicitParam(name = "updateDate", value = "修改时间", required =false,paramType="query"), @ApiImplicitParam(name = "del", value = "删除标记", required =false,paramType="query"), @ApiImplicitParam(name = "id", value = "编号", required =false,paramType="query"), }) /** * 保存打印模板 * @param printTemplate 打印模板实体 */ @PostMapping("/save") @ResponseBody @LogAnn(title = "保存打印模板", businessType = BusinessTypeEnum.INSERT) @RequiresPermissions("mprint:printTemplate:save") public ResultData save(@ModelAttribute @ApiIgnore PrintTemplateEntity printTemplate, HttpServletResponse response, HttpServletRequest request) { if(super.validated("print_template","name",printTemplate.getName())){ return ResultData.build().error(getResString("err.exist", this.getResString("name"))); } //验证模板名称的值是否合法 if(StringUtil.isBlank(printTemplate.getName())){ return ResultData.build().error(getResString("err.empty", this.getResString("name"))); } if(!StringUtil.checkLength(printTemplate.getName()+"", 1, 30)){ return ResultData.build().error(getResString("err.length", this.getResString("name"), "1", "30")); } printTemplateBiz.saveEntity(printTemplate); return ResultData.build().success(printTemplate); } /** * @param printTemplate 打印模板实体 */ @ApiOperation(value = "批量删除打印模板列表接口") @PostMapping("/delete") @ResponseBody @LogAnn(title = "删除打印模板", businessType = BusinessTypeEnum.DELETE) @RequiresPermissions("mprint:printTemplate:del") public ResultData delete(@RequestBody List printTemplates,HttpServletResponse response, HttpServletRequest request) { int[] ids = new int[printTemplates.size()]; for(int i = 0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy