update
This commit is contained in:
parent
c2a66689bc
commit
5e31ca3ebf
|
@ -2,10 +2,15 @@ package com.ydool.common.utils;
|
|||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
|
||||
public class UploadUtils {
|
||||
|
@ -31,4 +36,33 @@ public class UploadUtils {
|
|||
return System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
public static void download(HttpServletResponse response, String fullFilePath, String fileName) {
|
||||
response.reset();
|
||||
response.setContentType("application/octet-stream; charset=utf-8");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.addHeader("Content-Disposition", "attachment; filename*=utf-8'zh_cn'" + encodeUrl(StrUtil.isNotBlank(fileName) ? fileName : FileUtil.getName(fullFilePath)));
|
||||
try {
|
||||
IoUtil.copy(FileUtil.getInputStream(fullFilePath), response.getOutputStream());
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String encodeUrl(String part) {
|
||||
return encodeUrl(part, "UTF-8");
|
||||
}
|
||||
|
||||
public static String encodeUrl(String part, String encoding) {
|
||||
if (part == null) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
return URLEncoder.encode(part, encoding);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,12 @@ public class OrganizationController extends BaseController {
|
|||
@Autowired
|
||||
IOrganizationService organizationService;
|
||||
|
||||
@GetMapping("/selectOrganization")
|
||||
@ApiOperation(value = "企业名称列表")
|
||||
public AjaxResult selectOrganization() {
|
||||
return organizationService.selectOrganization();
|
||||
}
|
||||
|
||||
@GetMapping("/selectOrganizationByName")
|
||||
@ApiOperation(value = "企业名称查企业信息")
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "companyName", value = "企业名称", required = true)})
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package com.ydool.staff.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import com.ydool.common.base.BaseController;
|
||||
import com.ydool.common.constant.UrlConstant;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.common.utils.UploadUtils;
|
||||
import com.ydool.staff.dto.PersonnelDto;
|
||||
import com.ydool.staff.entity.Attachment;
|
||||
import com.ydool.staff.request.PersonnelDeleteRequest;
|
||||
import com.ydool.staff.request.PersonnelRequest;
|
||||
import com.ydool.staff.request.PersonnelUpdateRequest;
|
||||
import com.ydool.staff.service.IAttachmentService;
|
||||
import com.ydool.staff.service.IPersonnelService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
@ -15,11 +19,7 @@ import io.swagger.annotations.ApiImplicitParams;
|
|||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
@ -36,6 +36,8 @@ import java.util.List;
|
|||
public class PersonnelController extends BaseController {
|
||||
@Resource
|
||||
private IPersonnelService personnelService;
|
||||
@Autowired
|
||||
IAttachmentService attachmentService;
|
||||
|
||||
@GetMapping( "personnelList")
|
||||
@ApiOperation(value = "人员列表,传id查一条",response = PersonnelDto.class)
|
||||
|
@ -63,4 +65,18 @@ public class PersonnelController extends BaseController {
|
|||
return personnelService.updatePersonnel(personnelDeleteRequest);
|
||||
}
|
||||
|
||||
@GetMapping("/download")
|
||||
@ApiOperation(value = "下载文件")
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "path", value = "文件路径"), @ApiImplicitParam(name = "fileName", value = "文件名")})
|
||||
public void download(String path, String fileName) {
|
||||
String fullFilePath = UploadUtils.getWebRoot() + path;
|
||||
UploadUtils.download(response, fullFilePath, fileName);
|
||||
}
|
||||
|
||||
@GetMapping("/fileList")
|
||||
@ApiOperation(value = "文件列表")
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "current", value = "当前页"), @ApiImplicitParam(name = "size", value = "每页条数"), @ApiImplicitParam(name = "id", value = "人员id", required = true)})
|
||||
public AjaxResult fileList(String id) {
|
||||
return attachmentService.fileList(new Page<Attachment>(getPageNum(), getPageSize()), id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class Personnel extends BaseEntity {
|
|||
private String education;
|
||||
|
||||
@ApiModelProperty(value = "是否应届毕业生")
|
||||
private boolean freshGraduate;
|
||||
private Boolean freshGraduate;
|
||||
|
||||
@ApiModelProperty(value = "毕业院校")
|
||||
private String academy;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.ydool.staff.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.staff.entity.Attachment;
|
||||
import com.ydool.staff.request.AttachmentRequest;
|
||||
|
||||
|
@ -18,5 +20,7 @@ public interface IAttachmentService {
|
|||
boolean deleteById(String targetType,String id);
|
||||
|
||||
Attachment selectFile(String path, String id);
|
||||
|
||||
AjaxResult fileList(Page<Attachment> page, String id);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,5 +22,7 @@ public interface IOrganizationService {
|
|||
AjaxResult deleteOrganization(IdsRequest id);
|
||||
|
||||
AjaxResult selectOrganizationByName(String companyName);
|
||||
|
||||
AjaxResult selectOrganization();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package com.ydool.staff.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ydool.common.base.BaseService;
|
||||
import com.ydool.common.data.dto.AjaxResult;
|
||||
import com.ydool.staff.entity.Attachment;
|
||||
import com.ydool.staff.mapper.AttachmentMapper;
|
||||
import com.ydool.staff.request.AttachmentRequest;
|
||||
import com.ydool.staff.service.IAttachmentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 附件表 服务类
|
||||
|
@ -20,6 +25,9 @@ import org.springframework.stereotype.Service;
|
|||
public class AttachmentServiceImpl extends BaseService<AttachmentMapper, Attachment> implements IAttachmentService {
|
||||
|
||||
|
||||
@Autowired
|
||||
AttachmentMapper attachmentMapper;
|
||||
|
||||
@Override
|
||||
public boolean savePersonnel(Attachment entity) {
|
||||
return save(entity);
|
||||
|
@ -33,8 +41,11 @@ public class AttachmentServiceImpl extends BaseService<AttachmentMapper, Attachm
|
|||
@Override
|
||||
public Attachment selectFile(String path, String id) {
|
||||
return getOne(new LambdaQueryWrapper<Attachment>().eq(Attachment::getPath, path).eq(Attachment::getTargetId, id));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AjaxResult fileList(Page<Attachment> page, String id) {
|
||||
return AjaxResult.ok().data(attachmentMapper.selectPage(page, new LambdaQueryWrapper<Attachment>().eq(Attachment::getTargetId, id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
|
|||
LambdaQueryWrapper<Organization> organizationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
organizationLambdaQueryWrapper.eq(StrUtil.isNotBlank(companyName), Organization::getCompanyName, companyName);
|
||||
Page<Organization> selectPage = organizationMapper.selectPage(page, organizationLambdaQueryWrapper);
|
||||
for (Organization record : selectPage.getRecords()) {
|
||||
record.setUpdatedId(userMapper.selectById(record.getUpdatedId()).getUserName());
|
||||
}
|
||||
// for (Organization record : selectPage.getRecords()) {
|
||||
// record.setUpdatedId(userMapper.selectById(record.getUpdatedId()).getUserName());
|
||||
// }
|
||||
return AjaxResult.ok().data(selectPage);
|
||||
}
|
||||
|
||||
|
@ -80,5 +80,10 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
|
|||
public AjaxResult selectOrganizationByName(String companyName) {
|
||||
return AjaxResult.ok().data(organizationMapper.selectOne(new LambdaQueryWrapper<Organization>().eq(Organization::getCompanyName, companyName)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult selectOrganization() {
|
||||
return AjaxResult.ok().data(organizationMapper.selectList(null));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue