|
@@ -0,0 +1,124 @@
|
|
|
+package com.museum.web.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.museum.common.constant.TypeCode;
|
|
|
+import com.museum.common.util.Result;
|
|
|
+import com.museum.domain.entity.FileEntity;
|
|
|
+import com.museum.domain.entity.PartEntity;
|
|
|
+import com.museum.domain.entity.RoamEntity;
|
|
|
+import com.museum.domain.entity.TypeEntity;
|
|
|
+import com.museum.domain.request.NavRequest;
|
|
|
+import com.museum.service.PartService;
|
|
|
+import com.museum.service.RoamService;
|
|
|
+import com.museum.service.TypeService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import tk.mybatis.mapper.entity.Condition;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by owen on 2020/5/9 0018 12:17
|
|
|
+ *
|
|
|
+ * 给app、web 接口
|
|
|
+ */
|
|
|
+@Log4j2
|
|
|
+@Api(tags = "前端接口")
|
|
|
+@RestController
|
|
|
+@RequestMapping("api/web")
|
|
|
+@Transactional
|
|
|
+public class ApiController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public TypeService typeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PartService partService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RoamService roamService;
|
|
|
+
|
|
|
+
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "modelType", value = "模型类型, roam:自由漫游,part:部件欣赏", required = true)
|
|
|
+ })
|
|
|
+ @ApiOperation("获取导航")
|
|
|
+ @GetMapping("nav/{modelType}")
|
|
|
+ public Result<TypeEntity> nav(@PathVariable String modelType) {
|
|
|
+ Condition condition = new Condition(TypeEntity.class);
|
|
|
+ condition.and().andEqualTo("modelType", modelType);
|
|
|
+ List<TypeEntity> list = typeService.findAll(condition);
|
|
|
+ return Result.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("漫游列表/条件筛选")
|
|
|
+ @PostMapping("roam/list")
|
|
|
+ public Result<RoamEntity> roamList(@Valid @RequestBody NavRequest param) {
|
|
|
+ startPage(param);
|
|
|
+ // 区分移动端,还是后端
|
|
|
+ PageInfo<RoamEntity> page = new PageInfo<>(roamService.findByNav(param, 0));
|
|
|
+ return Result.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("漫游详情")
|
|
|
+ @GetMapping("roam/detail/{id}")
|
|
|
+ public Result<RoamEntity> roamDetail(@PathVariable Long id) {
|
|
|
+ RoamEntity entity = roamService.findById(id);
|
|
|
+
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("对象不存在: {}", id);
|
|
|
+ return Result.failure("对象不存在");
|
|
|
+ }
|
|
|
+ return Result.success(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("部件列表/条件筛选")
|
|
|
+ @PostMapping("part/list")
|
|
|
+ public Result<PartEntity> partList(@Valid @RequestBody NavRequest param) {
|
|
|
+ startPage(param);
|
|
|
+ // 区分移动端,还是后端
|
|
|
+ PageInfo<PartEntity> page = new PageInfo<>(partService.findByNav(param, 0));
|
|
|
+ return Result.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation("部件详情")
|
|
|
+ @GetMapping("part/detail/{id}")
|
|
|
+ public Result partDetail(@PathVariable Long id) {
|
|
|
+ PartEntity entity = partService.findById(id);
|
|
|
+
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("对象不存在: {}", id);
|
|
|
+ return Result.failure("对象不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找文件
|
|
|
+ List<FileEntity> files = fileService.findByFkIdAndType(id, TypeCode.MODEL_PART);
|
|
|
+
|
|
|
+ HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("part", entity);
|
|
|
+ resultMap.put("file", files);
|
|
|
+
|
|
|
+ return Result.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|