Преглед на файлове

1.新增企业及员工信息管理。

tomatozq преди 5 години
родител
ревизия
62ba3e60e1

+ 238 - 0
src/main/java/com/jpsoft/smart/modules/base/controller/CompanyInfoController.java

@@ -0,0 +1,238 @@
+package com.jpsoft.smart.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.common.utils.PojoUtils;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@RestController
+@RequestMapping("/base/companyInfo")
+@Api(description = "companyInfo")
+public class CompanyInfoController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    public MessageResult<CompanyInfo> create(){
+        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+
+        CompanyInfo companyInfo = new CompanyInfo();
+
+        msgResult.setData(companyInfo);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+    
+    @ApiOperation(value="添加信息")
+    @PostMapping("add")
+    public MessageResult<CompanyInfo> add(@RequestBody CompanyInfo companyInfo,@RequestAttribute String subject){
+        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+
+        try {
+            companyInfo.setId(UUID.randomUUID().toString());
+            companyInfo.setDelFlag(false);
+            companyInfo.setCreateBy(subject);
+            companyInfo.setCreateTime(new Date());
+            
+            int affectCount = companyInfoService.insert(companyInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(companyInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="获取信息")
+    @GetMapping("edit/{id}")
+    public MessageResult<CompanyInfo> edit(@PathVariable("id") String id){
+        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(id);
+
+            if (companyInfo != null) {
+                msgResult.setResult(true);
+                msgResult.setData(companyInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新")
+    @PostMapping("update")
+    public MessageResult<CompanyInfo> update(@RequestBody CompanyInfo companyInfo,@RequestAttribute String subject){
+        MessageResult<CompanyInfo> msgResult = new MessageResult<>();
+
+        try {
+            companyInfo.setUpdateBy(subject);
+            companyInfo.setUpdateTime(new Date());
+            
+            int affectCount = companyInfoService.update(companyInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(companyInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+    public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            CompanyInfo companyInfo = companyInfoService.get(id);
+            companyInfo.setDelFlag(true);
+            companyInfo.setUpdateBy(subject);
+            companyInfo.setUpdateTime(new Date());
+
+            int affectCount = companyInfoService.update(companyInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="批量删除")
+    @PostMapping("batchDelete")
+    public MessageResult<Integer> batchDelete(@RequestBody List<String> idList,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            for (String id : idList) {
+                CompanyInfo companyInfo = companyInfoService.get(id);
+                companyInfo.setDelFlag(true);
+                companyInfo.setUpdateBy(subject);
+                companyInfo.setUpdateTime(new Date());
+
+                affectCount += companyInfoService.update(companyInfo);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    public MessageResult<Map> pageList(
+            String id,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("id_","asc"));
+
+        if (StringUtils.isNotEmpty(id)) {
+            searchParams.put("id","%" + id + "%");
+        }
+
+        Page<CompanyInfo> page = companyInfoService.pageSearch(searchParams,pageIndex,pageSize,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="所有单位列表")
+    @RequestMapping(value = "list",method = RequestMethod.POST)
+    public MessageResult<List<CompanyInfo>> list(){
+        MessageResult<List<CompanyInfo>> msgResult = new MessageResult<>();
+
+        List<CompanyInfo> list = companyInfoService.list();
+
+        msgResult.setResult(true);
+        msgResult.setData(list);
+
+        return msgResult;
+    }
+}

+ 364 - 0
src/main/java/com/jpsoft/smart/modules/base/controller/EmployeeInfoController.java

@@ -0,0 +1,364 @@
+package com.jpsoft.smart.modules.base.controller;
+
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.config.OSSConfig;
+import com.jpsoft.smart.modules.base.dto.EmployeeInfoDTO;
+import com.jpsoft.smart.modules.common.utils.OSSUtil;
+import com.jpsoft.smart.modules.common.utils.PojoUtils;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.base.entity.EmployeeInfo;
+import com.jpsoft.smart.modules.base.service.EmployeeInfoService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Controller
+@RequestMapping("/base/employeeInfo")
+@Api(description = "employeeInfo")
+public class EmployeeInfoController {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    @Autowired
+    private OSSConfig ossConfig;
+
+    @Autowired
+    private EmployeeInfoService employeeInfoService;
+
+    @ApiOperation(value="创建空记录")
+    @GetMapping("create")
+    @ResponseBody
+    public MessageResult<EmployeeInfo> create(){
+        MessageResult<EmployeeInfo> msgResult = new MessageResult<>();
+
+        EmployeeInfo employeeInfo = new EmployeeInfo();
+
+        msgResult.setData(employeeInfo);
+        msgResult.setResult(true);
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="编辑信息")
+    @GetMapping("edit/{id}")
+    @ResponseBody
+    public MessageResult<EmployeeInfo> edit(@PathVariable("id") Long id){
+        MessageResult<EmployeeInfo> msgResult = new MessageResult<>();
+
+        try {
+            EmployeeInfo employeeInfo = employeeInfoService.get(id);
+
+            if (employeeInfo != null) {
+                msgResult.setResult(true);
+                msgResult.setData(employeeInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="更新用户")
+    @PostMapping("update")
+    @ResponseBody
+    public MessageResult<EmployeeInfo> update(@RequestBody EmployeeInfo employeeInfo,@RequestAttribute String subject){
+        MessageResult<EmployeeInfo> msgResult = new MessageResult<>();
+
+        try {
+            employeeInfo.setUpdateBy(subject);
+            employeeInfo.setUpdateTime(new Date());
+            
+            int affectCount = employeeInfoService.update(employeeInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(employeeInfo);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库更新失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+	@ApiOperation(value="删除")
+    @PostMapping("delete/{id}")
+    @ResponseBody
+    public MessageResult<Integer> delete(@PathVariable("id") Long id,@RequestAttribute String subject){
+        MessageResult<Integer> msgResult = new MessageResult<>();
+
+        try {
+            EmployeeInfo employeeInfo = employeeInfoService.get(id);
+            employeeInfo.setDelFlag(true);
+            employeeInfo.setUpdateBy(subject);
+            employeeInfo.setUpdateTime(new Date());
+
+            int affectCount = employeeInfoService.update(employeeInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData(affectCount);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("删除失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value="分页列表")
+    @RequestMapping(value = "pageList",method = RequestMethod.POST)
+    @ResponseBody
+    public MessageResult<Map> pageList(
+            String employeeName,
+            String companyId,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("c.sort_no","asc"));
+        sortList.add(new Sort("e.id_","asc"));
+
+        if (StringUtils.isNotEmpty(employeeName)) {
+            searchParams.put("employeeName","%" + employeeName + "%");
+        }
+
+        if (StringUtils.isNotEmpty(companyId)) {
+            searchParams.put("companyId",companyId);
+        }
+
+        Page<EmployeeInfo> page = employeeInfoService.pageSearch(searchParams,pageIndex,pageSize,sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="根据openId获取员工信息")
+    @GetMapping("mobile/findByOpenId")
+    @ResponseBody
+    public MessageResult<EmployeeInfoDTO> findByOpenId(String openId){
+        MessageResult<EmployeeInfoDTO> msgResult = new MessageResult<>();
+
+        try {
+            EmployeeInfo employeeInfo = employeeInfoService.findByOpenId(openId);
+
+            if (employeeInfo != null) {
+                msgResult.setResult(true);
+
+                EmployeeInfoDTO dto = new EmployeeInfoDTO();
+                PojoUtils.map(employeeInfo,dto);
+
+                msgResult.setData(dto);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("数据库不存在该记录!");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="保存信息")
+    @PostMapping("mobile/save")
+    @ResponseBody
+    public MessageResult<String> save(EmployeeInfoDTO employeeInfoDTO){
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        try {
+            int affectCount = 0;
+
+            EmployeeInfo employeeInfo = employeeInfoService.findByOpenId(employeeInfoDTO.getOpenId());
+
+            if(employeeInfo==null) {
+                employeeInfo = new EmployeeInfo();
+
+                PojoUtils.map(employeeInfoDTO,employeeInfo);
+
+                employeeInfo.setCreateTime(new Date());
+                affectCount = employeeInfoService.insert(employeeInfo);
+            }
+            else{
+                PojoUtils.map(employeeInfoDTO,employeeInfo);
+                employeeInfo.setUpdateTime(new Date());
+
+                affectCount = employeeInfoService.update(employeeInfo);
+            }
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("保存失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+
+    @PostMapping("mobile/upload")
+    @ResponseBody
+    @ApiOperation(value="员工照片上传")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "photoFile",value = "员工照片", required = true,paramType="form", dataType = "__file")
+    })
+    public MessageResult<String> upload(MultipartFile photoFile){
+        MessageResult<String> messageResult = new MessageResult<>();
+
+        try {
+            String fileName = photoFile.getOriginalFilename();
+            String retFileUrl = OSSUtil.upload(ossConfig,"/employee",fileName,photoFile.getInputStream());
+
+            messageResult.setResult(true);
+            messageResult.setData(retFileUrl);
+            messageResult.setCode(200);
+        } catch (Exception e) {
+            logger.error(e.getMessage(),e);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(e.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @ApiOperation(value="打包下载员工资料")
+    @RequestMapping(value = "downloadZip",method = RequestMethod.GET)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name="ids",value = "选中用户编号",required = true,paramType = "query"),
+            @ApiImplicitParam(name="localPath",value = "压缩包解压后文件夹所在路径",required = true,paramType = "query"),
+    })
+    public void downloadZip(String ids,String localPath, HttpServletRequest request, HttpServletResponse response){
+        try {
+            String path = request.getContextPath();
+            String basePath = request.getScheme() + "://" + request.getServerName()+":"+request.getServerPort()+path+"/";
+
+            response.setCharacterEncoding("utf-8");
+            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
+
+            //设置编码  为了解决中文名称乱码问题
+            String fileName = "员工资料";
+            String zipFileName = new String(fileName.getBytes("UTF-8"), "iso-8859-1");
+            response.setHeader("Content-Disposition", "attachment;fileName=" + zipFileName + ".zip");
+
+            //打包文件
+            List<Map<String,Object>> fileList = new ArrayList<>();
+
+            //读取模板
+            InputStream inputStream = this.getClass().getResourceAsStream("/static/模板.csv");
+            byte[] bytes = new byte[inputStream.available()];
+            inputStream.read(bytes);
+
+            StringBuilder csvBuilder = new StringBuilder();
+            csvBuilder.append(new String(bytes,"UTF-8"));
+
+            List<EmployeeInfo> employeeInfos = employeeInfoService.findByArray(ids.split(","));
+
+            if(employeeInfos.size()>0) {
+                for (EmployeeInfo employeeInfo : employeeInfos) {
+                    csvBuilder.append(employeeInfo.getId() + ",");
+                    csvBuilder.append(employeeInfo.getName() + ",");
+
+                    String photoExt = employeeInfo.getPhoto().substring(employeeInfo.getPhoto().lastIndexOf("."));
+
+                    csvBuilder.append(localPath + "\\照片\\" + employeeInfo.getId() + photoExt + "\r\n");
+                }
+
+                Map<String, Object> fileMap = new HashMap<>();
+                fileMap.put("fileData", csvBuilder.toString().getBytes("UTF-8"));
+                fileMap.put("fileName", "人员名单.csv");
+
+//                fileList.add(fileMap);
+            }
+
+            //身份证
+            for (EmployeeInfo employeeInfo : employeeInfos) {
+                if (StringUtils.isNotEmpty(employeeInfo.getPhoto())){
+                    String url = employeeInfo.getPhoto();
+
+                    String ext = url.substring(url.lastIndexOf("."));
+
+                    Map<String,Object> fileMap = new HashMap<>();
+                    fileMap.put("fileUrl",url + "?x-oss-process=image/resize,l_800,limit_1");
+                    fileMap.put("filePath", "照片/");
+                    fileMap.put("fileName", employeeInfo.getId() + ext);
+
+                    fileList.add(fileMap);
+                }
+            }
+
+            OutputStream output = response.getOutputStream();
+
+            OSSUtil.batchDownload(fileList,output);
+
+            output.flush();
+            output.close();
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+        }
+    }
+}

+ 70 - 0
src/main/java/com/jpsoft/smart/modules/base/service/impl/CompanyInfoServiceImpl.java

@@ -0,0 +1,70 @@
+package com.jpsoft.smart.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.smart.modules.base.dao.CompanyInfoDAO;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="companyInfoService")
+public class CompanyInfoServiceImpl implements CompanyInfoService {
+	@Resource(name="companyInfoDAO")
+	private CompanyInfoDAO companyInfoDAO;
+
+	@Override
+	public CompanyInfo get(String id) {
+		// TODO Auto-generated method stub
+		return companyInfoDAO.get(id);
+	}
+
+	@Override
+	public int insert(CompanyInfo model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return companyInfoDAO.insert(model);
+	}
+
+	@Override
+	public int update(CompanyInfo model) {
+		// TODO Auto-generated method stub
+		return companyInfoDAO.update(model);		
+	}
+
+	@Override
+	public int delete(String id) {
+		// TODO Auto-generated method stub
+		return companyInfoDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(String id) {
+		// TODO Auto-generated method stub
+		int count = companyInfoDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<CompanyInfo> list() {
+		// TODO Auto-generated method stub
+		return companyInfoDAO.list();
+	}
+		
+	@Override
+	public Page<CompanyInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
+        Page<CompanyInfo> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
+            companyInfoDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+}

+ 80 - 0
src/main/java/com/jpsoft/smart/modules/base/service/impl/EmployeeInfoServiceImpl.java

@@ -0,0 +1,80 @@
+package com.jpsoft.smart.modules.base.service.impl;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import javax.annotation.Resource;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+import com.jpsoft.smart.modules.base.dao.EmployeeInfoDAO;
+import com.jpsoft.smart.modules.base.entity.EmployeeInfo;
+import com.jpsoft.smart.modules.base.service.EmployeeInfoService;
+import com.github.pagehelper.Page;
+import com.jpsoft.smart.modules.common.dto.Sort;
+import com.github.pagehelper.PageHelper;
+
+@Transactional
+@Component(value="employeeInfoService")
+public class EmployeeInfoServiceImpl implements EmployeeInfoService {
+	@Resource(name="employeeInfoDAO")
+	private EmployeeInfoDAO employeeInfoDAO;
+
+	@Override
+	public EmployeeInfo get(Long id) {
+		// TODO Auto-generated method stub
+		return employeeInfoDAO.get(id);
+	}
+
+	@Override
+	public int insert(EmployeeInfo model) {
+		// TODO Auto-generated method stub
+		//model.setId(UUID.randomUUID().toString());
+		
+		return employeeInfoDAO.insert(model);
+	}
+
+	@Override
+	public int update(EmployeeInfo model) {
+		// TODO Auto-generated method stub
+		return employeeInfoDAO.update(model);		
+	}
+
+	@Override
+	public int delete(Long id) {
+		// TODO Auto-generated method stub
+		return employeeInfoDAO.delete(id);
+	}
+
+	@Override
+	public boolean exist(Long id) {
+		// TODO Auto-generated method stub
+		int count = employeeInfoDAO.exist(id);
+		
+		return count > 0 ? true : false;
+	}
+	
+	@Override
+	public List<EmployeeInfo> list() {
+		// TODO Auto-generated method stub
+		return employeeInfoDAO.list();
+	}
+		
+	@Override
+	public Page<EmployeeInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
+        Page<EmployeeInfo> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
+            employeeInfoDAO.search(searchParams,sortList);
+        });
+        
+        return page;
+	}
+
+	@Override
+	public List<EmployeeInfo> findByArray(String[] arr) {
+		return employeeInfoDAO.findByArray(arr);
+	}
+
+	@Override
+	public EmployeeInfo findByOpenId(String openId) {
+		return employeeInfoDAO.findByOpenId(openId);
+	}
+}

+ 259 - 0
src/main/java/com/jpsoft/smart/modules/common/utils/OSSUtil.java

@@ -0,0 +1,259 @@
+package com.jpsoft.smart.modules.common.utils;
+
+import cn.hutool.core.date.DateTime;
+import com.aliyun.oss.HttpMethod;
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.model.GeneratePresignedUrlRequest;
+import com.aliyun.oss.model.OSSObject;
+import com.aliyun.oss.model.PutObjectResult;
+import com.jpsoft.smart.config.OSSConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+@Slf4j
+public class OSSUtil {
+    public static String upload(OSSConfig ossConfig,
+                                   String subFolder, String fileName,
+                                   InputStream fileInputStream) {
+        Date now = new Date();
+
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(now);
+
+        String savePath = ossConfig.getObjectPre();
+
+        if (!subFolder.startsWith("/")) {
+            savePath += "/";
+        }
+
+        savePath += subFolder;
+
+        savePath = savePath + "/" + cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/";
+
+        OSS ossClient = new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
+
+        int index = fileName.indexOf(".");
+
+//        String prefix = fileName.substring(0,index);
+
+        String ext = fileName.substring(index);
+
+        String newFileName = DateTime.now().toString("ddHHmmssSSS") + ext;
+
+        String retFileUrl = savePath + newFileName;
+
+        // 上传文件流
+        PutObjectResult result = ossClient.putObject(ossConfig.getBucketName(), retFileUrl, fileInputStream);
+
+        // 关闭OSSClient
+        ossClient.shutdown();
+
+        return ossConfig.getUrlPrefix() + "/" + retFileUrl;
+    }
+
+    public static boolean download(String fileUrl,String filePath){
+        boolean result;
+
+        try {
+            FileOutputStream output = new FileOutputStream(filePath);
+
+            URL url = new URL(encodeFileName(fileUrl));
+            URLConnection conn = url.openConnection();
+            InputStream input = conn.getInputStream();
+
+            byte[] buffs = new byte[1024 * 10];
+
+            BufferedInputStream bis = new BufferedInputStream(input, 1024 * 10);
+
+            int read;
+            while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
+                output.write(buffs, 0, read);
+            }
+
+            input.close();
+            output.close();
+
+            result = true;
+        } catch (Exception e) {
+            result = false;
+            log.error(e.getMessage(),e);
+        }
+
+        return result;
+    }
+
+    public static void batchDownload(List<Map<String,Object>> fileList, OutputStream output){
+        try{
+            ZipOutputStream zos = new ZipOutputStream(output);
+
+            for (Map<String,Object> map : fileList) {
+                String fileUrl = (String)map.get("fileUrl");
+                String filePath = (String)map.get("filePath");
+                String fileName = (String)map.get("fileName");
+
+                try {
+                    if (StringUtils.isEmpty(fileName)) {
+                        fileName = fileUrl;
+                    }
+
+                    if (fileName.indexOf("?") != -1) {
+                        fileName = fileName.substring(0, fileName.indexOf("?"));
+                    }
+
+                    fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
+
+                    String zipFile = fileName;
+
+                    if(StringUtils.isNotEmpty(filePath)){
+                        zipFile = filePath + fileName;
+                    }
+
+                    ZipEntry zipEntry = new ZipEntry(zipFile);
+                    zos.putNextEntry(zipEntry);
+
+                    if(StringUtils.isNotEmpty(fileUrl)) {
+                        URL url = new URL(encodeFileName(fileUrl));
+
+                        URLConnection conn = url.openConnection();
+                        InputStream inputStream = conn.getInputStream();
+
+                        byte[] buffs = new byte[1024 * 10];
+
+                        BufferedInputStream bis = new BufferedInputStream(inputStream, 1024 * 10);
+
+                        int read;
+                        while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
+                            zos.write(buffs, 0, read);
+                        }
+
+                        bis.close();
+                    }
+                    else if(map.containsKey("fileData")){
+                        byte[] fileData = (byte[])map.get("fileData");
+                        zos.write(fileData,0,fileData.length);
+                    }
+                }
+                catch(Exception ex){
+                    log.error(ex.getMessage(),ex);
+                }
+            }
+
+            zos.close();
+        }
+        catch(Exception ex){
+            log.error(ex.getMessage(),ex);
+        }
+    }
+
+    private static String encodeFileName(String fileUrl) throws Exception{
+        String[] segements = fileUrl.split("\\?");
+
+        String[] arr = segements[0].split("/");
+
+        //文件名可能是中文,用utf-8编码
+        arr[arr.length - 1] = URLEncoder.encode(arr[arr.length - 1],"UTF-8");
+
+        String encFileUrl = Arrays.stream(arr).collect(Collectors.joining("/"));
+
+        if (segements.length>1){
+            encFileUrl += "?" + segements[1];
+        }
+
+        return encFileUrl;
+    }
+
+    public static void presignedDownload(OSSConfig ossConfig, List<Map> fileList, OutputStream output){
+        BufferedInputStream bis = null;
+
+        try{
+            ZipOutputStream zos = new ZipOutputStream(output);
+
+            OSS ossClient = new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKeyId(), ossConfig.getAccessKeySecret());
+
+            for (Map<String,String> map : fileList) {
+                try {
+                    String fileUrl = map.get("fileUrl");
+                    String filePath = map.get("filePath");
+
+                    Date expiration = new Date(System.currentTimeMillis() + 3600 * 1000);
+
+                    if (fileUrl.startsWith(ossConfig.getUrlPrefix())) {
+                        fileUrl = fileUrl.substring(ossConfig.getUrlPrefix().length());
+                    }
+
+                    if (fileUrl.indexOf("?") != -1) {
+                        fileUrl = fileUrl.substring(0, fileUrl.indexOf("?"));
+                    }
+
+                    if (fileUrl.startsWith("/")) {
+                        fileUrl = fileUrl.substring(1);
+                    }
+
+                    GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(ossConfig.getBucketName(), fileUrl, HttpMethod.GET);
+
+                    // 设置过期时间。
+                    request.setExpiration(expiration);
+
+                    //设置缩放
+                    request.setProcess("image/resize,l_1024,limit_1");
+
+                    // 生成签名URL(HTTP GET请求)。
+                    URL signedUrl = ossClient.generatePresignedUrl(request);
+
+                    // 使用签名URL发送请求。
+                    OSSObject ossObject = ossClient.getObject(signedUrl, new HashMap<>());
+
+                    if (ossObject != null) {
+                        InputStream inputStream = ossObject.getObjectContent();
+                        byte[] buffs = new byte[1024 * 10];
+                        String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
+                        String zipFile = fileName;
+
+                        if (StringUtils.isNotEmpty(filePath)){
+                            zipFile = filePath + fileName;
+                        }
+
+                        ZipEntry zipEntry = new ZipEntry(zipFile);
+                        zos.putNextEntry(zipEntry);
+                        bis = new BufferedInputStream(inputStream, 1024 * 10);
+
+                        int read;
+                        while ((read = bis.read(buffs, 0, 1024 * 10)) != -1) {
+                            zos.write(buffs, 0, read);
+                        }
+
+                        ossObject.close();
+                    }
+                }
+                catch(Exception ex){
+                    log.error(ex.getMessage(),ex);
+                }
+            }
+
+            zos.close();
+            ossClient.shutdown();
+        }
+        catch(Exception ex){
+            log.error(ex.getMessage(),ex);
+        }
+        finally {
+            if(bis!=null){
+                try {
+                    bis.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+}