whh
4 months ago
7 changed files with 148 additions and 4 deletions
@ -0,0 +1,46 @@ |
|||||
|
package com.haihang.controller; |
||||
|
|
||||
|
import com.haihang.service.ReportService; |
||||
|
import com.haihang.utils.Result; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
@RequestMapping("/report") |
||||
|
@RestController |
||||
|
public class ReportController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ReportService reportService; |
||||
|
|
||||
|
@GetMapping("/{id}") |
||||
|
public Result userCases(@PathVariable Integer id) { |
||||
|
//根据用户id统计用户创建的用例数量
|
||||
|
return reportService.userCases(id); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/dayCase") |
||||
|
public Result dayCase(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) { |
||||
|
|
||||
|
return reportService.dayCase(date); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/beforeDayUserCase") |
||||
|
public Result beforeDayUserCase(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date,Integer userId) { |
||||
|
// 3. 统计到指定日期,每个用户的用例数
|
||||
|
return reportService.beforeDayUserCase(date,userId); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/userAndRole") |
||||
|
public Result userAndRole(Integer roleId) { |
||||
|
|
||||
|
|
||||
|
return reportService.countUserByRoleId(roleId); |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
package com.haihang.entity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class UserCaseVO { |
||||
|
//用户用例大全
|
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.haihang.service; |
||||
|
|
||||
|
|
||||
|
import com.haihang.utils.Result; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
public interface ReportService { |
||||
|
|
||||
|
|
||||
|
Result userCases(int id); |
||||
|
|
||||
|
Result dayCase(LocalDate date); |
||||
|
|
||||
|
Result beforeDayUserCase(LocalDate date, int userId); |
||||
|
|
||||
|
Result countUserByRoleId(Integer roleId); |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package com.haihang.service.impl; |
||||
|
|
||||
|
import com.haihang.mapper.CaseMapper; |
||||
|
import com.haihang.mapper.UserRoleMapper; |
||||
|
import com.haihang.service.ReportService; |
||||
|
import com.haihang.utils.Result; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.time.LocalDate; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class ReportServiceImpl implements ReportService { |
||||
|
|
||||
|
@Autowired |
||||
|
private CaseMapper caseMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private UserRoleMapper userRoleMapper; |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public Result userCases(int id) { |
||||
|
List<Integer> list = caseMapper.queryByUserId(id); |
||||
|
return Result.ok(list.size()); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result dayCase(LocalDate date) { |
||||
|
//根据日期筛选出符合当前日期的用例
|
||||
|
System.out.println(date.toString()); |
||||
|
List<Integer> lis = caseMapper.queryByDate(date.toString()); |
||||
|
return Result.ok(lis.size()); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result beforeDayUserCase(LocalDate date, int userId) { |
||||
|
Integer lis = caseMapper.queryBeforeDateByUser(date,userId); |
||||
|
return Result.ok(lis); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Result countUserByRoleId(Integer roleId) { |
||||
|
//根据角色id查询角色关联用户数
|
||||
|
//直接查中间表就完了
|
||||
|
Integer count = userRoleMapper.CountByRoleId(roleId); |
||||
|
return Result.ok(count); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue