net.mingsoft.organization.action.OrganizationAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ms-morganization Show documentation
Show all versions of ms-morganization Show documentation
ms-morganization tools Library
package net.mingsoft.organization.action;
import java.util.List;
import java.io.File;
import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.hutool.core.util.ObjectUtil;
import java.util.*;
import com.alibaba.fastjson.JSON;
import net.mingsoft.base.entity.ResultData;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.BindingResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.ui.ModelMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import net.mingsoft.organization.biz.IOrganizationBiz;
import net.mingsoft.organization.entity.OrganizationEntity;
import net.mingsoft.base.util.JSONObject;
import net.mingsoft.base.entity.BaseEntity;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.base.filter.DateValueFilter;
import net.mingsoft.base.filter.DoubleValueFilter;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/**
* 组织机构管理控制层
* @author 铭飞开源团队
* 创建日期:2020-1-6 14:53:26
* 历史修订:
*/
@Api(value = "组织机构接口")
@Controller("organizationOrganizationAction")
@RequestMapping("/${ms.manager.path}/organization/organization")
public class OrganizationAction extends BaseAction{
/**
* 注入组织机构业务层
*/
@Autowired
private IOrganizationBiz organizationBiz;
/**
* 返回主界面index
*/
@GetMapping("/index")
public String index(HttpServletResponse response,HttpServletRequest request){
return "/organization/organization/index";
}
/**
* 查询组织机构列表
* @param organization 组织机构实体
*/
@ApiOperation(value = "查询组织机构列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "organizationTitle", value = "部门名称", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationId", value = "所属部门", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationStatus", value = "部门状态", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationCode", value = "部门编号", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationLeaders", value = "分管领导", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationLeader", value = "负责人", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationType", 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"),
})
@RequestMapping("/list")
@ResponseBody
public ResultData list(@ModelAttribute @ApiIgnore OrganizationEntity organization,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) {
BasicUtil.startPage();
List organizationList = organizationBiz.query(organization);
return ResultData.build().success(new EUListBean(organizationList,(int)BasicUtil.endPage(organizationList).getTotal()));
}
/**
* 返回编辑界面organization_form
*/
@GetMapping("/form")
public String form(@ModelAttribute OrganizationEntity organization,HttpServletResponse response,HttpServletRequest request,ModelMap model){
if(organization.getId()!=null){
BaseEntity organizationEntity = organizationBiz.getEntity(Integer.parseInt(organization.getId()));
model.addAttribute("organizationEntity",organizationEntity);
}
return "/organization/organization/form";
}
/**
* 获取组织机构
* @param organization 组织机构实体
*/
@ApiOperation(value = "获取组织机构列表接口")
@ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query")
@GetMapping("/get")
@ResponseBody
public ResultData get(@ModelAttribute @ApiIgnore OrganizationEntity organization,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){
if(organization.getId()==null) {
return ResultData.build().error();
}
OrganizationEntity _organization = (OrganizationEntity)organizationBiz.getEntity(Integer.parseInt(organization.getId()));
return ResultData.build().success(_organization);
}
@ApiOperation(value = "保存组织机构列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "organizationTitle", value = "部门名称", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationId", value = "所属部门", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationStatus", value = "部门状态", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationCode", value = "部门编号", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationLeaders", value = "分管领导", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationLeader", value = "负责人", required =false,paramType="query"),
@ApiImplicitParam(name = "organizationType", 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 organization 组织机构实体
*/
@PostMapping("/save")
@ResponseBody
@LogAnn(title = "保存组织机构", businessType = BusinessTypeEnum.INSERT)
@RequiresPermissions("organization:organization:save")
public ResultData save(@ModelAttribute @ApiIgnore OrganizationEntity organization, HttpServletResponse response, HttpServletRequest request) {
if(!StringUtil.checkLength(organization.getOrganizationTitle()+"", 1, 10)){
return ResultData.build().error(getResString("err.length", this.getResString("organization.title"), "1", "10"));
}
if(!StringUtil.checkLength(organization.getOrganizationCode()+"", 1, 10)){
return ResultData.build().error(getResString("err.length", this.getResString("organization.code"), "1", "10"));
}
organizationBiz.saveEntity(organization);
return ResultData.build().success(organization);
}
/**
* @param organization 组织机构实体
*/
@ApiOperation(value = "批量删除组织机构列表接口")
@PostMapping("/delete")
@ResponseBody
@LogAnn(title = "删除组织机构", businessType = BusinessTypeEnum.DELETE)
@RequiresPermissions("organization:organization:del")
public ResultData delete(@RequestBody List organizations,HttpServletResponse response, HttpServletRequest request) {
int[] ids = new int[organizations.size()];
for(int i = 0;i