借阅逻辑及sql权限,字典完善

new
parent 8834a8615d
commit 1424ecf52e

@ -0,0 +1,18 @@
--
alter table archives_record alter column identify_status set default '0';
-- id
ALTER TABLE archives_borrow_apply ADD COLUMN `record_id` bigint(20) NULL DEFAULT NULL COMMENT 'id';
INSERT INTO `lyr-one`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ( '', 'borrow_state', 0, NULL, '', '2023-10-19 14:38:49', '', '2023-10-19 14:38:49', b'0', '1970-01-01 00:00:00');
INSERT INTO `lyr-one`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '', '0', 'borrow_state', 0, 'default', '', NULL, '', '2023-10-19 14:40:16', '', '2023-10-19 14:40:16', b'0');
INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '', '1', 'borrow_state', 0, 'default', '', NULL, '', '2023-10-19 14:40:28', '', '2023-10-19 14:40:28', b'0');
INSERT INTO `lyr-one`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('', 'way_type', 0, NULL, '', '2023-10-19 14:41:44', '', '2023-10-19 14:41:44', b'0', '1970-01-01 00:00:00');
INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 0, '', '0', 'way_type', 0, 'default', '', NULL, '', '2023-10-19 14:41:59', '', '2023-10-19 14:41:59', b'0');
INSERT INTO `lyr-one`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '', '1', 'way_type', 0, 'default', '', NULL, '', '2023-10-19 14:42:05', '', '2023-10-19 14:42:05', b'0');
INSERT INTO `lyr-one`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('', 'media_type', 0, NULL, '', '2023-10-19 14:43:33', '', '2023-10-19 14:43:33', b'0', '1970-01-01 00:00:00');
INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 0, '', '0', 'media_type', 0, 'default', '', NULL, '', '2023-10-19 14:43:49', '', '2023-10-19 14:43:49', b'0');
INSERT INTO `lyr-one`.`system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (0, '', '1', 'media_type', 0, 'default', '', NULL, '', '2023-10-19 14:44:02', '', '2023-10-19 14:44:02', b'0');

@ -40,8 +40,9 @@ public class BorrowApplyController {
@PostMapping("/create")
@Operation(summary = "创建档案借阅申请")
@PreAuthorize("@ss.hasPermission('archives:borrow-apply:create')")
public CommonResult<Long> createBorrowApply(@Valid @RequestBody BorrowApplyCreateReqVO createReqVO) {
return success(borrowApplyService.createBorrowApply(createReqVO));
public CommonResult<BorrowApplyDO> createBorrowApply(@Valid @RequestBody BorrowApplyCreateReqVO createReqVO) {
return borrowApplyService.createBorrowApply(createReqVO);
}
@PutMapping("/update")

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.archives.controller.admin.borrowapply.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -61,4 +62,20 @@ public class BorrowApplyBaseVO {
@Schema(description = "描述", example = "你猜")
private String remark;
@Schema(description = "档案id", example = "档案id")
private Long recordId;
@Schema(description = "档案类型", example = "档案类型")
@TableField(exist = false)
private String fileType;
@Schema(description = "档案位置", example = "档案位置")
@TableField(exist = false)
private String site;
@Schema(description = "案卷号", example = "案卷号")
@TableField(exist = false)
private String filesNum;
}

@ -62,4 +62,21 @@ public class BorrowApplyPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "档案id", example = "档案id")
private Long recordId;
@Schema(description = "档案类型", example = "档案类型")
private String fileType;
@Schema(description = "档案位置", example = "档案位置")
private String site;
@Schema(description = "案卷号", example = "案卷号")
private String filesNum;
@Schema(description = "判断调用历史接口还是新增列表接口", example = "判断调用历史接口还是新增列表接口")
private String historyOrList;
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.archives.dal.dataobject.borrowapply;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
@ -85,4 +86,28 @@ public class BorrowApplyDO extends BaseDO {
*/
private String remark;
/**
* id
*/
private Long recordId;
/**
*
*/
@TableField(exist = false)
private String fileType;
/**
*
*/
@TableField(exist = false)
private String site;
/**
*
*/
@TableField(exist = false)
private String filesNum;
}

@ -91,6 +91,7 @@ public class RecordDO extends BaseDO {
/**
*
*/
@TableField(updateStrategy = FieldStrategy.IGNORED)
private String borrowStatus;
/**
*

@ -20,7 +20,6 @@ public interface BorrowApplyMapper extends BaseMapperX<BorrowApplyDO> {
default PageResult<BorrowApplyDO> selectPage(BorrowApplyPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BorrowApplyDO>()
.eqIfPresent(BorrowApplyDO::getBorrowCode, reqVO.getBorrowCode())
.eqIfPresent(BorrowApplyDO::getBorrowState, reqVO.getBorrowState())
.eqIfPresent(BorrowApplyDO::getReason, reqVO.getReason())
.eqIfPresent(BorrowApplyDO::getDescribes, reqVO.getDescribes())
.eqIfPresent(BorrowApplyDO::getUserId, reqVO.getUserId())
@ -34,7 +33,30 @@ public interface BorrowApplyMapper extends BaseMapperX<BorrowApplyDO> {
.eqIfPresent(BorrowApplyDO::getCompany, reqVO.getCompany())
.eqIfPresent(BorrowApplyDO::getRemark, reqVO.getRemark())
.betweenIfPresent(BorrowApplyDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BorrowApplyDO::getId));
.orderByDesc(BorrowApplyDO::getId)
.eq(BorrowApplyDO::getBorrowState,"1"));
}
default PageResult<BorrowApplyDO> selectPageHistory(BorrowApplyPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<BorrowApplyDO>()
.eqIfPresent(BorrowApplyDO::getBorrowCode, reqVO.getBorrowCode())
.eqIfPresent(BorrowApplyDO::getReason, reqVO.getReason())
.eqIfPresent(BorrowApplyDO::getDescribes, reqVO.getDescribes())
.eqIfPresent(BorrowApplyDO::getUserId, reqVO.getUserId())
.likeIfPresent(BorrowApplyDO::getUserName, reqVO.getUserName())
.eqIfPresent(BorrowApplyDO::getDeptId, reqVO.getDeptId())
.likeIfPresent(BorrowApplyDO::getDeptName, reqVO.getDeptName())
.betweenIfPresent(BorrowApplyDO::getReturnTime, reqVO.getReturnTime())
.eqIfPresent(BorrowApplyDO::getWay, reqVO.getWay())
.eqIfPresent(BorrowApplyDO::getMedia, reqVO.getMedia())
.eqIfPresent(BorrowApplyDO::getCompanyId, reqVO.getCompanyId())
.eqIfPresent(BorrowApplyDO::getCompany, reqVO.getCompany())
.eqIfPresent(BorrowApplyDO::getRemark, reqVO.getRemark())
.betweenIfPresent(BorrowApplyDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BorrowApplyDO::getId)
.isNull(BorrowApplyDO::getBorrowState));
}
default List<BorrowApplyDO> selectList(BorrowApplyExportReqVO reqVO) {

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.archives.service.borrowapply;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.archives.controller.admin.borrowapply.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.borrowapply.BorrowApplyDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@ -19,7 +21,7 @@ public interface BorrowApplyService {
* @param createReqVO
* @return
*/
Long createBorrowApply(@Valid BorrowApplyCreateReqVO createReqVO);
CommonResult<BorrowApplyDO> createBorrowApply(@Valid BorrowApplyCreateReqVO createReqVO);
/**
*

@ -1,19 +1,23 @@
package cn.iocoder.yudao.module.archives.service.borrowapply;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.string.StringUtils;
import cn.iocoder.yudao.module.archives.controller.admin.record.vo.RecordUpdateReqVO;
import cn.iocoder.yudao.module.archives.dal.dataobject.record.RecordDO;
import cn.iocoder.yudao.module.archives.service.record.RecordService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import java.util.List;
import cn.iocoder.yudao.module.archives.controller.admin.borrowapply.vo.*;
import cn.iocoder.yudao.module.archives.dal.dataobject.borrowapply.BorrowApplyDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.archives.convert.borrowapply.BorrowApplyConvert;
import cn.iocoder.yudao.module.archives.dal.mysql.borrowapply.BorrowApplyMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.archives.enums.ErrorCodeConstants.*;
@ -29,17 +33,47 @@ public class BorrowApplyServiceImpl implements BorrowApplyService {
@Resource
private BorrowApplyMapper borrowApplyMapper;
@Resource
private RecordService recordService;
@Override
public Long createBorrowApply(BorrowApplyCreateReqVO createReqVO) {
@Transactional
public CommonResult<BorrowApplyDO> createBorrowApply(BorrowApplyCreateReqVO createReqVO) {
// 插入
BorrowApplyDO borrowApply = BorrowApplyConvert.INSTANCE.convert(createReqVO);
//修改借阅状态
RecordDO record = recordService.getRecord(createReqVO.getRecordId());
if (StringUtils.isNotNull(record.getBorrowStatus())){
if (record.getBorrowStatus().equals("0")){
return CommonResult.error("档案已被借阅");
}
}
RecordUpdateReqVO recordUpdateReqVO = new RecordUpdateReqVO();
BeanUtils.copyProperties(record,recordUpdateReqVO);
recordUpdateReqVO.setBorrowStatus("1");
recordService.updateRecord(recordUpdateReqVO);
borrowApplyMapper.insert(borrowApply);
// 返回
return borrowApply.getId();
return CommonResult.success(borrowApply);
}
@Override
@Transactional
public void updateBorrowApply(BorrowApplyUpdateReqVO updateReqVO) {
BorrowApplyDO borrowApply = this.getBorrowApply(updateReqVO.getId());
RecordUpdateReqVO recordUpdateReqVO = new RecordUpdateReqVO();
RecordDO record = recordService.getRecord(borrowApply.getRecordId());
BeanUtils.copyProperties(record,recordUpdateReqVO);
if (StringUtils.isNotNull(updateReqVO.getBorrowState())){
if (updateReqVO.getBorrowState().equals("2")) {
recordUpdateReqVO.setBorrowStatus(null);
}
recordUpdateReqVO.setBorrowStatus(updateReqVO.getBorrowState());
recordService.updateRecord(recordUpdateReqVO);
}
// 校验存在
validateBorrowApplyExists(updateReqVO.getId());
// 更新
@ -63,7 +97,9 @@ public class BorrowApplyServiceImpl implements BorrowApplyService {
@Override
public BorrowApplyDO getBorrowApply(Long id) {
return borrowApplyMapper.selectById(id);
BorrowApplyDO borrowApplyDO = borrowApplyMapper.selectById(id);
RecordDO record = recordService.getRecord(borrowApplyDO.getRecordId());
return borrowApplyDO.setSite(record.getSite()).setFileType(record.getFileType()).setFilesNum(record.getFilesNum());
}
@Override
@ -73,6 +109,9 @@ public class BorrowApplyServiceImpl implements BorrowApplyService {
@Override
public PageResult<BorrowApplyDO> getBorrowApplyPage(BorrowApplyPageReqVO pageReqVO) {
if (pageReqVO.getHistoryOrList().equals("history")){
return borrowApplyMapper.selectPageHistory(pageReqVO);
}
return borrowApplyMapper.selectPage(pageReqVO);
}

Loading…
Cancel
Save