This commit is contained in:
zhuyy 2023-02-06 09:50:45 +08:00
parent c2a66689bc
commit 5e31ca3ebf
8 changed files with 89 additions and 11 deletions

View File

@ -2,10 +2,15 @@ package com.ydool.common.utils;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date; import java.util.Date;
public class UploadUtils { public class UploadUtils {
@ -31,4 +36,33 @@ public class UploadUtils {
return System.getProperty("user.dir"); 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;
}
}
} }

View File

@ -21,6 +21,12 @@ public class OrganizationController extends BaseController {
@Autowired @Autowired
IOrganizationService organizationService; IOrganizationService organizationService;
@GetMapping("/selectOrganization")
@ApiOperation(value = "企业名称列表")
public AjaxResult selectOrganization() {
return organizationService.selectOrganization();
}
@GetMapping("/selectOrganizationByName") @GetMapping("/selectOrganizationByName")
@ApiOperation(value = "企业名称查企业信息") @ApiOperation(value = "企业名称查企业信息")
@ApiImplicitParams({@ApiImplicitParam(name = "companyName", value = "企业名称", required = true)}) @ApiImplicitParams({@ApiImplicitParam(name = "companyName", value = "企业名称", required = true)})

View File

@ -1,13 +1,17 @@
package com.ydool.staff.controller; package com.ydool.staff.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ydool.common.base.BaseController; import com.ydool.common.base.BaseController;
import com.ydool.common.constant.UrlConstant; import com.ydool.common.constant.UrlConstant;
import com.ydool.common.data.dto.AjaxResult; import com.ydool.common.data.dto.AjaxResult;
import com.ydool.common.utils.UploadUtils;
import com.ydool.staff.dto.PersonnelDto; import com.ydool.staff.dto.PersonnelDto;
import com.ydool.staff.entity.Attachment;
import com.ydool.staff.request.PersonnelDeleteRequest; import com.ydool.staff.request.PersonnelDeleteRequest;
import com.ydool.staff.request.PersonnelRequest; import com.ydool.staff.request.PersonnelRequest;
import com.ydool.staff.request.PersonnelUpdateRequest; import com.ydool.staff.request.PersonnelUpdateRequest;
import com.ydool.staff.service.IAttachmentService;
import com.ydool.staff.service.IPersonnelService; import com.ydool.staff.service.IPersonnelService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -15,11 +19,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
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 javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.List;
@ -36,6 +36,8 @@ import java.util.List;
public class PersonnelController extends BaseController { public class PersonnelController extends BaseController {
@Resource @Resource
private IPersonnelService personnelService; private IPersonnelService personnelService;
@Autowired
IAttachmentService attachmentService;
@GetMapping( "personnelList") @GetMapping( "personnelList")
@ApiOperation(value = "人员列表,传id查一条",response = PersonnelDto.class) @ApiOperation(value = "人员列表,传id查一条",response = PersonnelDto.class)
@ -63,4 +65,18 @@ public class PersonnelController extends BaseController {
return personnelService.updatePersonnel(personnelDeleteRequest); 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);
}
} }

View File

@ -67,7 +67,7 @@ public class Personnel extends BaseEntity {
private String education; private String education;
@ApiModelProperty(value = "是否应届毕业生") @ApiModelProperty(value = "是否应届毕业生")
private boolean freshGraduate; private Boolean freshGraduate;
@ApiModelProperty(value = "毕业院校") @ApiModelProperty(value = "毕业院校")
private String academy; private String academy;

View File

@ -1,5 +1,7 @@
package com.ydool.staff.service; 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.entity.Attachment;
import com.ydool.staff.request.AttachmentRequest; import com.ydool.staff.request.AttachmentRequest;
@ -18,5 +20,7 @@ public interface IAttachmentService {
boolean deleteById(String targetType,String id); boolean deleteById(String targetType,String id);
Attachment selectFile(String path, String id); Attachment selectFile(String path, String id);
AjaxResult fileList(Page<Attachment> page, String id);
} }

View File

@ -22,5 +22,7 @@ public interface IOrganizationService {
AjaxResult deleteOrganization(IdsRequest id); AjaxResult deleteOrganization(IdsRequest id);
AjaxResult selectOrganizationByName(String companyName); AjaxResult selectOrganizationByName(String companyName);
AjaxResult selectOrganization();
} }

View File

@ -1,13 +1,18 @@
package com.ydool.staff.service.impl; package com.ydool.staff.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.base.BaseService;
import com.ydool.common.data.dto.AjaxResult;
import com.ydool.staff.entity.Attachment; import com.ydool.staff.entity.Attachment;
import com.ydool.staff.mapper.AttachmentMapper; import com.ydool.staff.mapper.AttachmentMapper;
import com.ydool.staff.request.AttachmentRequest; import com.ydool.staff.request.AttachmentRequest;
import com.ydool.staff.service.IAttachmentService; import com.ydool.staff.service.IAttachmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* <p> * <p>
* 附件表 服务类 * 附件表 服务类
@ -20,6 +25,9 @@ import org.springframework.stereotype.Service;
public class AttachmentServiceImpl extends BaseService<AttachmentMapper, Attachment> implements IAttachmentService { public class AttachmentServiceImpl extends BaseService<AttachmentMapper, Attachment> implements IAttachmentService {
@Autowired
AttachmentMapper attachmentMapper;
@Override @Override
public boolean savePersonnel(Attachment entity) { public boolean savePersonnel(Attachment entity) {
return save(entity); return save(entity);
@ -33,8 +41,11 @@ public class AttachmentServiceImpl extends BaseService<AttachmentMapper, Attachm
@Override @Override
public Attachment selectFile(String path, String id) { public Attachment selectFile(String path, String id) {
return getOne(new LambdaQueryWrapper<Attachment>().eq(Attachment::getPath, path).eq(Attachment::getTargetId, 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)));
} }
} }

View File

@ -45,9 +45,9 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
LambdaQueryWrapper<Organization> organizationLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Organization> organizationLambdaQueryWrapper = new LambdaQueryWrapper<>();
organizationLambdaQueryWrapper.eq(StrUtil.isNotBlank(companyName), Organization::getCompanyName, companyName); organizationLambdaQueryWrapper.eq(StrUtil.isNotBlank(companyName), Organization::getCompanyName, companyName);
Page<Organization> selectPage = organizationMapper.selectPage(page, organizationLambdaQueryWrapper); Page<Organization> selectPage = organizationMapper.selectPage(page, organizationLambdaQueryWrapper);
for (Organization record : selectPage.getRecords()) { // for (Organization record : selectPage.getRecords()) {
record.setUpdatedId(userMapper.selectById(record.getUpdatedId()).getUserName()); // record.setUpdatedId(userMapper.selectById(record.getUpdatedId()).getUserName());
} // }
return AjaxResult.ok().data(selectPage); return AjaxResult.ok().data(selectPage);
} }
@ -80,5 +80,10 @@ public class OrganizationServiceImpl extends BaseService<OrganizationMapper, Org
public AjaxResult selectOrganizationByName(String companyName) { public AjaxResult selectOrganizationByName(String companyName) {
return AjaxResult.ok().data(organizationMapper.selectOne(new LambdaQueryWrapper<Organization>().eq(Organization::getCompanyName, 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));
}
} }