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

net.mingsoft.organization.action.EmployeeAction Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
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.IEmployeeBiz;
import net.mingsoft.organization.entity.EmployeeEntity;
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("organizationEmployeeAction") @RequestMapping("/${ms.manager.path}/organization/employee") public class EmployeeAction extends BaseAction{ /** * 注入员工业务层 */ @Autowired private IEmployeeBiz employeeBiz; /** * 返回主界面index */ @GetMapping("/index") public String index(HttpServletResponse response,HttpServletRequest request){ return "/organization/employee/index"; } /** * 查询员工列表 * @param employee 员工实体 */ @ApiOperation(value = "查询员工列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "employeeCode", value = "员工编号", required =false,paramType="query"), @ApiImplicitParam(name = "employeeStatus", value = "员工状态", required =false,paramType="query"), @ApiImplicitParam(name = "employeeSex", value = "性别", required =false,paramType="query"), @ApiImplicitParam(name = "employeeRole", value = "所属角色", required =false,paramType="query"), @ApiImplicitParam(name = "postIds", value = "岗位", required =false,paramType="query"), @ApiImplicitParam(name = "organizationId", value = "所属部门", required =false,paramType="query"), @ApiImplicitParam(name = "politics", value = "政治面貌", required =false,paramType="query"), @ApiImplicitParam(name = "education", value = "员工学历", required =false,paramType="query"), @ApiImplicitParam(name = "age", value = "年龄", required =false,paramType="query"), @ApiImplicitParam(name = "employeePhone", 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 EmployeeEntity employee,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model,BindingResult result) { BasicUtil.startPage(); List employeeList = employeeBiz.queryListByOrganization(employee); return ResultData.build().success(new EUListBean(employeeList,(int)BasicUtil.endPage(employeeList).getTotal())); } /** * 返回编辑界面employee_form */ @GetMapping("/form") public String form(@ModelAttribute EmployeeEntity employee,HttpServletResponse response,HttpServletRequest request,ModelMap model){ if(employee.getId()!=null){ BaseEntity employeeEntity = employeeBiz.getEntity(Integer.parseInt(employee.getId())); model.addAttribute("employeeEntity",employeeEntity); } return "/organization/employee/form"; } /** * 获取员工 * @param employee 员工实体 */ @ApiOperation(value = "获取员工列表接口") @ApiImplicitParam(name = "id", value = "编号", required =true,paramType="query") @GetMapping("/get") @ResponseBody public ResultData get(@ModelAttribute @ApiIgnore EmployeeEntity employee,HttpServletResponse response, HttpServletRequest request,@ApiIgnore ModelMap model){ if(employee.getId()==null) { return ResultData.build().error(); } EmployeeEntity _employee = (EmployeeEntity)employeeBiz.getEntity(Integer.parseInt(employee.getId())); return ResultData.build().success(_employee); } @ApiOperation(value = "保存员工列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "employeeCode", value = "员工编号", required =false,paramType="query"), @ApiImplicitParam(name = "employeeStatus", value = "员工状态", required =true,paramType="query"), @ApiImplicitParam(name = "employeeSex", value = "性别", required =true,paramType="query"), @ApiImplicitParam(name = "employeeRole", value = "所属角色", required =true,paramType="query"), @ApiImplicitParam(name = "postIds", value = "岗位", required =true,paramType="query"), @ApiImplicitParam(name = "organizationId", value = "所属部门", required =false,paramType="query"), @ApiImplicitParam(name = "politics", value = "政治面貌", required =true,paramType="query"), @ApiImplicitParam(name = "education", value = "员工学历", required =true,paramType="query"), @ApiImplicitParam(name = "age", value = "年龄", required =true,paramType="query"), @ApiImplicitParam(name = "employeePhone", value = "手机号", required =true,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 employee 员工实体 */ @PostMapping("/save") @ResponseBody @LogAnn(title = "保存员工", businessType = BusinessTypeEnum.INSERT) @RequiresPermissions("organization:employee:save") public ResultData save(@ModelAttribute @ApiIgnore EmployeeEntity employee, HttpServletResponse response, HttpServletRequest request) { if(!StringUtil.checkLength(employee.getEmployeeCode()+"", 1, 10)){ return ResultData.build().error(getResString("err.length", this.getResString("employee.code"), "1", "10")); } //验证员工状态的值是否合法 if(StringUtil.isBlank(employee.getEmployeeStatus())){ return ResultData.build().error(getResString("err.empty", this.getResString("employee.status"))); } //验证性别的值是否合法 if(StringUtil.isBlank(employee.getEmployeeSex())){ return ResultData.build().error(getResString("err.empty", this.getResString("employee.sex"))); } //验证所属角色的值是否合法 if(StringUtil.isBlank(employee.getEmployeeRole())){ return ResultData.build().error(getResString("err.empty", this.getResString("employee.role"))); } //验证岗位的值是否合法 if(StringUtil.isBlank(employee.getPostIds())){ return ResultData.build().error(getResString("err.empty", this.getResString("post.ids"))); } //验证政治面貌的值是否合法 if(StringUtil.isBlank(employee.getPolitics())){ return ResultData.build().error(getResString("err.empty", this.getResString("politics"))); } //验证员工学历的值是否合法 if(StringUtil.isBlank(employee.getEducation())){ return ResultData.build().error(getResString("err.empty", this.getResString("education"))); } //验证年龄的值是否合法 if(StringUtil.isBlank(employee.getAge())){ return ResultData.build().error(getResString("err.empty", this.getResString("age"))); } if(!StringUtil.checkLength(employee.getAge()+"", 0, 11)){ return ResultData.build().error(getResString("err.length", this.getResString("age"), "0", "11")); } //验证手机号的值是否合法 if(StringUtil.isBlank(employee.getPhone())){ return ResultData.build().error(getResString("err.empty", this.getResString("employee.phone"))); } employeeBiz.saveEntity(employee); return ResultData.build().success(employee); } /** * @param employee 员工实体 */ @ApiOperation(value = "批量删除员工列表接口") @PostMapping("/delete") @ResponseBody @LogAnn(title = "删除员工", businessType = BusinessTypeEnum.DELETE) @RequiresPermissions("organization:employee:del") public ResultData delete(@RequestBody List employees,HttpServletResponse response, HttpServletRequest request) { int[] ids = new int[employees.size()]; for(int i = 0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy