|
|
@@ -0,0 +1,42 @@
|
|
|
+package com.etotem.cfc.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.entity.HealthExerciseRecord;
|
|
|
+import com.etotem.cfc.mapper.HealthExerciseRecordMapper;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Tag(name = "运动打卡")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/health/exercise")
|
|
|
+public class HealthExerciseController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HealthExerciseRecordMapper healthExerciseRecordMapper;
|
|
|
+
|
|
|
+ @Operation(summary = "获取运动打卡列表")
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result<List<HealthExerciseRecord>> list(@RequestBody Map<String, Object> params) {
|
|
|
+ Long memberId = params.get("memberId") != null ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ if (memberId == null) return Result.error("memberId不能为空");
|
|
|
+ LambdaQueryWrapper<HealthExerciseRecord> wrapper = new LambdaQueryWrapper<HealthExerciseRecord>()
|
|
|
+ .eq(HealthExerciseRecord::getMemberId, memberId)
|
|
|
+ .orderByDesc(HealthExerciseRecord::getCreatedAt);
|
|
|
+ return Result.success(healthExerciseRecordMapper.selectList(wrapper));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "创建运动打卡")
|
|
|
+ @PostMapping("/create")
|
|
|
+ public Result<HealthExerciseRecord> create(@RequestBody HealthExerciseRecord record) {
|
|
|
+ record.setCreatedAt(new Date());
|
|
|
+ healthExerciseRecordMapper.insert(record);
|
|
|
+ return Result.success(record);
|
|
|
+ }
|
|
|
+}
|