From 640d1ebf2b738440ab16f8e8954bfeed1472a3b3 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期五, 29 十二月 2023 17:59:26 +0800
Subject: [PATCH] 接口所有代码

---
 guns-admin/src/main/java/com/stylefeng/guns/modular/api/AppUserController.java |  130 ++++++++++++++++++++++++++++++------------
 1 files changed, 92 insertions(+), 38 deletions(-)

diff --git a/guns-admin/src/main/java/com/stylefeng/guns/modular/api/AppUserController.java b/guns-admin/src/main/java/com/stylefeng/guns/modular/api/AppUserController.java
index ec49227..f52a002 100644
--- a/guns-admin/src/main/java/com/stylefeng/guns/modular/api/AppUserController.java
+++ b/guns-admin/src/main/java/com/stylefeng/guns/modular/api/AppUserController.java
@@ -1,5 +1,6 @@
 package com.stylefeng.guns.modular.api;
 
+import com.alibaba.druid.sql.visitor.functions.If;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -8,6 +9,7 @@
 import com.stylefeng.guns.modular.system.service.*;
 import com.stylefeng.guns.modular.system.service.impl.FeedBackServiceImpl;
 import com.stylefeng.guns.modular.system.service.impl.HouseTypeServiceImpl;
+import com.stylefeng.guns.modular.system.util.HttpUtils;
 import com.stylefeng.guns.modular.system.util.Page;
 import com.stylefeng.guns.modular.system.util.ResultUtil;
 import com.stylefeng.guns.modular.system.warpper.req.*;
@@ -49,6 +51,8 @@
     private IRegionService regionService;
     @Autowired
     private IBannerService bannerService;
+    @Autowired
+    private IReportHouseResourceService reportHouseResource;
     @ResponseBody
     @GetMapping("/base/appUser/agreement")
     @ApiOperation(value = "协议", tags = {"协议"})
@@ -56,12 +60,12 @@
         Banner banners = bannerService.selectOne(new EntityWrapper<Banner>().eq("position",type));
         return ResultUtil.success(banners);
     }
+
     @ResponseBody
     @PostMapping("/base/appUser/appletLogin")
     @ApiOperation(value = "微信小程序登录", tags = {"登录注册"})
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "jscode", value = "微信jscode", required = true)
-    })
+            @ApiImplicitParam(name = "jscode", value = "微信jscode", required = true)})
     public ResultUtil<AppletLoginRes> appletLogin(String jscode,String encryptedPhoneData,String phoneIv){
         RegisterAccountReq req = new RegisterAccountReq();
         req.setJscode(jscode);
@@ -85,7 +89,6 @@
             @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
     })
     public ResultUtil<AppUser> userInfo(){
-
         return appUserService.userInfo();
     }
 
@@ -124,29 +127,33 @@
             }
             if (housingDemand.getHouseTypeId()!=null && (!housingDemand.getHouseTypeId().equals("0"))){
                 HouseType houseType = houseTypeService.selectById(housingDemand.getHouseTypeId());
-                housingDemand.setHouseTypeName(houseType.getName());
+                if (houseType!=null){
+                    housingDemand.setHouseTypeName(houseType.getName());
+                }
             }
             if (housingDemand.getHouseTypeId()!=null && housingDemand.getHouseTypeId().equals("0")){
                 housingDemand.setHouseTypeName("不限");
             }
+            housingDemand.setUpdateTime(new Date());
             // 查询求房源选择的区域
             return ResultUtil.success(housingDemand);
         }else{
             HouseResource houseResource = houseResourceService.selectById(id);
             if (houseResource.getHouseTypeId()!=null){
                 HouseType houseType = houseTypeService.selectById(houseResource.getHouseTypeId());
-                houseResource.setHouseTypeName(houseType.getName());
+                if (houseType!=null)houseResource.setHouseTypeName(houseType.getName());
             }
             if (houseResource.getCityId()!=null){
                 Region region = regionService.selectById(houseResource.getCityId());
-                houseResource.setCityName(region.getName());
+                if (region!=null)houseResource.setCityName(region.getName());
             }
             if (houseResource.getDistrictId()!=null && houseResource.getDistrictId()==0){
                 houseResource.setDistrictName("不限");
             }else{
                 Region region = regionService.selectById(houseResource.getDistrictId());
-                houseResource.setDistrictName(region.getName());
+                if (region!=null)houseResource.setDistrictName(region.getName());
             }
+            houseResource.setUpdateTime(new Date());
             return ResultUtil.success(houseResource);
         }
     }
@@ -157,17 +164,68 @@
     @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....",
             required = true, paramType = "header")
     public ResultUtil auth(@RequestBody AuthDTO dto){
-        AppUser appUser1 = appUserService.getAppUser();
-        appUser1.setAgentLicenceCode(dto.getAgentLicenceCode());
-        appUser1.setCompanyName(dto.getCompanyName());
-        appUser1.setCompanyAddress(dto.getCompanyAddress());
-        appUser1.setBusinessCardPhoto(dto.getBusinessCardPhoto());
-        appUser1.setCityId(dto.getCityId());
-        appUser1.setDistrictId(dto.getDistrictId());
-        appUser1.setAuth(1);
-        appUser1.setPhone(dto.getPhone());
-        appUserService.updateById(appUser1);
+        AppUser appUser = appUserService.getAppUser();
+        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
+            return ResultUtil.errorLogin("当前账号已被冻结或删除");
+        }
+        appUser.setAgentLicenceCode(dto.getAgentLicenceCode());
+        appUser.setCompanyName(dto.getCompanyName());
+        appUser.setCompanyAddress(dto.getCompanyAddress());
+        appUser.setBusinessCardPhoto(dto.getBusinessCardPhoto());
+        appUser.setCityId(dto.getCityId());
+        appUser.setDistrictId(dto.getDistrictId());
+        appUser.setAuth(1);
+        appUserService.updateById(appUser);
         return ResultUtil.success();
+    }
+    @ResponseBody
+    @PostMapping("/base/appUser/authInfo")
+    @ApiOperation(value = "中介认证信息", tags = {"个人中心"})
+    @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....",
+            required = true, paramType = "header")
+    public ResultUtil authInfo(){
+        AppUser appUser = appUserService.getAppUser();
+        AppUserDTO appUserDTO = new AppUserDTO();
+        BeanUtils.copyProperties(appUser,appUserDTO);
+        if (appUser.getCityId()!=null){
+            Region region = regionService.selectById(appUser.getCityId());
+            appUserDTO.setCityName(region.getName());
+        }
+        if (appUser.getDistrictId()!=null){
+            Region region = regionService.selectById(appUser.getDistrictId());
+            appUserDTO.setDistrictName(region.getName());
+        }
+        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
+            return ResultUtil.errorLogin("当前账号已被冻结或删除");
+        }
+        return ResultUtil.success(appUserDTO);
+    }
+
+
+
+    /**
+     *地图查询
+     */
+    @ResponseBody
+    @ApiOperation(value = "地图查询", tags = {"个人中心"})
+    @GetMapping("/base/appUser/queryMap")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name", value = "位置", required = true)
+    })
+    public ResultUtil queryMap(String name)
+    {
+        String url ="https://apis.map.qq.com/ws/geocoder/v1/?address="+name+"&key=AAIBZ-NO7AQ-RKQ5G-2YSBL-3MEJH-VTFH4";
+        String result = HttpUtils.sendGet(url);
+        JSONArray data = JSONObject.parseObject(result).getJSONArray("data");
+        return ResultUtil.success(data);
+    }
+
+    public static void main(String[] args) {
+        String url ="https://apis.map.qq.com/ws/place/v1/suggestion/?keyword="+"四川省成都市青羊区大墙西街72号"+"&key=AAIBZ-NO7AQ-RKQ5G-2YSBL-3MEJH-VTFH4";
+        String result = HttpUtils.sendGet(url);
+        System.err.println(result);
+        JSONArray data = JSONObject.parseObject(result).getJSONArray("data");
+        System.err.println("返回结果:"+data);
     }
 //    // todo 放行
 //    @ResponseBody
@@ -201,6 +259,9 @@
     @ApiOperation(value = "发布-删除/下架/顶上去/上架", tags = {"个人中心"})
     public ResultUtil delete(@RequestBody UserInfoDTO dto){
         AppUser appUser = appUserService.getAppUser();
+        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
+            return ResultUtil.errorLogin("当前账号已被冻结或删除");
+        }
         Integer id = appUser.getId();
         if (dto.getData() == 2){
         switch (dto.getType()){
@@ -221,29 +282,14 @@
                 houseResourceService.updateById(houseResource2);
                 break;
             case 4:
-                if (appUser.getAuth()!=2){
-                    // 未认证 只能能发布三条房源信息
-                    List<HouseResource> houseResources = houseResourceService.selectList(new EntityWrapper<HouseResource>()
-                            .eq("app_user_id", id)
-                            .eq("is_delete", 1)
-                            .eq("status", 1)
-                    );
-                    if (houseResources.size()>=3){
-                        return ResultUtil.error("中介账号未认证,只能同时上架3条房源信息");
-                    }
-                }else if (appUser.getAuth()==1){
-                    // 已经认证 只能能发布20条房源信息
-                    List<HouseResource> houseResources = houseResourceService.selectList(new EntityWrapper<HouseResource>()
-                            .eq("app_user_id", id)
-                            .eq("is_delete", 1)
-                            .eq("status", 1)
-                    );
-                    if (houseResources.size()>=20){
-                        return ResultUtil.error("当前中介账号只能同时上架20条房源信息");
-                    }
-                }
+                // 判断当前房源是否有被举报的记录
+                int size = reportHouseResource.selectList(new EntityWrapper<ReportHouseResource>()
+                        .eq("house_resource_id", dto.getId())
+                        .eq("audit", 0)).size();
+                if (size>0)return ResultUtil.errorAdd("当前房源被举报,暂时不能上架");
                 HouseResource houseResource3 = houseResourceService.selectById(dto.getId());
                 houseResource3.setStatus(1);
+                houseResource3.setAuthStatus(2);
                 houseResourceService.updateById(houseResource3);
                 break;
         }
@@ -262,6 +308,7 @@
                 case 3:
                     HousingDemand houseResource2 = housingDemandService.selectById(dto.getId());
                     houseResource2.setInsertTime(new Date());
+                    houseResource2.setUpTime(new Date());
                     housingDemandService.updateById(houseResource2);
                     break;
                 case 4:
@@ -282,6 +329,10 @@
     @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....",
             required = true, paramType = "header")
     public ResultUtil feedback(@RequestBody FeedBack feedBack){
+        AppUser appUser = appUserService.getAppUser();
+        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
+            return ResultUtil.errorLogin("当前账号已被冻结或删除");
+        }
         feedBack.setAppUserId(appUserService.getAppUser().getId());
         feedBack.setInsertTime(new Date());
         feedBackService.insert(feedBack);
@@ -296,6 +347,9 @@
             required = true, paramType = "header")
     public ResultUtil update(@RequestBody UpdateAppUser user){
         AppUser appUser = appUserService.getAppUser();
+        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
+            return ResultUtil.errorLogin("当前账号已被冻结或删除");
+        }
         if (StringUtils.hasLength(user.getProfilePhoto())){
             appUser.setProfilePhoto(user.getProfilePhoto());
         }

--
Gitblit v1.7.1