瀏覽代碼

国家新增接口修改,解决数值不自动获取的问题。

Sakana 1 周之前
父節點
當前提交
82066e2208
共有 13 個文件被更改,包括 367 次插入28 次删除
  1. 2 1
      edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/commodity/ShopSpecRemoteController.java
  2. 10 0
      edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/commodity/ShopSpecValueRemoteController.java
  3. 46 0
      edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/dto/ShopSpecValueDto.java
  4. 45 0
      edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/vo/ShopSpecValueVo.java
  5. 6 0
      edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/vo/SpecVo.java
  6. 0 14
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopLanguageController.java
  7. 3 3
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopOpinionController.java
  8. 107 2
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopSpecController.java
  9. 64 1
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopSpecValueController.java
  10. 3 3
      edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopUnitController.java
  11. 6 0
      edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/service/BaseCountryService.java
  12. 54 1
      edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/service/impl/BaseCountryServiceImpl.java
  13. 21 3
      edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/web/BaseCountryServeController.java

+ 2 - 1
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/commodity/ShopSpecRemoteController.java

@@ -1,6 +1,7 @@
 package edu.travel.remote.commodity;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import edu.travel.remote.base.RemoteBaseController;
 import edu.travel.remote.dto.SpecDto;
 import edu.travel.remote.vo.SpecVo;
 import edu.travel.rpc.RPCBaseResponse;
@@ -12,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 
 
 @FeignClient(name="commodity-dev",path = "/shopSpec")
-public interface ShopSpecRemoteController {
+public interface ShopSpecRemoteController extends RemoteBaseController<SpecVo, SpecDto> {
     @GetMapping("/getShopSpec")
     public RPCBaseResponse<Page<SpecVo>> getShopSpec(@RequestParam("countryId")Long countryId,
                                                      @RequestParam("currentPage")Integer currentPage,

+ 10 - 0
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/commodity/ShopSpecValueRemoteController.java

@@ -0,0 +1,10 @@
+package edu.travel.remote.commodity;
+
+import edu.travel.remote.base.RemoteBaseController;
+import edu.travel.remote.dto.ShopSpecValueDto;
+import edu.travel.remote.vo.ShopSpecValueVo;
+import org.springframework.cloud.openfeign.FeignClient;
+
+@FeignClient(name="commodity-dev",path = "/shopSpecValue")
+public interface ShopSpecValueRemoteController extends RemoteBaseController<ShopSpecValueVo, ShopSpecValueDto> {
+}

+ 46 - 0
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/dto/ShopSpecValueDto.java

@@ -0,0 +1,46 @@
+package edu.travel.remote.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import edu.travel.entity.BaseEntity;
+import edu.travel.po.PagePO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 规格值表
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName(value = "shop_spec_value")
+public class ShopSpecValueDto extends PagePO {
+    /**
+     * 规格值表ID
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 商品规格关联ID
+     */
+    @TableField(value = "product_spec_id")
+    private Long productSpecId;
+
+    /**
+     * 规格值
+     */
+    @TableField(value = "spec_value")
+    private String specValue;
+
+    /**
+     * 权重
+     */
+    @TableField(value = "sort_order")
+    private String sortOrder;
+
+
+}

+ 45 - 0
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/vo/ShopSpecValueVo.java

@@ -0,0 +1,45 @@
+package edu.travel.remote.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import edu.travel.entity.BaseEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 规格值表
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName(value = "shop_spec_value")
+public class ShopSpecValueVo extends BaseEntity {
+    /**
+     * 规格值表ID
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 商品规格关联ID
+     */
+    @TableField(value = "product_spec_id")
+    private Long productSpecId;
+
+    /**
+     * 规格值
+     */
+    @TableField(value = "spec_value")
+    private String specValue;
+
+    /**
+     * 权重
+     */
+    @TableField(value = "sort_order")
+    private String sortOrder;
+
+
+}

+ 6 - 0
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/vo/SpecVo.java

@@ -2,6 +2,8 @@ package edu.travel.remote.vo;
 
 import lombok.Data;
 
+import java.util.Map;
+
 @Data
 public class SpecVo {
     /**
@@ -12,4 +14,8 @@ public class SpecVo {
      * 规格值
      */
     private String specName;
+    /**
+     * map
+     */
+    private Map<String, Object> map;
 }

+ 0 - 14
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopLanguageController.java

@@ -1,14 +0,0 @@
-package edu.travel.commodity.web;
-
-import org.springframework.web.bind.annotation.*;
-
-/**
-* 语言表(shop_language)表控制层
-*
-* @author xxxxx
-*/
-@RestController
-@RequestMapping("/shop_language")
-public class ShopLanguageController {
-
-}

+ 3 - 3
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopOpinionController.java

@@ -70,7 +70,7 @@ public class ShopOpinionController extends BaseController<ShopOpinion> implement
      */
     @Override
     @PostMapping("/updateTargetFormId")
-    public RPCBaseResponse<ShopOpinionVo> updateTargetFormId(ShopOpinionDto entity) {
+    public RPCBaseResponse<ShopOpinionVo> updateTargetFormId(@RequestBody ShopOpinionDto entity) {
         ShopOpinion shopOpinion = new ShopOpinion();
         BeanUtils.copyProperties(entity, shopOpinion);
         RPCBaseResponse<ShopOpinion> shopOpinionRPCBaseResponse = super.updateTargetById(shopOpinion);
@@ -84,7 +84,7 @@ public class ShopOpinionController extends BaseController<ShopOpinion> implement
      */
     @Override
     @PostMapping("/saveFormTarget")
-    public RPCBaseResponse<ShopOpinionVo> saveFormTarget(ShopOpinionDto entity) {
+    public RPCBaseResponse<ShopOpinionVo> saveFormTarget(@RequestBody ShopOpinionDto entity) {
         ShopOpinion shopOpinion = new ShopOpinion();
         BeanUtils.copyProperties(entity, shopOpinion);
         RPCBaseResponse<ShopOpinion> shopOpinionRPCBaseResponse = super.saveTarget(shopOpinion);
@@ -98,7 +98,7 @@ public class ShopOpinionController extends BaseController<ShopOpinion> implement
      */
     @Override
     @PostMapping("/deleteTargetFormId")
-    public RPCBaseResponse<ShopOpinionVo> deleteTargetFormId(List<String> ids) {
+    public RPCBaseResponse<ShopOpinionVo> deleteTargetFormId(@RequestBody List<String> ids) {
         RPCBaseResponse<ShopOpinion> shopOpinionRPCBaseResponse = super.deleteTargetById(ids);
         RPCBaseResponse<ShopOpinionVo> shopOpinionVoRPCBaseResponse = new RPCBaseResponse<>();
         BeanUtils.copyProperties(shopOpinionRPCBaseResponse, shopOpinionVoRPCBaseResponse);

+ 107 - 2
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopSpecController.java

@@ -1,15 +1,26 @@
 package edu.travel.commodity.web;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import edu.travel.adapter.service.country.CountryAdapter;
+import edu.travel.commodity.constant.BaseConstant;
+import edu.travel.commodity.entity.ShopSpec;
 import edu.travel.commodity.service.ShopSpecService;
 import edu.travel.remote.commodity.ShopSpecRemoteController;
 import edu.travel.remote.dto.SpecDto;
 import edu.travel.remote.vo.SpecVo;
 import edu.travel.rpc.RPCBaseResponse;
+import edu.travel.vo.BaseCountryServeVo;
+import edu.travel.web.BaseController;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
 import static edu.travel.rpc.RPCBaseResponse.success;
 
 /**
@@ -19,13 +30,14 @@ import static edu.travel.rpc.RPCBaseResponse.success;
 */
 @RestController
 @RequestMapping("/shopSpec")
-public class ShopSpecController implements ShopSpecRemoteController {
+public class ShopSpecController extends BaseController<ShopSpec> implements ShopSpecRemoteController {
 /**
 * 服务对象
 */
     @Autowired
     private ShopSpecService shopSpecService;
-
+    @Autowired
+    private CountryAdapter countryAdapter;
 
     /**
      *  分页查询规格
@@ -49,4 +61,97 @@ public class ShopSpecController implements ShopSpecRemoteController {
         shopSpecService.insertOrUpdate(specDto);
         return success();
     }
+
+    /**
+     * 通过id查找规格
+     * @param id
+     * @return
+     */
+    @Override
+    @GetMapping("/getFormId")
+    public RPCBaseResponse<SpecVo> getFormId(String id) {
+        RPCBaseResponse<ShopSpec> shopSpecRPCBaseResponse = super.getId(id);
+        if (!Objects.equals(shopSpecRPCBaseResponse.getCode(), BaseConstant.SUCCESS_CODE)){
+            return RPCBaseResponse.error(shopSpecRPCBaseResponse.getMsg());
+        }
+        //获取规格信息
+        ShopSpec shopSpec = shopSpecRPCBaseResponse.getData();
+        //提取countryId
+        Long countryId = shopSpec.getCountryId();
+        //获取国家信息countryAdapter
+        RPCBaseResponse<BaseCountryServeVo> countryInfoResponse = countryAdapter.getFormId(countryId.toString());
+        //检查国家信息的响应
+        if (!Objects.equals(countryInfoResponse.getCode(), BaseConstant.SUCCESS_CODE)){
+            return RPCBaseResponse.error(countryInfoResponse.getMsg());
+        }
+        //获取国家信息
+        BaseCountryServeVo countryInfo = countryInfoResponse.getData();
+        //创建vo对象
+        SpecVo specVo = new SpecVo();
+        BeanUtils.copyProperties(shopSpec, specVo);
+        //存入map
+        Map<String, Object> map = new HashMap<>();
+        map.put("countryInfo", countryInfo);
+        specVo.setMap(map);
+        return RPCBaseResponse.success(specVo);
+    }
+
+    /**
+     * 更新规格
+     * @param entity
+     * @return
+     */
+    @Override
+    @PostMapping("/updateTargetFormId")
+    public RPCBaseResponse<SpecVo> updateTargetFormId(@RequestBody SpecDto entity) {
+        ShopSpec shopSpec = new ShopSpec();
+        BeanUtils.copyProperties(entity, shopSpec);
+        RPCBaseResponse<ShopSpec> shopSpecRPCBaseResponse = super.updateTargetById(shopSpec);
+        RPCBaseResponse<SpecVo> shopSpecVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecRPCBaseResponse, shopSpecVoRPCBaseResponse);
+        return shopSpecVoRPCBaseResponse;
+    }
+
+    /**
+     * 新增规格
+     * @param entity
+     * @return
+     */
+    @Override
+    @PostMapping("/saveFormTarget")
+    public RPCBaseResponse<SpecVo> saveFormTarget(@RequestBody SpecDto entity) {
+        ShopSpec shopSpec = new ShopSpec();
+        BeanUtils.copyProperties(entity, shopSpec);
+        RPCBaseResponse<ShopSpec> shopSpecRPCBaseResponse = super.saveTarget(shopSpec);
+        RPCBaseResponse<SpecVo> shopSpecVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecRPCBaseResponse, shopSpecVoRPCBaseResponse);
+        return shopSpecVoRPCBaseResponse;
+    }
+
+    /**
+     *删除规格
+     * @param ids
+     * @return
+     */
+    @Override
+    @PostMapping("/deleteTargetFormId")
+    public RPCBaseResponse<SpecVo> deleteTargetFormId(@RequestBody List<String> ids) {
+        RPCBaseResponse<ShopSpec> shopSpecRPCBaseResponse = super.deleteTargetById(ids);
+        RPCBaseResponse<SpecVo> shopSpecVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecRPCBaseResponse, shopSpecVoRPCBaseResponse);
+        return shopSpecVoRPCBaseResponse;
+    }
+
+    /**
+     * 获取所有规格
+     * @return
+     */
+    @Override
+    @GetMapping("/getAllForm")
+    public RPCBaseResponse<List<SpecVo>> getAllForm() {
+        RPCBaseResponse<List<ShopSpec>> shopSpecRPCBaseResponse = super.listAll();
+        RPCBaseResponse<List<SpecVo>> shopSpecVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecRPCBaseResponse, shopSpecVoRPCBaseResponse);
+        return shopSpecVoRPCBaseResponse;
+    }
 }

+ 64 - 1
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopSpecValueController.java

@@ -1,10 +1,19 @@
 package edu.travel.commodity.web;
 
+import edu.travel.commodity.entity.ShopSpecValue;
 import edu.travel.commodity.service.ShopSpecValueService;
+import edu.travel.remote.commodity.ShopSpecValueRemoteController;
+import edu.travel.remote.dto.ShopSpecValueDto;
+import edu.travel.remote.vo.ShopSpecValueVo;
+import edu.travel.rpc.RPCBaseResponse;
+import edu.travel.web.BaseController;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 /**
 * 规格值表(shop_spec_value)表控制层
 *
@@ -12,11 +21,65 @@ import org.springframework.beans.factory.annotation.Autowired;
 */
 @RestController
 @RequestMapping("/shop_spec_value")
-public class ShopSpecValueController {
+public class ShopSpecValueController extends BaseController<ShopSpecValue> implements ShopSpecValueRemoteController {
 /**
 * 服务对象
 */
     @Autowired
     private ShopSpecValueService shopSpecValueService;
 
+    /**
+     * 通过id查找规格值
+     * @param id
+     * @return
+     */
+    @Override
+    @GetMapping("/getFormId")
+    public RPCBaseResponse<ShopSpecValueVo> getFormId(@RequestParam("id") String id) {
+        RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.getId(id);
+        RPCBaseResponse<ShopSpecValueVo> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecValueRPCBaseResponse, shopSpecValueVoRPCBaseResponse);
+        return shopSpecValueVoRPCBaseResponse;
+    }
+
+    /**
+     *
+     * @param entity
+     * @return
+     */
+    @Override
+    public RPCBaseResponse<ShopSpecValueVo> updateTargetFormId(ShopSpecValueDto entity) {
+        ShopSpecValue shopSpecValue = new ShopSpecValue();
+        BeanUtils.copyProperties(entity, shopSpecValue);
+        RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.updateTargetById(shopSpecValue);
+        RPCBaseResponse<ShopSpecValueVo> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecValueRPCBaseResponse, shopSpecValueVoRPCBaseResponse);
+        return shopSpecValueVoRPCBaseResponse;
+    }
+
+    @Override
+    public RPCBaseResponse<ShopSpecValueVo> saveFormTarget(ShopSpecValueDto entity) {
+        ShopSpecValue shopSpecValue = new ShopSpecValue();
+        BeanUtils.copyProperties(entity, shopSpecValue);
+        RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.saveTarget(shopSpecValue);
+        RPCBaseResponse<ShopSpecValueVo> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecValueRPCBaseResponse, shopSpecValueVoRPCBaseResponse);
+        return shopSpecValueVoRPCBaseResponse;
+    }
+
+    @Override
+    public RPCBaseResponse<ShopSpecValueVo> deleteTargetFormId(List<String> ids) {
+        RPCBaseResponse<ShopSpecValue> shopSpecValueRPCBaseResponse = super.deleteTargetById(ids);
+        RPCBaseResponse<ShopSpecValueVo> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecValueRPCBaseResponse, shopSpecValueVoRPCBaseResponse);
+        return shopSpecValueVoRPCBaseResponse;
+    }
+
+    @Override
+    public RPCBaseResponse<List<ShopSpecValueVo>> getAllForm() {
+        RPCBaseResponse<List<ShopSpecValue>> shopSpecValueRPCBaseResponse = super.listAll();
+        RPCBaseResponse<List<ShopSpecValueVo>> shopSpecValueVoRPCBaseResponse = new RPCBaseResponse<>();
+        BeanUtils.copyProperties(shopSpecValueRPCBaseResponse, shopSpecValueVoRPCBaseResponse);
+        return shopSpecValueVoRPCBaseResponse;
+    }
 }

+ 3 - 3
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopUnitController.java

@@ -83,7 +83,7 @@ public class ShopUnitController extends BaseController<ShopUnit> implements Shop
      */
     @Override
     @PostMapping("/updateTargetFormId")
-    public RPCBaseResponse<ShopUnitVo> updateTargetFormId(ShopUnitDto entity) {
+    public RPCBaseResponse<ShopUnitVo> updateTargetFormId(@RequestBody ShopUnitDto entity) {
         ShopUnit shopUnit = new ShopUnit();
         BeanUtils.copyProperties(entity, shopUnit);
         RPCBaseResponse<ShopUnit> shopUnitRPCBaseResponse = super.updateTargetById(shopUnit);
@@ -99,7 +99,7 @@ public class ShopUnitController extends BaseController<ShopUnit> implements Shop
      */
     @Override
     @PostMapping("/saveFormTarget")
-    public RPCBaseResponse<ShopUnitVo> saveFormTarget(ShopUnitDto entity) {
+    public RPCBaseResponse<ShopUnitVo> saveFormTarget(@RequestBody ShopUnitDto entity) {
         ShopUnit shopUnit = new ShopUnit();
         BeanUtils.copyProperties(entity, shopUnit);
         RPCBaseResponse<ShopUnit> shopUnitRPCBaseResponse = super.saveTarget(shopUnit);
@@ -115,7 +115,7 @@ public class ShopUnitController extends BaseController<ShopUnit> implements Shop
      */
     @Override
     @PostMapping("/deleteFormTarget")
-    public RPCBaseResponse<ShopUnitVo> deleteTargetFormId(List<String> ids) {
+    public RPCBaseResponse<ShopUnitVo> deleteTargetFormId(@RequestBody List<String> ids) {
         RPCBaseResponse<ShopUnit> shopUnitRPCBaseResponse = super.deleteTargetById(ids);
         RPCBaseResponse<ShopUnitVo> shopUnitVoRPCBaseResponse = new RPCBaseResponse<>();
         BeanUtils.copyProperties(shopUnitRPCBaseResponse, shopUnitVoRPCBaseResponse);

+ 6 - 0
edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/service/BaseCountryService.java

@@ -4,9 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import edu.travel.country.entity.BaseCountry;
 import edu.travel.dto.BaseCountryDto;
+import edu.travel.dto.BaseCountryServeDto;
 import edu.travel.rpc.RPCBaseResponse;
+import edu.travel.vo.BaseCountryServeVo;
 import edu.travel.vo.BaseCountryVo;
+import org.springframework.web.bind.annotation.RequestBody;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 public interface BaseCountryService extends IService<BaseCountry> {
@@ -15,4 +19,6 @@ public interface BaseCountryService extends IService<BaseCountry> {
     RPCBaseResponse<IPage<BaseCountryVo>> getCountryPage(BaseCountryDto baseCountryDTO);
 //国家树
     RPCBaseResponse<List<BaseCountryVo>> getCountryTree();
+
+    RPCBaseResponse<BaseCountryServeVo> saveFormTargetNew(@RequestBody BaseCountryServeDto entity, HttpServletRequest request);
 }

+ 54 - 1
edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/service/impl/BaseCountryServiceImpl.java

@@ -1,18 +1,29 @@
 package edu.travel.country.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import edu.travel.country.entity.BaseCountryServe;
+import edu.travel.country.mapper.BaseCountryServeMapper;
 import edu.travel.dto.BaseCountryDto;
+import edu.travel.dto.BaseCountryServeDto;
 import edu.travel.rpc.RPCBaseResponse;
 import edu.travel.service.SysServiceImpl;
+import edu.travel.vo.BaseCountryServeVo;
 import edu.travel.vo.BaseCountryVo;
 import org.springframework.beans.BeanUtils;
 import edu.travel.country.entity.BaseCountry;
 import edu.travel.country.mapper.BaseCountryMapper;
 import edu.travel.country.service.BaseCountryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -20,7 +31,8 @@ import java.util.Map;
 
 @Service
 public class BaseCountryServiceImpl extends SysServiceImpl<BaseCountryMapper, BaseCountry> implements BaseCountryService {
-
+@Autowired
+    private BaseCountryServeMapper baseCountryServeMapper;
     @Override
     public RPCBaseResponse<IPage<BaseCountryVo>> getCountryPage(BaseCountryDto baseCountryDto) {
         Page<BaseCountry> baseCountryPage = new Page<>(baseCountryDto.getCurrentPage(), baseCountryDto.getPageSize());
@@ -46,6 +58,47 @@ public class BaseCountryServiceImpl extends SysServiceImpl<BaseCountryMapper, Ba
         return new RPCBaseResponse<>(200,"SUCCESS",BaseCountryTree);
     }
 
+    @Override
+    public RPCBaseResponse<BaseCountryServeVo> saveFormTargetNew(BaseCountryServeDto entity, HttpServletRequest request) {
+        // 创建 BaseCountryServe 对象
+        BaseCountryServe baseCountryServe = new BaseCountryServe();
+
+        // 使用 BeanUtils 复制属性
+        BeanUtils.copyProperties(entity, baseCountryServe);
+
+        // 从请求头获取 Project
+        String project = request.getHeader("Project");
+        baseCountryServe.setProject(project); // 设置 Project
+
+        // 获取当前登录用户并设置 create_user_id
+        Long currentUserId = getCurrentUserId();
+        baseCountryServe.setCreateUserId(String.valueOf(currentUserId));
+
+        baseCountryServeMapper.insert(baseCountryServe);
+        // 创建返回的 RPCBaseResponse
+        RPCBaseResponse<BaseCountryServeVo> baseCountryServeVoRPCBaseResponse = new RPCBaseResponse<>();
+        BaseCountryServeVo baseCountryServeVo = new BaseCountryServeVo();
+        BeanUtils.copyProperties(baseCountryServe, baseCountryServeVo); // 复制属性到 VO
+        baseCountryServeVoRPCBaseResponse.setData(baseCountryServeVo); // 设置返回数据
+
+        return baseCountryServeVoRPCBaseResponse;
+    }
+
+    // 获取当前用户 ID 的方法
+    private Long getCurrentUserId() {
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+        Object principal = authentication.getPrincipal();
+        Long userId = null;
+
+        if (!(principal instanceof String && "anonymousUser".equals(principal))) {
+            String jsonString = JSON.toJSONString(principal);
+            JSONObject jsonObject = JSON.parseObject(jsonString);
+            userId = jsonObject.getLong("id");
+        }
+
+        return userId;
+    }
+
     //树构建方法
     private List<BaseCountryVo> buildCountryTree(List<BaseCountry> baseCountryList) {
         //map,快速查找国家VO对象

+ 21 - 3
edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/web/BaseCountryServeController.java

@@ -1,10 +1,12 @@
 package edu.travel.country.web;
 
 
-import cn.hutool.db.Page;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import edu.travel.country.entity.BaseCountryServe;
 import edu.travel.country.service.BaseCountryServeService;
+import edu.travel.country.service.BaseCountryService;
 import edu.travel.dto.BaseCountryServeDto;
 import edu.travel.dto.BaseCountryServeStatusDto;
 import edu.travel.remote.BaseCountryServeRemoteController;
@@ -14,8 +16,11 @@ import edu.travel.vo.BaseCountryServeVo;
 import edu.travel.web.BaseController;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 /**
@@ -32,6 +37,8 @@ public class BaseCountryServeController extends BaseController<BaseCountryServe>
      */
     @Autowired
     private BaseCountryServeService baseCountryServeService;
+    @Autowired
+    private BaseCountryService baseCountryService;
 
     /**
      * 分页连表
@@ -101,11 +108,22 @@ public class BaseCountryServeController extends BaseController<BaseCountryServe>
     public RPCBaseResponse<BaseCountryServeVo> saveFormTarget(@RequestBody BaseCountryServeDto entity) {
         BaseCountryServe baseCountryServe = new BaseCountryServe();
         BeanUtils.copyProperties(entity, baseCountryServe);
-        RPCBaseResponse<BaseCountryServe> baseCountryServeRPCBaseResponse = super.saveTarget(baseCountryServe);
+        boolean save = baseCountryServeService.save(baseCountryServe);
         RPCBaseResponse<BaseCountryServeVo> baseCountryServeVoRPCBaseResponse = new RPCBaseResponse<>();
-        BeanUtils.copyProperties(baseCountryServeRPCBaseResponse, baseCountryServeVoRPCBaseResponse);
+        BaseCountryServeVo countryServeVo = new BaseCountryServeVo();
+        BeanUtils.copyProperties(baseCountryServe, countryServeVo);
+        baseCountryServeVoRPCBaseResponse.setCode(200);
+        baseCountryServeVoRPCBaseResponse.setMsg("");
+        baseCountryServeVoRPCBaseResponse.setData(countryServeVo);
         return baseCountryServeVoRPCBaseResponse;
     }
+    /**
+     *新增服务国家信息(new)
+     */
+    @PostMapping("/saveFormTargetNew")
+    public RPCBaseResponse<BaseCountryServeVo> saveFormTargetNew(@RequestBody BaseCountryServeDto entity, HttpServletRequest request) {
+        return baseCountryService.saveFormTargetNew(entity, request);
+    }
 
     /**
      * 删除服务国家信息