首页返回值修改
This commit is contained in:
Ftz123456 2024-03-20 16:13:33 +08:00
parent 7d73f52dd0
commit 200ad5b2d4
5 changed files with 66 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import com.zsc.edu.bill.framework.security.SecurityUtil;
import com.zsc.edu.bill.framework.security.UserDetailsImpl;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.entity.Home;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import com.zsc.edu.bill.modules.bills.service.BillService;
import lombok.AllArgsConstructor;
@ -38,9 +39,9 @@ public class BillController {
/**
* 首页数据
* <p>
* */
*/
@GetMapping("home")
public List<Map<String, Object>> Home( BillDto dto){
public Home home(BillDto dto){
return service.getHomes(dto);
}

View File

@ -0,0 +1,18 @@
package com.zsc.edu.bill.modules.bills.entity;
import lombok.Data;
/**
* @author ftz
* 创建时间:2024/3/19 19:48
* 描述: 首页返回数据
*/
@Data
public class Home {
private Long notFiled =0L;
private Long notAudit =0L;
private Long pass =0L;
private Long notPass =0L;
}

View File

@ -5,11 +5,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.entity.Home;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import java.util.List;
import java.util.Map;
/**
* @author fantianzhi
* @description 针对表ticket(票据表)的数据库操作Service
@ -28,5 +26,5 @@ public interface BillService extends IService<Bill> {
Page<Bill> auditPage(Page<Bill> page, BillQuery query);
List<Map<String, Object>> getHomes(BillDto dto);
Home getHomes(BillDto dto);
}

View File

@ -8,6 +8,7 @@ import com.zsc.edu.bill.framework.security.SecurityUtil;
import com.zsc.edu.bill.framework.security.UserDetailsImpl;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.entity.Home;
import com.zsc.edu.bill.modules.bills.mapper.BillMapper;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import com.zsc.edu.bill.modules.bills.repo.BillRepository;
@ -15,8 +16,6 @@ import com.zsc.edu.bill.modules.bills.service.BillService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
@ -65,21 +64,56 @@ public class BillServiceImpl extends ServiceImpl<BillRepository, Bill> implement
}
@Override
public List<Map<String, Object>> getHomes(BillDto dto) {
public Home getHomes(BillDto dto) {
QueryWrapper<Bill> queryWrapper = new QueryWrapper<>();
Home home = new Home();
queryWrapper
.select("status as 'status',IFNULL(count(status),0) as 'number'")
.eq(Objects.nonNull(dto.getUserId()),"user_id",dto.getUserId())
.eq(Objects.nonNull(dto.getAuditorId()),"auditor_id",dto.getAuditorId())
.orderByAsc("status")
.groupBy("status");
List<Map<String, Object>> maps = listMaps(queryWrapper);
maps.forEach(map -> {
Integer status = (Integer) map.get("status");
map.put("status", Bill.Status.getByCode(status));
// listMaps(queryWrapper).forEach(map ->
// switch (map.get("status").toString()){
// case "0":
// home.setNotFiled((Integer) map.get("number"));
//
// case "1":
// home.setNotAudit((Integer)map.get("number"));
//
// case "2":
// home.setPass((Integer)map.get("number"));
//
// case "3":
// home.setNotPass((Integer)map.get("number"));
//
// default:
// throw new IllegalStateException("Unexpected value: " + map.get("status").toString());
// }
//
// );
listMaps(queryWrapper).forEach(map -> {
switch (map.get("status").toString()){
case "0":
home.setNotFiled((Long) map.get("number"));
break;
case "1":
home.setNotAudit((Long) map.get("number"));
break;
case "2":
home.setPass((Long) map.get("number"));
break;
case "3":
home.setNotPass((Long) map.get("number"));
break;
default:
throw new IllegalStateException("Unexpected value: " + map.get("status").toString());
}
});
return maps;
return home;
}

View File

@ -15,7 +15,7 @@ public class UploadUtils {
public static File getImgDirFile(){
// 构建上传文件的存放 "文件夹" 路径
String fileDirPath = new String("src/main/resources/" + IMG_PATH_PREFIX);
String fileDirPath = "src/main/resources/" + IMG_PATH_PREFIX;
File fileDir = new File(fileDirPath);
if(!fileDir.exists()){