Browse Source

月度期刊统计分页、修改

master
Jinyuanyuan 5 months ago
parent
commit
c84fd11cad
  1. 97
      huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouPeriodicallabCountController.java
  2. 14
      huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouPeriodicallabCountMapper.java
  3. 4
      huzhou/src/main/java/com/easy/admin/modules/huzhou/entity/HuzhouPeriodicallab.java
  4. 41
      huzhou/src/main/java/com/easy/admin/modules/huzhou/entity/HuzhouPeriodicallabCount.java
  5. 24
      huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouPeriodicallabCountService.java
  6. 95
      huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouPeriodicallabCountServiceImpl.java
  7. 14
      huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouPeriodicallabServiceImpl.java
  8. 25
      huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/PeriodicallabCountOV.java

97
huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouPeriodicallabCountController.java

@ -0,0 +1,97 @@
package com.easy.admin.modules.huzhou.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easy.admin.common.api.vo.Result;
import com.easy.admin.common.core.exception.EasyException;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallab;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallabCount;
import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabCountService;
import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabService;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountOV;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@RestController
@RequestMapping("/huzhouPeriodicallabCount")
public class HuzhouPeriodicallabCountController {
@Autowired
private IHuzhouPeriodicallabCountService periodicallabCountService;
/**
* 查询月度期刊分页
* @param periodicallabCount 条件
* @param pageNo 分页
* @param pageSize 页码
* @return
*/
@GetMapping("/periodicallabCountPageList")
public Result<?> periodicallabCountPageList(HuzhouPeriodicallabCount periodicallabCount,
@RequestParam(name="current", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
Page<PeriodicallabCountOV> pageList = periodicallabCountService.getPeriodicallabCountPageList(periodicallabCount, pageNo, pageSize);
return Result.ok(pageList);
}
/**
* 根据id获取详情月度期刊
* @param id
* @return
*/
@GetMapping("/getperiodicallabById")
public Result<?> getperiodicallabCountById(String id){
HuzhouPeriodicallabCount byId = periodicallabCountService.getById(id);
return Result.ok(byId);
}
/**
* 添加月度期刊
* @param file
* @param periodicallab
* @return
* @throws IOException
*/
@PostMapping("/addPeriodicallabCount")
public Result<?> addPeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount){
periodicallabCountService.addPeriodicallabCount(periodicallabCount);
return Result.ok("新增成功");
}
/**
* 修改阅读期刊
* @param file
* @param periodicallab
* @return
* @throws IOException
*/
@PostMapping("/modifyPeriodicallabCount")
public Result<?> modifyPeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount){
Boolean aBoolean = periodicallabCountService.modifyPeriodicallabCount(periodicallabCount);
if(aBoolean){
return Result.ok("修改成功");
}
throw new EasyException("修改失败");
}
/**
* 删除阅读期刊
* @param periodicallab
* @return
* @throws IOException
*/
@PostMapping("/deletePeriodicallabCount")
public Result<?> deletePeriodicallabCount(@RequestBody HuzhouPeriodicallabCount periodicallabCount){
Boolean aBoolean = periodicallabCountService.deletePeriodicallabCount(periodicallabCount);
if(aBoolean){
return Result.ok("删除成功");
}
throw new EasyException("删除失败");
}
}

14
huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouPeriodicallabCountMapper.java

@ -0,0 +1,14 @@
package com.easy.admin.modules.huzhou.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallab;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallabCount;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountPage;
import org.apache.ibatis.annotations.Param;
public interface HuzhouPeriodicallabCountMapper extends BaseMapper<HuzhouPeriodicallabCount> {
}

4
huzhou/src/main/java/com/easy/admin/modules/huzhou/entity/HuzhouPeriodicallab.java

@ -1,7 +1,9 @@
package com.easy.admin.modules.huzhou.entity; package com.easy.admin.modules.huzhou.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
@ -14,6 +16,8 @@ import java.util.Date;
* @since 2024-02-29 11:03:40 * @since 2024-02-29 11:03:40
*/ */
@Data @Data
@Accessors(chain = true)
@Builder(toBuilder = true)
public class HuzhouPeriodicallab extends BaseEntity implements Serializable { public class HuzhouPeriodicallab extends BaseEntity implements Serializable {
private static final long serialVersionUID = -50005828024123796L; private static final long serialVersionUID = -50005828024123796L;
/** /**

41
huzhou/src/main/java/com/easy/admin/modules/huzhou/entity/HuzhouPeriodicallabCount.java

@ -0,0 +1,41 @@
package com.easy.admin.modules.huzhou.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.models.security.SecurityScheme;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* (HuzhouPeriodicallab)实体类
*
* @author makejava
* @since 2024-02-29 11:03:40
*/
@Data
@Accessors(chain = true)
@Builder(toBuilder = true)
public class HuzhouPeriodicallabCount extends BaseEntity implements Serializable {
private static final long serialVersionUID = -50005828024123796L;
/**
* id
*/
private String id;
private String workplace;
private String adminDivision;
private Integer countNumber;
private Integer editNumber;
}

24
huzhou/src/main/java/com/easy/admin/modules/huzhou/service/IHuzhouPeriodicallabCountService.java

@ -0,0 +1,24 @@
package com.easy.admin.modules.huzhou.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallab;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallabCount;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountOV;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountPage;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public interface IHuzhouPeriodicallabCountService extends IService<HuzhouPeriodicallabCount> {
Page<PeriodicallabCountOV> getPeriodicallabCountPageList(HuzhouPeriodicallabCount periodicallabCount, Integer pageNo,
Integer pageSize);
Boolean addPeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount);
Boolean modifyPeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount);
Boolean deletePeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount);
String findId(String workplace);
}

95
huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouPeriodicallabCountServiceImpl.java

@ -0,0 +1,95 @@
package com.easy.admin.modules.huzhou.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easy.admin.auth.model.SysUser;
import com.easy.admin.common.util.CommonUtils;
import com.easy.admin.modules.huzhou.dao.HuzhouPeriodicallabCountMapper;
import com.easy.admin.modules.huzhou.dao.HuzhouPeriodicallabMapper;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallab;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallabCount;
import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabCountService;
import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabService;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountOV;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountPage;
import com.easy.admin.util.ShiroUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@Service
public class HuzhouPeriodicallabCountServiceImpl extends ServiceImpl<HuzhouPeriodicallabCountMapper, HuzhouPeriodicallabCount> implements IHuzhouPeriodicallabCountService {
@Autowired
HuzhouPeriodicallabCountMapper periodicallabCountMapper;
@Override
public Page<PeriodicallabCountOV> getPeriodicallabCountPageList(HuzhouPeriodicallabCount periodicallabCount, Integer pageNo, Integer pageSize) {
LambdaQueryWrapper<HuzhouPeriodicallabCount> queryWrapper = new LambdaQueryWrapper<>();
Page<HuzhouPeriodicallabCount> page = new Page<>(pageNo, pageSize);
String workplace = periodicallabCount.getWorkplace();
String adminDivision = periodicallabCount.getAdminDivision();
queryWrapper.like(StringUtils.isNotBlank(workplace),HuzhouPeriodicallabCount::getWorkplace,workplace);
queryWrapper.eq(StringUtils.isNotBlank(adminDivision),HuzhouPeriodicallabCount::getAdminDivision,adminDivision);
Page<HuzhouPeriodicallabCount> periodicallabCountPage = this.page(page, queryWrapper);
List<HuzhouPeriodicallabCount> records = periodicallabCountPage.getRecords();
List<PeriodicallabCountOV> newRecords=new ArrayList<>();
for(HuzhouPeriodicallabCount r:records){
PeriodicallabCountOV ov = new PeriodicallabCountOV();
BeanUtils.copyProperties(r,ov);
if(r.getEditNumber() == null){
ov.setShowNumber(r.getCountNumber());
}else {
ov.setShowNumber(r.getEditNumber());
}
newRecords.add(ov);
}
Page<PeriodicallabCountOV> result=new Page<>();
result.setRecords(newRecords).setTotal(periodicallabCountPage.getTotal()).setCurrent(periodicallabCountPage.getCurrent()).setSize(periodicallabCountPage.getSize());
return result;
}
@Override
public Boolean addPeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount) {
return this.save(periodicallabCount);
}
@Override
public Boolean modifyPeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount) {
return this.updateById(periodicallabCount);
}
@Override
public Boolean deletePeriodicallabCount(HuzhouPeriodicallabCount periodicallabCount) {
String id=periodicallabCount.getId();
return this.removeById(id);
}
@Override
public String findId(String workplace) {
LambdaQueryWrapper<HuzhouPeriodicallabCount> query = new LambdaQueryWrapper<>();
query.eq(StringUtils.isNotBlank(workplace),HuzhouPeriodicallabCount::getWorkplace,workplace);
List<?> result = periodicallabCountMapper.selectObjs(query);
return result == null || result.isEmpty() ? null : (String) result.get(0);
}
}

