|
@@ -5,6 +5,7 @@ import com.yaoxiang.diagnosis.model.Result;
|
|
|
import com.yaoxiang.diagnosis.service.LearnRecordService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -12,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-@Api(tags = "学习")
|
|
|
+@Api(tags = "学习记录")
|
|
|
@RestController
|
|
|
@RequestMapping("learn")
|
|
|
public class LearnRecordController {
|
|
@@ -22,50 +23,69 @@ public class LearnRecordController {
|
|
|
|
|
|
@ApiOperation("增加")
|
|
|
@PostMapping("add")
|
|
|
- public Result add(Long uid, String content, Long beginTime, Long endTime) {
|
|
|
+ public Result add(Long uid, String content, String status,
|
|
|
+ @RequestParam(required = false) Long beginTime,
|
|
|
+ @RequestParam(required = false) Long endTime) {
|
|
|
if (beginTime == null) {
|
|
|
beginTime = System.currentTimeMillis();
|
|
|
}
|
|
|
- boolean result = learnRecordService.add(uid, content, beginTime, endTime);
|
|
|
- return Result.ok(result);
|
|
|
+ boolean result = learnRecordService.add(uid, content, status, beginTime, endTime);
|
|
|
+ return new Result(result);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("更新")
|
|
|
@PostMapping("update")
|
|
|
public Result update(@RequestBody LearnRecord record) {
|
|
|
boolean result = learnRecordService.update(record);
|
|
|
- return Result.ok(result);
|
|
|
+ return new Result(result);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("删除")
|
|
|
@PostMapping("delete")
|
|
|
public Result delete(Long id) {
|
|
|
boolean result = learnRecordService.delete(id);
|
|
|
- return Result.ok(result);
|
|
|
+ return new Result(result);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("monthStatus")
|
|
|
@ApiOperation("获取当月的记录情况")
|
|
|
- @ApiImplicitParam(name = "time", value = "月份时间,毫秒", paramType = "query")
|
|
|
- public Map<Integer, Long> monthStatus(Long uid, Long time) {
|
|
|
+ @ApiImplicitParam(name = "time", value = "月份时间,单位至毫秒", paramType = "query")
|
|
|
+ public Map<String, Long> monthStatus(Long uid, @RequestParam(required = false) Long time) {
|
|
|
if (time == null) {
|
|
|
time = System.currentTimeMillis();
|
|
|
}
|
|
|
return learnRecordService.monthStatus(uid, time);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("获取列表")
|
|
|
+ @GetMapping("listByMonth")
|
|
|
+ @ApiOperation("获取当月的记录情况")
|
|
|
+ @ApiImplicitParam(name = "time", value = "月份时间,单位至毫秒", paramType = "query")
|
|
|
+ public List<LearnRecord> listByMonth(Long uid, @RequestParam(required = false) Long time) {
|
|
|
+ if (time == null) {
|
|
|
+ time = System.currentTimeMillis();
|
|
|
+ }
|
|
|
+ return learnRecordService.listByMonth(uid, time);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("根据用户Id获取列表")
|
|
|
@GetMapping("list")
|
|
|
- public List<LearnRecord> list(Long uid, String category,
|
|
|
- @RequestParam(defaultValue = "0") Long startTime, Long endTime) {
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "startTime", value = "开始时间,单位至毫秒", paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "endTime", value = "结束时间,单位至毫秒", paramType = "query")
|
|
|
+ })
|
|
|
+ public List<LearnRecord> list(Long uid, @RequestParam(required = false) String category,
|
|
|
+ @RequestParam(defaultValue = "0") Long startTime,
|
|
|
+ @RequestParam(required = false) Long endTime) {
|
|
|
if (endTime == null) {
|
|
|
endTime = System.currentTimeMillis();
|
|
|
}
|
|
|
return learnRecordService.list(uid, category, startTime, endTime);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("获取本周的记录")
|
|
|
+ @ApiOperation("获取time(毫秒)所在周的记录,time为null时,获取本周记录")
|
|
|
@GetMapping("listByWeek")
|
|
|
- public List<LearnRecord> listByWeek(Long uid, Long time) {
|
|
|
+ @ApiImplicitParam(name = "time", value = "周时间,单位至毫秒", paramType = "query")
|
|
|
+ public List<LearnRecord> listByWeek(Long uid, @RequestParam(required = false) Long time) {
|
|
|
if (time == null) {
|
|
|
time = System.currentTimeMillis();
|
|
|
}
|