From 84ae873e1c19ca7d2ffc5c98248285706dae818b Mon Sep 17 00:00:00 2001
From: rk <94314517@qq.com>
Date: 星期五, 26 六月 2026 18:07:37 +0800
Subject: [PATCH] 功能开发

---
 server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java |   88 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java b/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
index 54931bf..07217f0 100644
--- a/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
+++ b/server/services/src/main/java/com/doumee/service/system/impl/SystemDictDataServiceImpl.java
@@ -1,9 +1,13 @@
 package com.doumee.service.system.impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
+import com.doumee.core.douyin.DouyinClient;
+import com.doumee.dao.business.web.request.LocaltionDTO;
+import com.doumee.dao.business.web.response.DouyinConfigDTO;
 import com.doumee.dao.business.web.response.MiniProgrammeDTO;
 import com.doumee.dao.system.SystemDictMapper;
 import com.doumee.dao.system.model.SystemDict;
@@ -19,6 +23,7 @@
 import com.doumee.service.system.SystemDictDataService;
 import com.baomidou.mybatisplus.core.conditions.Wrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -26,6 +31,7 @@
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -37,12 +43,16 @@
  * @date 2022/03/15 09:54
  */
 @Service
+@Slf4j
 public class SystemDictDataServiceImpl implements SystemDictDataService {
 
     @Autowired
     private SystemDictDataMapper systemDictDataMapper;
     @Autowired
     private SystemDictMapper systemDictMapper;
+    /** 鎶栭煶 HTTP 瀹㈡埛绔�:鐢ㄤ簬鏀瑰畬搴旂敤閰嶇疆鍚庢竻绌� client_token 缂撳瓨 */
+    @Autowired
+    private DouyinClient douyinClient;
 
     @Override
     public String create(SystemDictData systemDictData) {
@@ -139,19 +149,93 @@
     @Override
     public void updateMiniProgrammeDTO(MiniProgrammeDTO miniProgrammeDTO) {
         try {
+            if(miniProgrammeDTO.getParkLatLngList()!=null){
+                try {
+                    TypeReference typeReference =  new TypeReference<List<LocaltionDTO>>(){};
+                    List<LocaltionDTO> response = JSONObject.parseObject(miniProgrammeDTO.getParkLatLngList(), typeReference.getType());
+                }catch (Exception e){
+                    e.printStackTrace();
+                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"杩愯惀鍖哄煙鍙傛暟瑙f瀽鏈夎锛�");
+                }
+            }
             String jasonStr = MiniProgrammeDTO.toUnderlineJSONString(miniProgrammeDTO);
             JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
             parse.entrySet().forEach(s->{
-                if (StringUtils.isNotBlank((String)s.getValue())){
+//                if (StringUtils.isNotBlank((String)s.getValue())){
                     UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
                     wrapper.lambda()
                             .eq(SystemDictData::getLabel,s.getKey().toUpperCase())
                             .set(SystemDictData::getCode,s.getValue());
                     systemDictDataMapper.update(null,wrapper);
-                }
+//                }
             });
         } catch (JsonProcessingException e) {
             throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
         }
     }
+
+    @Override
+    public DouyinConfigDTO getDouyinConfigDTO() {
+        try {
+            // 澶嶇敤 MiniProgrammeDTO 鐨勯┘宄扳噭涓嬪垝绾垮伐鍏�:瀵硅薄灞炴�� 鈫� {client_key,client_secret,account_id,poi_id}
+            String jasonStr = MiniProgrammeDTO.toUnderlineJSONString(new DouyinConfigDTO());
+            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+            List<String> collect = parse.entrySet().stream().map(s -> s.getKey().toUpperCase()).collect(Collectors.toList());
+            QueryWrapper<SystemDictData> wrapper = new QueryWrapper<>();
+            wrapper.lambda()
+                    .in(SystemDictData::getLabel,collect);
+            List<SystemDictData> systemDictData = systemDictDataMapper.selectList(wrapper);
+            if (CollectionUtils.isEmpty(systemDictData)){
+                throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"瀛楀吀涓嶅瓨鍦�");
+            }
+            systemDictData.forEach(s->{
+                parse.put(s.getLabel().toLowerCase(),s.getCode());
+            });
+            String s = parse.toJSONString();
+            return MiniProgrammeDTO.toSnakeObject(s, DouyinConfigDTO.class);
+        } catch (BusinessException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+        }
+    }
+
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+    @Override
+    public void updateDouyinAppConfigDTO(DouyinConfigDTO douyinConfigDTO) {
+        try {
+            String jasonStr = MiniProgrammeDTO.toUnderlineJSONString(douyinConfigDTO);
+            JSONObject parse = (JSONObject) JSONObject.parse(jasonStr);
+            // 浠呮洿鏂版姈闊冲簲鐢ㄤ笁椤�(client_key/client_secret/account_id),poi_id 鐢辩嫭绔嬫帴鍙g淮鎶�
+            parse.entrySet().forEach(s->{
+                UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
+                wrapper.lambda()
+                        .eq(SystemDictData::getLabel,s.getKey().toUpperCase())
+                        .set(SystemDictData::getCode,s.getValue());
+                systemDictDataMapper.update(null,wrapper);
+            });
+        } catch (JsonProcessingException e) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀛楀吀鍊艰В鏋愭湁璇�");
+        }
+        // client_key/client_secret 鏀逛簡涔嬪悗,缂撳瓨鐨勬棫 access-token 宸插け鏁�,娓呮帀鍚庝笅娆¤皟鐢ㄦ墠鐢ㄦ柊閰嶇疆鎹㈠彇鏂� token銆�
+        // 娓呯紦瀛樺睘浜庡壇浣滅敤,澶辫触涓嶅洖婊氶厤缃�(閰嶇疆宸叉纭叆搴�,token 涓嬫杩囨湡鑷剤)銆�
+        try {
+            douyinClient.clearAccessToken();
+        } catch (Exception e) {
+            log.warn("鏇存柊鎶栭煶搴旂敤閰嶇疆鍚庢竻绌� access-token 澶辫触", e);
+        }
+    }
+
+    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
+    @Override
+    public void updateDouyinPoiIdDTO(String poiId) {
+        if (StringUtils.isBlank(poiId)){
+            throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"闂ㄥ簵ID涓嶈兘涓虹┖");
+        }
+        UpdateWrapper<SystemDictData> wrapper = new UpdateWrapper<>();
+        wrapper.lambda()
+                .eq(SystemDictData::getLabel, Constants.DOUYIN_POI_ID)
+                .set(SystemDictData::getCode,poiId);
+        systemDictDataMapper.update(null,wrapper);
+    }
 }

--
Gitblit v1.9.3