14
huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouPeriodicallabServiceImpl.java

@ -8,6 +8,8 @@ import com.easy.admin.auth.model.SysUser;
import com.easy.admin.common.util.CommonUtils; import com.easy.admin.common.util.CommonUtils;
import com.easy.admin.modules.huzhou.dao.HuzhouPeriodicallabMapper; import com.easy.admin.modules.huzhou.dao.HuzhouPeriodicallabMapper;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallab; import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallab;
import com.easy.admin.modules.huzhou.entity.HuzhouPeriodicallabCount;
import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabCountService;
import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabService; import com.easy.admin.modules.huzhou.service.IHuzhouPeriodicallabService;
import com.easy.admin.modules.huzhou.vo.PeriodicallabCountPage; import com.easy.admin.modules.huzhou.vo.PeriodicallabCountPage;
import com.easy.admin.util.ShiroUtil; import com.easy.admin.util.ShiroUtil;
@ -36,6 +38,9 @@ public class HuzhouPeriodicallabServiceImpl extends ServiceImpl<HuzhouPeriodical
@Autowired @Autowired
HuzhouPeriodicallabMapper periodicallabMapper; HuzhouPeriodicallabMapper periodicallabMapper;
@Autowired
IHuzhouPeriodicallabCountService periodicallabCountService;
@Override @Override
public Page<HuzhouPeriodicallab> getPeriodicallabPageList(HuzhouPeriodicallab periodicallab, public Page<HuzhouPeriodicallab> getPeriodicallabPageList(HuzhouPeriodicallab periodicallab,
Integer pageNo, Integer pageNo,
@ -59,6 +64,10 @@ public class HuzhouPeriodicallabServiceImpl extends ServiceImpl<HuzhouPeriodical
public void addPeriodicallab(MultipartFile file, HuzhouPeriodicallab periodicallab) throws IOException { public void addPeriodicallab(MultipartFile file, HuzhouPeriodicallab periodicallab) throws IOException {
addFile(file,periodicallab); addFile(file,periodicallab);
this.save(periodicallab); this.save(periodicallab);
String workplace = periodicallab.getWorkplace();
String id = periodicallabCountService.findId(workplace);
int num = periodicallabCountService.getById(id).getCountNumber() + 1;
periodicallabCountService.modifyPeriodicallabCount(HuzhouPeriodicallabCount.builder().id(id).countNumber(num).build());
} }
@Override @Override
@ -84,7 +93,12 @@ public class HuzhouPeriodicallabServiceImpl extends ServiceImpl<HuzhouPeriodical
File file = new File(periodicallab.getDocumentPath()); File file = new File(periodicallab.getDocumentPath());
if(file.delete()){ if(file.delete()){
this.removeById(id); this.removeById(id);
String workplace = periodicallabMapper.selectById(id).getWorkplace();
String periodicallabCountId = periodicallabCountService.findId(workplace);
int num=periodicallabCountService.getById(periodicallabCountId).getCountNumber()-1;
periodicallabCountService.modifyPeriodicallabCount(HuzhouPeriodicallabCount.builder().id(periodicallabCountId).countNumber(num).build());
return Boolean.TRUE; return Boolean.TRUE;
} }
return Boolean.FALSE; return Boolean.FALSE;
} }

25
huzhou/src/main/java/com/easy/admin/modules/huzhou/vo/PeriodicallabCountOV.java

@ -0,0 +1,25 @@
package com.easy.admin.modules.huzhou.vo;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
public class PeriodicallabCountOV {
/**
* id
*/
private String id;
private String workplace;
private String adminDivision;
private Integer countNumber;
private Integer editNumber;
private Integer showNumber;
}
Loading…
Cancel
Save