Commit 48e6a0df authored by chenhao's avatar chenhao

修改bug (页面展示文件名称出错的问题)

parent a249edcc
package com.yeejoin.amos.boot.module.common.api.dto;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 消防员合同
*
......@@ -52,5 +55,8 @@ public class FirefightersContractDto extends BaseDto {
@ApiModelProperty(value = "操作人名称")
private String recUserName;
@ApiModelProperty(value = "附件")
private Map<String, List<AttachmentDto>> attachments;
}
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -12,6 +14,8 @@ import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 消防员合同
*
......@@ -66,4 +70,9 @@ public class FirefightersContract extends BaseEntity {
@ApiModelProperty(value = "更新时间")
@TableField(fill=FieldFill.UPDATE)
private Date updateTime;
@TableField(exist = false)
@ApiModelProperty(value = "附件")
private Map<String, List<AttachmentDto>> attachments;
}
package com.yeejoin.amos.boot.module.common.api.service;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersContractDto;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
/**
* 消防员合同 服务类
*
......@@ -7,5 +10,14 @@ package com.yeejoin.amos.boot.module.common.api.service;
* @date 2021-06-07
*/
public interface IFirefightersContractService {
/**
* 保存
* @param firefightersContract
* @return
*/
public FirefightersContractDto save(FirefightersContractDto firefightersContract);
public FirefightersContractDto updateById(FirefightersContractDto firefightersContract, AgencyUserModel userInfo);
}
package com.yeejoin.amos.boot.module.common.api.service;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.dto.CheckObjectDto;
import com.yeejoin.amos.boot.module.common.api.dto.CompanyDto;
import com.yeejoin.amos.boot.module.common.api.dto.ESOrgUsrDto;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgDepartmentFormDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgPersonFormDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrExcelDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrFormDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgUsrzhDto;
import com.yeejoin.amos.boot.module.common.api.dto.RequestData;
import com.yeejoin.amos.boot.module.common.api.dto.UserUnitDto;
import com.yeejoin.amos.boot.module.common.api.entity.DynamicFormInstance;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
* 机构/部门/人员表 服务类
......
......@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -28,8 +29,11 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersContractDto;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersContract;
import com.yeejoin.amos.boot.module.common.api.service.IFirefightersContractService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersContractServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.SourceFileServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -48,6 +52,12 @@ public class FirefightersContractController extends BaseController {
@Autowired
FirefightersContractServiceImpl iFirefightersContractService;
@Autowired
IFirefightersContractService firefightersContractService;
@Autowired
SourceFileServiceImpl sourceFileService;
@Autowired
RedisUtils redisUtils;
@Value("${redis.cache.failure.time}")
......@@ -59,9 +69,8 @@ public class FirefightersContractController extends BaseController {
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增消防员合同", notes = "新增消防员合同")
public ResponseModel<FirefightersContract> saveFirefightersContract(HttpServletRequest request, @RequestBody FirefightersContract firefightersContract){
iFirefightersContractService.save(firefightersContract);
return ResponseHelper.buildResponse(firefightersContract);
public ResponseModel<FirefightersContractDto> saveFirefightersContract(HttpServletRequest request, @RequestBody FirefightersContractDto firefightersContract){
return ResponseHelper.buildResponse(firefightersContractService.save(firefightersContract));
}
/**
......@@ -93,8 +102,8 @@ public class FirefightersContractController extends BaseController {
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/updateById", method = RequestMethod.PUT)
@ApiOperation(httpMethod = "PUT", value = "修改消防员合同", notes = "修改消防员合同")
public ResponseModel<FirefightersContract> updateByIdFirefightersContract(HttpServletRequest request, @RequestBody FirefightersContract firefightersContract){
iFirefightersContractService.updateById(firefightersContract);
public ResponseModel<FirefightersContractDto> updateByIdFirefightersContract(HttpServletRequest request, @RequestBody FirefightersContractDto firefightersContract){
firefightersContractService.updateById(firefightersContract, getUserInfo());
//删除缓存
redisUtils.del(RedisKey.CONTRACT_ID+firefightersContract.getSequenceNbr());
return ResponseHelper.buildResponse(firefightersContract);
......@@ -116,9 +125,12 @@ public class FirefightersContractController extends BaseController {
return ResponseHelper.buildResponse(obj);
}else{
FirefightersContract firefightersContract= iFirefightersContractService.getById(id);
redisUtils.set(RedisKey.CONTRACT_ID+id, JSON.toJSON(firefightersContract),time);
return ResponseHelper.buildResponse(firefightersContract);
}
FirefightersContractDto dto = new FirefightersContractDto();
Bean.copyExistPropertis(firefightersContract, dto);
dto.setAttachments(sourceFileService.getAttachments(id));
redisUtils.set(RedisKey.CONTRACT_ID+id, JSON.toJSON(dto),time);
return ResponseHelper.buildResponse(dto);
}
}
......@@ -173,6 +185,9 @@ public class FirefightersContractController extends BaseController {
pageBean = new Page<FirefightersContract>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
}
page = iFirefightersContractService.page(pageBean, firefightersContractQueryWrapper);
page.getRecords().forEach(i->{
i.setAttachments(sourceFileService.getAttachments(i.getSequenceNbr()));
});
return ResponseHelper.buildResponse(page);
}
}
......
package com.yeejoin.amos.boot.module.common.biz.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.module.common.api.dto.AttachmentDto;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersContractDto;
import com.yeejoin.amos.boot.module.common.api.entity.FirefightersContract;
import com.yeejoin.amos.boot.module.common.api.entity.SourceFile;
import com.yeejoin.amos.boot.module.common.api.mapper.FirefightersContractMapper;
import com.yeejoin.amos.boot.module.common.api.service.IFirefightersContractService;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
/**
* 消防员合同 服务实现类
......@@ -17,4 +31,68 @@ import com.yeejoin.amos.boot.module.common.api.service.IFirefightersContractServ
@Service
public class FirefightersContractServiceImpl extends BaseService<FirefightersContractDto,FirefightersContract,FirefightersContractMapper> implements IFirefightersContractService {
@Autowired
SourceFileServiceImpl sourceFileService;
@Autowired
private Sequence sequence;
@Override
@Transactional(rollbackFor = Exception.class)
public FirefightersContractDto save(FirefightersContractDto firefightersContract) {
long sequenceId = sequence.nextId();
FirefightersContract detail=new FirefightersContract();
Bean.copyExistPropertis(firefightersContract, detail);
firefightersContract.setSequenceNbr(sequenceId);
detail.setSequenceNbr(sequenceId);
this.save(detail);
saveAttachments(firefightersContract);
return firefightersContract;
}
public void saveAttachments(FirefightersContractDto firefightersContract) {
if (!ValidationUtil.isEmpty(firefightersContract.getAttachments())) {
List<SourceFile> sourceFiles = Lists.newArrayList();
Map<String, List<AttachmentDto>> attachmentMap = firefightersContract.getAttachments();
attachmentMap.entrySet().forEach(entry -> {
List<AttachmentDto> atts = entry.getValue();
sourceFiles.addAll(attachment2SourceFile(entry.getKey(), atts));
});
sourceFileService.saveSourceFile(firefightersContract.getSequenceNbr(), sourceFiles);
}
}
private List<SourceFile> attachment2SourceFile(String type, List<AttachmentDto> attachmentDtoList) {
List<SourceFile> sourceFiles = Lists.newArrayList();
if (!ValidationUtil.isEmpty(attachmentDtoList)) {
attachmentDtoList.forEach(a -> {
SourceFile s = new SourceFile();
s.setFilePath(a.getUrl());
s.setFileName(a.getName());
s.setFileCategory(type);
sourceFiles.add(s);
});
}
return sourceFiles;
}
@Override
@Transactional(rollbackFor = Exception.class)
public FirefightersContractDto updateById(FirefightersContractDto firefightersContract, AgencyUserModel userInfo) {
FirefightersContract detail=new FirefightersContract();
Bean.copyExistPropertis(firefightersContract, detail);
detail.setIsDelete(false);
detail.setRecDate(new Date());
detail.setRecUserId(userInfo.getUserId());
detail.setRecUserName(userInfo.getUserName());
this.baseMapper.updateById(detail);
Map<String, List<AttachmentDto>> map = firefightersContract.getAttachments();
if (ObjectUtils.isNotEmpty(map)) {
this.saveAttachments(firefightersContract);
}
return firefightersContract;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment