From bf765893039bc7968b8160a70bda778526dca98c Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期二, 31 十二月 2024 15:28:19 +0800
Subject: [PATCH] 定时任务

---
 manage/src/main/java/com/jilongda/manage/controller/TLensSeriesController.java |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 115 insertions(+), 2 deletions(-)

diff --git a/manage/src/main/java/com/jilongda/manage/controller/TLensSeriesController.java b/manage/src/main/java/com/jilongda/manage/controller/TLensSeriesController.java
index 6de8cea..bcff7ea 100644
--- a/manage/src/main/java/com/jilongda/manage/controller/TLensSeriesController.java
+++ b/manage/src/main/java/com/jilongda/manage/controller/TLensSeriesController.java
@@ -1,9 +1,27 @@
 package com.jilongda.manage.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonArray;
+import com.jilongda.common.basic.ApiResult;
+import com.jilongda.common.basic.PageInfo;
+import com.jilongda.manage.model.TLensSeries;
+import com.jilongda.manage.model.TOptometrist;
+import com.jilongda.manage.query.TLensSeriesQuery;
+import com.jilongda.manage.query.TOptometristQuery;
+import com.jilongda.manage.service.TLensSeriesService;
+import com.jilongda.manage.vo.TLensSeriesVO;
+import com.jilongda.manage.vo.TOptometristVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -13,9 +31,104 @@
  * @author 无关风月
  * @since 2024-12-09
  */
+@Api(tags = "镜片系列管理")
 @RestController
 @RequestMapping("/t-lens-series")
 public class TLensSeriesController {
+    @Autowired
+    private TLensSeriesService lensSeriesService;
+    @ApiOperation(value = "镜片系列列表")
+    @PostMapping(value = "/pageList")
+    public ApiResult<PageInfo<TLensSeriesVO>> pageList(@RequestBody TLensSeriesQuery query) {
+        PageInfo<TLensSeriesVO> optometristVOPageInfo = lensSeriesService.pageList(query);
+        return ApiResult.success(optometristVOPageInfo);
+    }
+    @ApiOperation(value = "镜片系列添加")
+    @PostMapping(value = "/add")
+    public ApiResult<String> add(@RequestBody TLensSeries dto) {
+        lensSeriesService.save(dto);
+        return ApiResult.success();
+    }
+    @ApiOperation(value = "镜片系列编辑")
+    @PostMapping(value = "/update")
+    public ApiResult<String> update(@RequestBody TLensSeries dto) {
+        if (!StringUtils.hasLength(dto.getSphere())){
+            dto.setSphere("");
+        }
+        if (!StringUtils.hasLength(dto.getAsphericSurface())){
+            dto.setAsphericSurface("");
+        }
+        if (!StringUtils.hasLength(dto.getDoubleNon())){
+            dto.setDoubleNon("");
+        }
+        lensSeriesService.updateById(dto);
+        return ApiResult.success();
+    }
+    @ApiOperation(value = "镜片系列启用/禁用")
+    @GetMapping(value = "/updateState")
+    public ApiResult<String> update(Integer id) {
+        TLensSeries byId = lensSeriesService.getById(id);
+        if (byId.getStatus()==1){
+            byId.setStatus(2);
+        }else{
+            byId.setStatus(1);
+        }
+        lensSeriesService.updateById(byId);
+        return ApiResult.success();
+    }
+    @ApiOperation(value = "通过品牌id查询镜片系列列表")
+    @GetMapping(value = "/seriesList")
+    public ApiResult<List<TLensSeries>> seriesList(Integer brandId) {
+        return ApiResult.success(lensSeriesService.lambdaQuery().eq(TLensSeries::getBrandId,brandId).list());
+    }
+    @ApiOperation(value = "通过系列id查询球/非球 返回参数1为球 2非球 3双飞")
+    @GetMapping(value = "/lensTypeList")
+    public ApiResult<List<Integer>> lensTypeList(Integer id) {
+        TLensSeries byId = lensSeriesService.getById(id);
+        List<Integer> integers = new ArrayList<>();
+        if (StringUtils.hasLength(byId.getSphere())){
+            integers.add(1);
+        }
+        if (StringUtils.hasLength(byId.getAsphericSurface())){
+            integers.add(2);
+        }
+        if (StringUtils.hasLength(byId.getDoubleNon())){
+            integers.add(3);
+        }
+        return ApiResult.success(integers);
+    }
+    @ApiOperation(value = "根据系列id + 球/非球查询折射率列表 球/非球入参数1为球 2非球 3双飞")
+    @GetMapping(value = "/refractiveIndexList")
+    public ApiResult<JSONArray> refractiveIndexList(Integer id, Integer lensType) {
+        TLensSeries byId = lensSeriesService.getById(id);
+        JSONArray jsonArray = null;
+        if (lensType==1){
+            String sphere = byId.getSphere();
+            // 将字符串化为jsonArray
+            if (StringUtils.hasLength(sphere)) {
+                jsonArray = JSONObject.parseArray(sphere);
+            } else {
+                return ApiResult.success(new JSONArray());
+            }
+        }
+        if (lensType==2){
+            String asphericSurface = byId.getAsphericSurface();
+            if (StringUtils.hasLength(asphericSurface)) {
+                jsonArray = JSONObject.parseArray(asphericSurface);
+            } else {
+                return ApiResult.success(new JSONArray());
+            }
+        }
+        if (lensType==3){
+            String doubleNon = byId.getDoubleNon();
+            if (StringUtils.hasLength(doubleNon)) {
+                jsonArray = JSONObject.parseArray(doubleNon);
+            } else {
+                return ApiResult.success(new JSONArray());
+            }
+        }
 
+        return ApiResult.success(jsonArray);
+    }
 }
 

--
Gitblit v1.7.1