44323
2023-12-29 640d1ebf2b738440ab16f8e8954bfeed1472a3b3
接口所有代码
36个文件已修改
1个文件已删除
2个文件已添加
1981 ■■■■ 已修改文件
guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/api/AppUserController.java 130 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/api/BannerController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/api/EncyclopedicKnowledgeController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/api/FileController.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/api/HouseResourceController.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/api/HousingDemandController.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/AppUserMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/BannerMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/HouseResourceMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/AppUserMapper.xml 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/BannerMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml 243 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/HousingDemandMapper.xml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/AppUser.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/AppUserDTO.java 145 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/HouseResource.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/HousingDemand.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/IBannerService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/AppUserServiceImpl.java 275 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/BannerServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java 182 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java 252 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReportHouseResourceServiceImpl.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/HttpUtils.java 263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ResultUtil.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtilHouseResource.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/weChat/WeChatUtil.java 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/req/AddHouseReq.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/req/HousingDemandReq.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/req/SearchHouseResourceReq.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/AppletLoginRes.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/CollectListRes.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/ContactInformationRes.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/HouseResourceInfoRes.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/HousingDemandInfoRes.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/SearchHouseResourceListRes.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/SearchHousingDemandListRes.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/resources/application-dev.yml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java
@@ -31,7 +31,6 @@
    private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class);
    public static void main(String[] args) {
        SpringApplication.run(GunsApplication.class, args);
        logger.info("GunsApplication is success!");
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());
        }
guns-admin/src/main/java/com/stylefeng/guns/modular/api/BannerController.java
@@ -33,8 +33,8 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "position", value = "位置(1=首页,6=租房,7=买房,8=公司盘,9=求房源)", required = true)
    })
    public ResultUtil<List<BannerRes>> getBanners(Integer position){
        List<BannerRes> banners = bannerService.getBanners(position);
    public ResultUtil<BannerRes> getBanners(Integer position){
        BannerRes banners = bannerService.getBanner(position);
        return ResultUtil.success(banners);
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/api/EncyclopedicKnowledgeController.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.modular.api;
import com.stylefeng.guns.modular.system.model.AppUser;
import com.stylefeng.guns.modular.system.model.EncyclopedicKnowledge;
import com.stylefeng.guns.modular.system.model.SysDataType;
import com.stylefeng.guns.modular.system.service.IAppUserService;
@@ -31,6 +32,8 @@
    @Autowired
    private ISysDataTypeService sysDataTypeService;
    @Autowired
    private IAppUserService appUserService;
    @ResponseBody
@@ -69,6 +72,7 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = false, paramType = "header")
    })
    public ResultUtil<EncyclopedicKnowledgeInfoRes> getEncyclopedicKnowledgeInfo(Integer id){
        EncyclopedicKnowledgeInfoRes encyclopedicKnowledgeInfo = encyclopedicKnowledgeService.getEncyclopedicKnowledgeInfo(id);
        return ResultUtil.success(encyclopedicKnowledgeInfo);
    }
@@ -82,6 +86,10 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil upvoteEncyclopedicKnowledge(Integer id){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return encyclopedicKnowledgeService.upvoteEncyclopedicKnowledge(id);
    }
guns-admin/src/main/java/com/stylefeng/guns/modular/api/FileController.java
@@ -1,12 +1,16 @@
package com.stylefeng.guns.modular.api;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.OSSObject;
import com.aliyun.oss.model.ObjectMetadata;
import com.aliyun.oss.model.PutObjectRequest;
import com.aliyun.oss.model.PutObjectResult;
import com.stylefeng.guns.modular.file.OSSService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -18,14 +22,28 @@
@RestController
@RequestMapping("")
public class FileController {
    @Autowired
    private OSSService ossService;
    private static final String endpoint = "oss-cn-hongkong.aliyuncs.com";
    private static final String accessKeyId = "LTAI5tQZzqsZYX5gw8yRNchQ";
    private static final String accessKeySecret = "5yJVdXwRzwPZwKKXp07lRAc7tkTxQp";
    private static final String bucketName = "bizuphk";
    @PostMapping("/base/files/upload")
    @ApiOperation(value = "文件上传", tags = {"文件上传"})
    public String uploadFile(@RequestParam("file") MultipartFile file) {
        return ossService.uploadFile(file);
    public String uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
            // 创建 OSSClient 实例
            OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
        long l = System.currentTimeMillis();
        // 创建 PutObjectRequest 对象
            PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, String.valueOf(l), file.getInputStream());
            ObjectMetadata metadata = new ObjectMetadata();
            // 取消文件缓存,文件每次都会从OSS服务器获取
            metadata.setHeader("Cache-Control", "no-cache");
            metadata.setHeader("Expires", "0");
            // 上传文件
            PutObjectResult putObjectResult = ossClient.putObject(putObjectRequest);
            // 关闭 OSSClient 实例
            ossClient.shutdown();
            String fileUrl = "https://" + bucketName + "." + endpoint + "/" + String.valueOf(l);
            return fileUrl;
    }
//    @ApiOperation(value = "服务端上传", notes = "服务端上传")
guns-admin/src/main/java/com/stylefeng/guns/modular/api/HouseResourceController.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.api;
import com.alipay.api.internal.util.codec.Base64;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.modular.file.OSSService;
import com.stylefeng.guns.modular.system.model.AppUser;
import com.stylefeng.guns.modular.system.model.HouseResource;
@@ -117,7 +118,26 @@
    @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....",
            required = true, paramType = "header")
    public ResultUtil confirm(Integer userType){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return houseResourceService.confirm(userType);
    }
    @ResponseBody
    @PostMapping("/base/addHouse/userInfo")
    @ApiOperation(value = "发布房源获取当前人的中介认证状态", tags = {"发布"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil userInfo(){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        Integer auth = appUserService.getAppUser().getAuth();
        return ResultUtil.success(appUser);
    }
    @ResponseBody
@@ -127,6 +147,10 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil addHouse(@RequestBody AddHouseReq req){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return houseResourceService.addHouse(req);
    }
@@ -158,7 +182,6 @@
        return ResultUtil.success(districtHouseResourceNumber);
    }
    @ResponseBody
    @PostMapping("/base/houseResource/getHouseResourceInfo")
    @ApiOperation(value = "获取房源详情", tags = {"详情"})
@@ -171,7 +194,6 @@
        return ResultUtil.success(houseResourceInfo);
    }
    @ResponseBody
    @PostMapping("/base/houseResource/collectionHouseResource")
    @ApiOperation(value = "收藏/取消收藏房源操作", tags = {"详情"})
@@ -180,10 +202,12 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil collectionHouseResource(Integer id){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return collectionHouseResourceService.collectionHouseResource(id);
    }
    @ResponseBody
    @GetMapping("/base/houseResource/getNearbyHouseResource")
@@ -195,7 +219,6 @@
        List<SearchHouseResourceListRes> nearbyHouseResource = houseResourceService.getNearbyHouseResource(id);
        return ResultUtil.success(nearbyHouseResource);
    }
    @ResponseBody
    @GetMapping("/base/houseResource/getContactInformation/{id}")
@@ -212,8 +235,13 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil addReportHouseResource(@RequestBody ReportHouseResourceReq req){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return reportHouseResourceService.addReportHouseResource(req);
    }
    @ResponseBody
    @PostMapping("/base/intermediary/list")
    @ApiOperation(value = "找中介", tags = {"服务"})
@@ -221,6 +249,7 @@
        SearchIntermediaryRes res= appUserService.searchIntermediaryList(req);
        return ResultUtil.success(res);
    }
    @ResponseBody
    @PostMapping("/base/intermediary/intermediaryInfo")
    @ApiOperation(value = "找中介-中介信息", tags = {"服务"})
@@ -241,6 +270,7 @@
        }
        return ResultUtil.success(res);
    }
    @ResponseBody
    @GetMapping("/base/intermediary/getContactInfo/{id}")
    @ApiOperation(value = "获取中介联系方式", tags = {"详情"})
@@ -265,7 +295,11 @@
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil<Integer> getSurplusPushNumber1(){
    public ResultUtil getSurplusPushNumber1(){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return houseResourceService.getSurplusPushNumber1();
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/api/HousingDemandController.java
@@ -1,7 +1,9 @@
package com.stylefeng.guns.modular.api;
import com.stylefeng.guns.modular.system.model.AppUser;
import com.stylefeng.guns.modular.system.model.HouseResource;
import com.stylefeng.guns.modular.system.model.HousingDemand;
import com.stylefeng.guns.modular.system.service.IAppUserService;
import com.stylefeng.guns.modular.system.service.ICollectionHousingDemandService;
import com.stylefeng.guns.modular.system.service.IHousingDemandService;
import com.stylefeng.guns.modular.system.service.IReportHousingDemandService;
@@ -35,6 +37,8 @@
    private IReportHousingDemandService reportHousingDemandService;
    @Autowired
    private ICollectionHousingDemandService collectionHousingDemandService;
    @Autowired
    private IAppUserService appUserService;
    @ResponseBody
@@ -52,6 +56,10 @@
    })
    public ResultUtil addHousingDemand(@RequestBody HousingDemandReq req){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return housingDemandService.addHousingDemand(req);
    }
@@ -71,10 +79,13 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil<HousingDemandInfoRes> housingDemandInfo(Integer id){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        HousingDemandInfoRes housingDemandInfoRes = housingDemandService.housingDemandInfo(id);
        return ResultUtil.success(housingDemandInfoRes);
    }
    @ResponseBody
    @PostMapping("/base/housingDemand/addReportHousingDemand")
@@ -83,16 +94,24 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil addReportHousingDemand(ReportHousingDemandReq req){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return reportHousingDemandService.addReportHousingDemand(req);
    }
    @ResponseBody
    @PostMapping("/base/housingDemand/collectionHousingDemand")
    @PostMapping("/api/housingDemand/collectionHousingDemand")
    @ApiOperation(value = "收藏/取消收藏房源操作", tags = {"求房源"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil collectionHousingDemand(Integer id){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return collectionHousingDemandService.collectionHousingDemand(id);
    }
@@ -111,8 +130,10 @@
            @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header")
    })
    public ResultUtil<Integer> getSurplusPushNumber(){
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return housingDemandService.getSurplusPushNumber();
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/AppUserMapper.java
@@ -15,6 +15,9 @@
    List<SearchIntermediaryListRes>  searchIntermediaryList(@Param("req") SearchIntermediaryReq req,
                                                 @Param("districtIds") List<Integer> districtIds,
                                                 @Param("cityIds")List<Integer> cityIds);
    List<SearchIntermediaryListRes>  searchIntermediaryList1(@Param("req") SearchIntermediaryReq req,
                                                 @Param("districtIds") List<Integer> districtIds,
                                                 @Param("cityIds")List<Integer> cityIds);
    SearchIntermediaryListRes searchIntermediaryInfo(@Param("id")Integer id);
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/BannerMapper.java
@@ -18,5 +18,5 @@
     * @param position
     * @return
     */
    List<BannerRes> getBanners(Integer position);
    BannerRes getBanner(Integer position);
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/HouseResourceMapper.java
@@ -27,6 +27,14 @@
    List<SearchHouseResourceListRes> searchHouseResource(@Param("req") SearchHouseResourceReq req, @Param("cityIds") List<Integer> cityIds,
                                                         @Param("districtIds") List<Integer> districtIds,
                                                         @Param("saleAmountStart") Double saleAmountStart, @Param("saleAmountEnd") Double saleAmountEnd,
                                                         @Param("houseModels") List<String> houseModels, @Param("houseTypeIds") List<Integer> houseTypeIds);/**
     * 获取房源列表数据
     * @param req
     * @return
     */
    List<SearchHouseResourceListRes> searchHouseResource1(@Param("req") SearchHouseResourceReq req, @Param("cityIds") List<Integer> cityIds,
                                                         @Param("districtIds") List<Integer> districtIds,
                                                         @Param("saleAmountStart") Double saleAmountStart, @Param("saleAmountEnd") Double saleAmountEnd,
                                                         @Param("houseModels") List<String> houseModels, @Param("houseTypeIds") List<Integer> houseTypeIds);
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/AppUserMapper.xml
@@ -9,9 +9,52 @@
        COUNT(t2.id) AS houseCount
        from t_app_user t1
        left join t_house_resource t2 on t1.id = t2.insert_user_id
        and t2.auth_status = 2
        and t2.is_delete = 0
        and t2.status = 1
        and t2.type = 2
        <where>
            <if test="null != req.name and '' != req.name">
                and t1.nickname like CONCAT('%', #{req.name}, '%')
                or t1.company_name like CONCAT('%', #{req.name}, '%')
            </if>
            <if test="null != districtIds and districtIds.size()>0">
                and t1.city_id in
                <foreach collection="districtIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            <if test="null != cityIds and cityIds.size()>0">
                and t1.district_id in
                <foreach collection="cityIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </if>
            and t1.auth = 2
            and t1.status = 1
            and t1.user_type = 3
        </where>
        group by t1.id
        order by houseCount desc
        limit #{req.pageNum}, #{req.pageSize}
    </select>
    <select id="searchIntermediaryList1"
            resultType="com.stylefeng.guns.modular.system.warpper.res.SearchIntermediaryListRes">
        select t1.id,t1.profile_photo as profilePhoto,t1.nickname as nickname,t1.company_name as companyName,
        t1.company_address as companyAddress,t1.introduce as introduce,t1.phone as phone,
        COUNT(t2.id) AS houseCount
        from t_app_user t1
        left join t_house_resource t2 on t1.id = t2.insert_user_id
        and t2.auth_status = 2
        and t2.is_delete = 0
        and t2.status = 1
        and t2.type = 2
        <where>
            <if test="null != req.name and '' != req.name">
                and t1.nickname like CONCAT('%', #{req.name}, '%')
                or t1.company_name like CONCAT('%', #{req.name}, '%')
            </if>
            <if test="null != cityIds and cityIds.size()>0">
                and t1.district_id in
@@ -28,10 +71,6 @@
            and t1.auth = 2
            and t1.status = 1
            and t1.user_type = 3
            and t2.auth_status = 2
            and t2.is_delete = 0
            and t2.status = 1
            and t2.type=2
        </where>
        group by t1.id
        order by houseCount desc
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/BannerMapper.xml
@@ -3,8 +3,7 @@
<mapper namespace="com.stylefeng.guns.modular.system.dao.BannerMapper">
    <select id="getBanners" resultType="com.stylefeng.guns.modular.system.warpper.res.BannerRes">
    <select id="getBanner" resultType="com.stylefeng.guns.modular.system.warpper.res.BannerRes">
        select id, img_url as imgUrl, content from t_banner where `position` = #{position} order by `sort` desc
    </select>
</mapper>
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml
@@ -17,26 +17,39 @@
        hr.latitude,
        hr.platform,
        hr.sale_amount as saleAmount,
        IFNULL(su.`name`,au.nickname) as nickname,
         IFNULL(au.profile_photo,su.avatar) as profilePhoto,
        au.profile_photo as profilePhoto,
        au.nickname,
        hr.elevator,
        hr.drying_area as dryingArea,
        hr.garden,
        hr.carport,
        hr.air,
        hr.balcony,
        hr.is_manage as isManage,
        hr.leaseTime,
        tp.name as houseTypeName,
        hr.keep_pet as keepPet
        from t_house_resource hr
        left join t_app_user au on (hr.app_user_id = au.id)
        LEFT JOIN sys_user su ON hr.insert_user_id = su.id AND hr.is_manage = 1
        left join t_region rc on (hr.district_id = rc.id)
        left join t_region rp on (rp.id = rc.parent_id)
        left join t_house_type tp on hr.house_type_id = tp.id
        where hr.is_delete = 0 and hr.`status` = 1 and hr.auth_status = 2 and hr.type=2
        <if test="null != req.type">
        <if test="null != req.type and 2 == req.type">
            and hr.data_type = #{req.type}
        </if>
        <if test="null != req.userType and 4 != req.userType">
            and au.user_type = #{req.userType}
        <if test="null != req.type and 1 == req.type">
            and hr.data_type = #{req.type}
        </if>
        <if test="null != req.userType and 2 == req.userType">
            and au.user_type = 2
        </if>
        <if test="null != req.userType and 3 == req.userType">
            and au.user_type = 3
        </if>
        <if test="null == req.userType">
            and hr.firm_house != 1
        </if>
        <if test="null != req.userType and 4 == req.userType">
            and hr.firm_house = 1
@@ -102,53 +115,80 @@
            and hr.good_house = 1
        </if>
        <if test="null != req.dataType and req.dataType == 2">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 7 day)
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 21 day)
        </if>
        order by au.user_type desc
        <if test="null != req.sort and req.sort == 1">
            order by hr.insert_time desc
            ,hr.insert_time desc
        </if>
        <if test="null != req.sort and req.sort == 2">
            order by hr.good_house desc
            , hr.views_number desc
        </if>
        <if test="null != req.sort and req.sort == 3">
            order by hr.sale_amount
            , hr.sale_amount
        </if>
        <if test="null != req.sort and req.sort == 4">
            order by hr.sale_amount desc
            , hr.sale_amount desc
        </if>
        order by au.user_type desc, hr.insert_time desc
        limit #{req.pageNum}, #{req.pageSize}
    </select>
    <select id="searchHouseResourceCount" resultType="int">
    <select id="searchHouseResource1" resultType="com.stylefeng.guns.modular.system.warpper.res.SearchHouseResourceListRes">
        select
        count(1)
        hr.id,
        au.user_type as houseResource,
        hr.house_photo as imgUrl,
        hr.title,
        hr.house_area as houseArea,
        hr.house_model as houseModel,
        concat(rp.`name`, rc.`name`) as address,
        hr.longitude,
        hr.latitude,
        hr.platform,
        hr.sale_amount as saleAmount,
        au.profile_photo as profilePhoto,
        au.nickname,
        hr.elevator,
        hr.drying_area as dryingArea,
        hr.garden,
        hr.carport,
        hr.air,
        hr.balcony,
        hr.leaseTime,
        hr.keep_pet as keepPet
        from t_house_resource hr
        left join t_app_user au on (hr.app_user_id = au.id)
        where hr.is_delete = 0 and hr.`status` = 1 and hr.auth_status = 2
        and hr.type=2
        <if test="null != req.type">
        left join t_region rc on (hr.district_id = rc.id)
        left join t_region rp on (rp.id = rc.parent_id)
        where hr.is_delete = 0 and hr.`status` = 1 and hr.auth_status = 2 and hr.type=2
        <if test="null != req.type and 2 == req.type">
            and hr.data_type = #{req.type}
        </if>
        <if test="null != req.userType and 4 != req.userType">
            and au.user_type = #{req.userType}
        <if test="null != req.type and 1 == req.type">
            and hr.data_type = #{req.type}
        </if>
        <if test="null != req.userType and 2 == req.userType">
            and au.user_type = 2
        </if>
        <if test="null != req.userType and 3 == req.userType">
            and au.user_type = 3
        </if>
        <if test="null == req.userType">
            and hr.firm_house != 1
        </if>
        <if test="null != req.userType and 4 == req.userType">
            and hr.firm_house = 1
        </if>
        <if test="null != req.content and '' != req.content">
            and hr.title = CONCAT('%', #{req.content}, '%')
            and hr.title like CONCAT('%', #{req.content}, '%')
        </if>
        <if test="null != cityIds and cityIds.size()>0" >
            and hr.city_id in
            and hr.district_id in
            <foreach collection="cityIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != districtIds and districtIds.size()>0">
            and hr.district_id in
            and hr.city_id in
            <foreach collection="districtIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
@@ -199,7 +239,156 @@
            and hr.good_house = 1
        </if>
        <if test="null != req.dataType and req.dataType == 2">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 21 day)
        </if>
        order by au.user_type desc
        <if test="null != req.sort and req.sort == 1">
            ,hr.insert_time desc
        </if>
        <if test="null != req.sort and req.sort == 2">
            , hr.views_number desc
        </if>
        <if test="null != req.sort and req.sort == 3">
            , hr.sale_amount
        </if>
        <if test="null != req.sort and req.sort == 4">
            , hr.sale_amount desc
        </if>
    </select>
    <select id="searchHouseResourceCount" resultType="int">
        select
        hr.id,
        au.user_type as houseResource,
        hr.house_photo as imgUrl,
        hr.title,
        hr.house_area as houseArea,
        hr.house_model as houseModel,
        concat(rp.`name`, rc.`name`) as address,
        hr.longitude,
        hr.latitude,
        hr.platform,
        hr.sale_amount as saleAmount,
        au.profile_photo as profilePhoto,
        au.nickname,
        hr.elevator,
        hr.drying_area as dryingArea,
        hr.garden,
        hr.carport,
        hr.air,
        hr.balcony,
        hr.leaseTime,
        hr.keep_pet as keepPet
        from t_house_resource hr
        left join t_app_user au on (hr.app_user_id = au.id)
        left join t_region rc on (hr.district_id = rc.id)
        left join t_region rp on (rp.id = rc.parent_id)
        where hr.is_delete = 0 and hr.`status` = 1 and hr.auth_status = 2 and hr.type=2
        <if test="null != req.type">
            and hr.data_type = #{req.type}
        </if>
        <if test="null != req.userType and 2 == req.userType">
            and hr.is_manage != 1
        </if>
        <if test="null != req.userType and 4 != req.userType and 5 != req.userType">
            and au.user_type = #{req.userType}
        </if>
        <if test="null != req.userType and 4 == req.userType">
            and hr.firm_house = 1
        </if>
        <if test="null != req.userType and 5 == req.userType">
            and hr.firm_house = 0
        </if>
        <if test="null != req.content and '' != req.content">
            and hr.title like CONCAT('%', #{req.content}, '%')
        </if>
        <if test="null != cityIds and cityIds.size()>0" >
            and hr.district_id in
            <foreach collection="cityIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != districtIds and districtIds.size()>0">
            and hr.city_id in
            <foreach collection="districtIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != saleAmountStart and null != saleAmountEnd">
            and hr.sale_amount &gt;= #{saleAmountStart} and hr.sale_amount &lt; #{saleAmountEnd}
        </if>
        <if test="null != houseModels">
            and hr.house_model in
            <foreach collection="houseModels" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.elevator">
            and hr.elevator = #{req.elevator}
        </if>
        <if test="null != houseTypeIds">
            and hr.house_type_id in
            <foreach collection="houseTypeIds" item="item" index="index" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="null != req.rentalDuration">
            and hr.rental_duration = #{req.rentalDuration}
        </if>
        <if test="null != req.balcony">
            and hr.balcony = #{req.balcony}
        </if>
        <if test="null != req.keepPet">
            and hr.keep_pet = #{req.keepPet}
        </if>
        <if test="null != req.createTime and req.createTime == 3">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 3 day)
        </if>
        <if test="null != req.createTime and req.createTime == 7">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 7 day)
        </if>
        <if test="null != req.createTime and req.createTime == 30">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 1 MONTH)
        </if>
        <if test="null != req.createTime and req.createTime == 60">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 2 MONTH)
        </if>
        <if test="null != req.createTime and req.createTime == 90">
            and now() &lt;= DATE_ADD(hr.insert_time,INTERVAL 3 MONTH)
        </if>
        <if test="null != req.dataType and req.dataType == 1">
            and hr.good_house = 1
        </if>
        <if test="null != req.dataType and req.dataType == 2">
            order by hr.insert_time desc
            <if test="null != req.sort and req.sort == 1">
                , hr.insert_time desc
            </if>
            <if test="null != req.sort and req.sort == 2">
                , hr.good_house desc
            </if>
            <if test="null != req.sort and req.sort == 3">
                ,hr.sale_amount
            </if>
            <if test="null != req.sort and req.sort == 4">
                , hr.sale_amount desc
            </if>
            ,hr.insert_time desc, au.user_type desc
        </if>
        <if test="null == req.dataType">
            order by au.user_type desc, hr.insert_time desc
            <if test="null != req.sort and req.sort == 1">
                , hr.insert_time desc
            </if>
            <if test="null != req.sort and req.sort == 2">
                , hr.good_house desc
            </if>
            <if test="null != req.sort and req.sort == 3">
                ,hr.sale_amount
            </if>
            <if test="null != req.sort and req.sort == 4">
                , hr.sale_amount desc
            </if>
        </if>
    </select>
@@ -271,6 +460,7 @@
        hr.sale_amount as saleAmount,
        hr.elevator as elevator,
        hr.house_model as houseModel,
        hr.house_type_id as houseTypeId,
        hr.drying_area as dryingArea,
        hr.garden as garden,
        hr.carport as carport,
@@ -284,11 +474,14 @@
        hr.leaseTime as leaseTime,
        hr.data_type as dataType,
        hr.insert_time as insertTime,
        hr.auth_status as authStatus,
        hr.type as `type`,
        hr.upTime as upTime,
        tp.name as houseTypeName,
        2 as `data`,
        hr.status as status
        from t_house_resource hr
        left join t_house_type tp on hr.house_type_id = tp.id
        where hr.is_delete = 0
        and hr.app_user_id = #{id}
    </select>
@@ -315,11 +508,13 @@
        hr.insert_time as insertTime,hr.type as `type`,
        hr.status as status,
        2 as `data`,
        tp.name as houseTypeName,
        au.profile_photo as profilePhoto,
        au.nickname as nickname,
        au.user_type as userType
        from t_house_resource hr
        left join t_app_user au on hr.app_user_id = au.id
        left join t_house_type tp on hr.house_type_id = tp.id
        where hr.is_delete = 0 and hr.`status` = 1
        <if test="null != ids and ids.size()>0">
            and hr.id in
guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/HousingDemandMapper.xml
@@ -9,6 +9,7 @@
        hd.app_user_id as appuserId,
        hd.title,
        hd.house_model as houseModel,
        hd.rental_duration as rentalDuration,
        hd.sale_amount as saleAmount,
        au.profile_photo as profilePhoto,
        au.nickname,
@@ -32,14 +33,6 @@
        <if test="null != req.content and '' != req.content">
            and hd.title like CONCAT('%', #{req.content}, '%')
        </if>
        <if test="null != cityIds and cityIds.size()>0">
            and hd.id in (select housing_demand_id from t_housing_demand_district
            where t_housing_demand_district.district_id in
            <foreach collection="cityIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        <if test="null != district and district.size()>0">
            and hd.id in (select housing_demand_id from t_housing_demand_district
            where t_housing_demand_district.city_id in
@@ -48,8 +41,17 @@
            </foreach>
            )
        </if>
        <if test="null != cityIds and cityIds.size()>0">
            and hd.id in (select housing_demand_id from t_housing_demand_district
            where t_housing_demand_district.district_id in
            <foreach collection="cityIds" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
            )
        </if>
        <if test="null != saleAmountStart and null != saleAmountEnd">
            and hd.sale_amount &gt;= #{saleAmountStart} and hd.sale_amount &lt; #{saleAmountEnd}
            and CAST(SUBSTRING_INDEX(hd.sale_amount, '-', 1) AS DECIMAL) &lt;= #{saleAmountStart}
            and CAST(SUBSTRING_INDEX(hd.sale_amount, '-', -1) AS DECIMAL) >= #{saleAmountEnd}
        </if>
        <if test="null != houseModels">
            and hd.house_model in
@@ -184,6 +186,7 @@
        au.profile_photo as profilePhoto,
        au.nickname,
        hd.elevator,
        hd.house_type_id as houseTypeId,
        hd.rental_duration as rentalDuration,
        hd.drying_area as dryingArea,
        hd.garden,
@@ -195,6 +198,7 @@
        hd.data_type as dataType,
        hd.insert_time as insertTime,
        hd.type as `type`,
        hd.upTime as upTime,
        hd.keep_pet as keepPet
        from t_housing_demand hd
        left join t_app_user au on (hd.app_user_id = au.id)
@@ -208,6 +212,7 @@
        hd.app_user_id as appuserId,
        hd.title,
        hd.house_model as houseModel,
        hd.house_type_id as houseTypeId,
        hd.sale_amount as saleAmount,
        au.profile_photo as profilePhoto,
        au.nickname,
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/AppUser.java
@@ -18,6 +18,12 @@
@TableName("t_app_user")
public class AppUser {
    /**
     * 用户类型改变时间
     */
    @TableField("changeTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date changeTime;
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
@@ -128,4 +134,19 @@
     */
    @TableField("reason")
    private String reason;
    /**
     * 拒绝理由
     */
    @TableField("wechat_qr_code1")
    private String wechatQrCode1;
    /**
     * 拒绝理由
     */
    @TableField("watch_app1")
    private String watchApp1;
    /**
     * 拒绝理由
     */
    @TableField("phone1")
    private String phone1;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/AppUserDTO.java
New file
@@ -0,0 +1,145 @@
package com.stylefeng.guns.modular.system.model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
/**
* APP用户
* @author pzb
* @Date 2021/12/1 12:03
*/
@Data
@TableName("t_app_user")
public class AppUserDTO {
    /**
     * 用户类型改变时间
     */
    @TableField("changeTime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date changeTime;
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 编号
     */
    @TableField("code")
    private String code;
    /**
     * 头像
     */
    @TableField("profile_photo")
    private String profilePhoto;
    /**
     * 昵称
     */
    @TableField("nickname")
    private String nickname;
    /**
     * 用户类型(1=普通,2=房东,3=中介)
     */
    @TableField("user_type")
    private Integer userType;
    /**
     * 手机号
     */
    @TableField("phone")
    private String phone;
    /**
     * 微信openid
     */
    @TableField("wechat_openid")
    private String wechatOpenid;
    /**
     * 微信二维码
     */
    @TableField("wechat_qr_code")
    private String wechatQRCode;
    /**
     * WhatApp
     */
    @TableField("watch_app")
    private String watchApp;
    /**
     * 代理人牌照号
     */
    @TableField("agent_licence_code")
    private String agentLicenceCode;
    /**
     * 公司名称
     */
    @TableField("company_name")
    private String companyName;
    /**
     * 公司地址
     */
    @TableField("company_address")
    private String companyAddress;
    /**
     * 名片照
     */
    @TableField("business_card_photo")
    private String businessCardPhoto;
    /**
     * 审核状态(0=未认证,1=待审核,2=审核通过,3=审核拒绝)
     */
    @TableField("audit_status")
    private Integer auditStatus;
    /**
     * 审核注释
     */
    @TableField("audit_note")
    private String auditNote;
    /**
     * 状态(1=正常,2=冻结,3=删除)
     */
    @TableField("status")
    private Integer status;
    /**
     * 注册时间
     */
    @TableField("insert_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date insertTime;
    /**
     * 中介的个人简介
     */
    @TableField("introduce")
    private String introduce;
    /**
     * 中介所在公司所在的市
     */
    @TableField("city_id")
    private Integer cityId;
    /**
     * 中介所在公司所在的区
     */
    @TableField("district_id")
    private Integer districtId;
    /**
     * 中介认证审核状态 0未认证 1待审核 2已通过 3已拒绝
     */
    @TableField("auth")
    private Integer auth;
    /**
     * 拒绝理由
     */
    @TableField("reason")
    private String reason;
    /**
     * 一级区域名称
     */
    private String cityName;
    /**
     * 二级区域名称
     */
    private String districtName;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/HouseResource.java
@@ -291,4 +291,9 @@
     */
    @TableField("videoPhoto")
    private String videoPhoto;
    /**
     * 是否为后台添加的1为后台添加的
     */
    @TableField("is_manage")
    private Integer isManage;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/HousingDemand.java
@@ -87,7 +87,7 @@
    @TableField("elevator")
    private Integer elevator;
    /**
     * 是否有晾晒区(0=否,1=是)
     * 晾晒区天台(0=否,1=是)
     */
    @TableField("drying_area")
    private Integer dryingArea;
@@ -102,7 +102,7 @@
    @TableField("carport")
    private Integer carport;
    /**
     * 是否有平台(0=否,1=是)
     * 晾晒区阳台(0=否,1=是)
     */
    @TableField("balcony")
    private Integer balcony;
@@ -162,7 +162,7 @@
    @TableField("type")
    private Integer type;
    /**
     * 是否需要晾晒区
     * 晾晒区无0否1是
     */
    @TableField("air")
    private Integer air;
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/IBannerService.java
@@ -18,5 +18,5 @@
     * @param position
     * @return
     */
    List<BannerRes> getBanners(Integer position);
    BannerRes getBanner(Integer position);
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/AppUserServiceImpl.java
@@ -26,6 +26,7 @@
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
@@ -54,9 +55,8 @@
    private CollectionHouseResourceServiceImpl collectionHouseResourceService;
    @Autowired
    private ICollectionHousingDemandService collectionHousingDemandService;
    @Autowired
    private IHouseTypeService houseTypeService;
    /**
     * 通过token获取用户信息
@@ -78,11 +78,6 @@
        return null;
    }
    /**
     * 小程序登录
     * @return
@@ -97,40 +92,25 @@
                return ResultUtil.error("获取微信身份信息失败");
            }
            String openid = map.get("openid").toString();
            String sessionKey = map.get("sessionKey").toString();
            //解密手机号
            String phone = WXCore.decrypt(req.getEncryptedPhoneData(), sessionKey, req.getPhone_iv());
            JSONObject jsonObject = JSONObject.parseObject(phone);
            String phone1 = jsonObject.getString("phoneNumber");
            AppUser appUser = this.selectOne(new EntityWrapper<AppUser>()
                    .eq("wechat_openid", openid));
            if(null != appUser && appUser.getStatus() == 2){
                return ResultUtil.error("账号冻结");
                    .eq("wechat_openid", openid)
                    .eq("phone",phone1)
            .ne("status",3));
            if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
                return ResultUtil.errorLogin("当前账号已被冻结或删除");
            }
            AppletLoginRes appletLoginRes = new AppletLoginRes();
            // 当前微信号没有注册过
                if(null == appUser){
                    System.err.println("新增");
                    String sessionKey = map.get("sessionKey").toString();
                    //解密手机号
                    String phone = WXCore.decrypt(req.getEncryptedPhoneData(), sessionKey, req.getPhone_iv());
                    appUser = this.selectOne(new EntityWrapper<AppUser>()
                            .eq("phone", phone)
                            .eq("status", 1));
                        JSONObject jsonObject = JSONObject.parseObject(phone);
                        String phone1 = jsonObject.getString("phoneNumber");
                        System.err.println("看看json");
                        System.err.println(jsonObject);
                        System.err.println(phone1);
                        //注册新账号
                        appUser = addNewAppUser(openid, phone1);
                    }else{
                    String sessionKey = map.get("sessionKey").toString();
                    String phone = WXCore.decrypt(req.getEncryptedPhoneData(), sessionKey, req.getPhone_iv());
                    JSONObject jsonObject = JSONObject.parseObject(phone);
                    String phone1 = jsonObject.getString("phoneNumber");
                    appUser.setWechatOpenid(openid);
                    appUser.setPhone(phone1);
                    this.updateById(appUser);
                }
            if(null == appUser){
                //注册新账号
                appUser = addNewAppUser(openid, phone1);
            }
            //生成token
            String token = JwtTokenUtil.generateToken(appUser.getPhone());
            System.err.println("token1111--->" + token);
            appletLoginRes.setState(appUser.getAuth());
            appletLoginRes.setToken(token);
@@ -223,8 +203,9 @@
        }
        SearchIntermediaryRes searchIntermediaryRes = new SearchIntermediaryRes();
        List<SearchIntermediaryListRes> res =this.baseMapper.searchIntermediaryList(req,districtIds,cityIds);
        List<SearchIntermediaryListRes> res1 =this.baseMapper.searchIntermediaryList1(req,districtIds,cityIds);
        searchIntermediaryRes.setList(res);
        searchIntermediaryRes.setTotal(res.size());
        searchIntermediaryRes.setTotal(res1.size());
        return searchIntermediaryRes;
    }
@@ -232,6 +213,12 @@
    public ResultUtil<AppUser> userInfo() {
        // 获取当前登录用户
        AppUser appUser = appUserService.getAppUser();
        if (!StringUtils.hasLength(appUser.getProfilePhoto())){
            appUser.setProfilePhoto("https://bizuphk.oss-cn-hongkong.aliyuncs.com/1703841554373");
        }
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        return ResultUtil.success(appUser);
    }
@@ -245,9 +232,23 @@
    }
    @Override
    public ResultUtil<CollectRes> collect(UserInfoQuery query) {
        AppUser appUser = appUserService.getAppUser();
        SearchHousingDemandRes searchHousingDemandRes = housingDemandService
                .searchHousingDemand1(appUserService.getAppUser().getId());
                .searchHousingDemand1(appUser.getId());
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        List<SearchHousingDemandListRes> list1 = searchHousingDemandRes.getList();
        for (SearchHousingDemandListRes searchHousingDemandListRes : list1) {
            if (StringUtils.hasLength(searchHousingDemandListRes.getHouseTypeId())){
                String[] split = searchHousingDemandListRes.getHouseTypeId().split(",");
                if (split.length>0){
                    HouseType houseType = houseTypeService.selectById(split[0]);
                    if (houseType!=null)searchHousingDemandListRes.setHouseTypeName(houseType.getName());
                }
            }
        }
        CollectRes searchIntermediaryRes = new CollectRes();
        List<CollectListRes> list = houseResourceService.collect(appUserService.getAppUser().getId());
        for (SearchHousingDemandListRes temp : list1) {
@@ -255,6 +256,7 @@
            CollectListRes collectListRes = new CollectListRes();
            collectListRes.setSaleAmount(temp.getSaleAmount());
            collectListRes.setData(1);
            collectListRes.setAuthStatus(2);
            BeanUtils.copyProperties(temp,collectListRes);
            StringBuilder stringBuilder = new StringBuilder("");
            if (temp.getAddress()!=null){
@@ -320,22 +322,21 @@
        }
        collect1.addAll(collect2);
        // 使用 Collections.sort() 方法排序
        Collections.sort(collect1, Comparator.comparing(CollectListRes::getInsertTime).reversed());
        List<CollectListRes> testing = testing(collect1.size(), query.getPageNum(), query.getPageSize(), collect1);
        List<CollectListRes> collect = testing.stream().filter(t -> t.getData() == 2).distinct().collect(Collectors.toList());
        List<CollectListRes> collectt = testing.stream().filter(t -> t.getData() == 1).distinct().collect(Collectors.toList());
        long count = collect.stream().filter(t -> t.getType() == 1).count();
        long count1 = collectt.stream().filter(t -> t.getType() == 1).count();
        // 草稿数量
        searchIntermediaryRes.setDraft(Integer.parseInt(String.valueOf(count))+Integer.parseInt(String.valueOf(count1)));
        // 上架房源数
        int size = collect.stream().filter(t -> t.getStatus() == 1 && t.getType()==2).collect(Collectors.toList()).size();
        int size2 = collectt.stream().filter(t -> t.getStatus() == 1 && t.getType()==2).collect(Collectors.toList()).size();
        searchIntermediaryRes.setOn(size+size2);
        // 下架房源数
        int size1 = collect.stream().filter(t -> t.getStatus() == 0 && t.getType()==2).collect(Collectors.toList()).size();
        int size3 = collectt.stream().filter(t -> t.getStatus() == 0 && t.getType()==2).collect(Collectors.toList()).size();
        searchIntermediaryRes.setOff(size1+size3);
        long count1 = collect1.stream().filter(t -> t.getType() == 1).count();
        // 上架数量
        long count2 = collect1.stream().filter(t -> t.getType() == 2 && t.getStatus()==1).count();
        // 下架数量
        long count3 = collect1.stream().filter(t -> t.getType() == 2 && t.getStatus()==0).count();
        searchIntermediaryRes.setDraft(Integer.parseInt(String.valueOf(count1)));
        searchIntermediaryRes.setOff(Integer.parseInt(String.valueOf(count3)));
        searchIntermediaryRes.setOn(Integer.parseInt(String.valueOf(count2)));
//        @ApiModelProperty("是否有电梯(0=否,1=是)")
//        private Integer elevator;
//        @ApiModelProperty("是否有晾晒区(0=否,1=是)")
@@ -350,36 +351,54 @@
//        private Integer keepPet;
        for (CollectListRes t : testing) {
            int a =0;
            // 将时间转化为指定格式
            // 创建一个日期格式化对象,指定要转换的格式
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日");
            String format = formatter.format(t.getInsertTime());
            t.setTime(format);
            StringBuilder temp = new StringBuilder("");
            if (t.getElevator()==null){
                temp.append("电梯,");
            }else if (t.getElevator()==1){
                temp.append("电梯,");
            if (StringUtils.hasLength(t.getHouseTypeName())){
                if (a<4){
                    temp.append(t.getHouseTypeName()+",");
                    a++;
                }
            }
            if (t.getDryingArea()==null){
                temp.append("晾晒区,");
            }else if (t.getDryingArea()==1){
                temp.append("晾晒区,");
             if (t.getElevator()!=null&&t.getElevator()==1){
                 if (a<4) {
                     temp.append("有电梯,");
                     a++;
                 }
            }
            if (t.getGarden()==null){
                temp.append("花园,");
            }else if (t.getGarden()==1){
                temp.append("花园,");
            if (t.getBalcony()!=null&&t.getBalcony()==1){
                if (a<4) {
                    temp.append("有阳台,");
                    a++;
                }
            }
            if (t.getCarport()==null){
                temp.append("车位,");
            }else if (t.getCarport()==1){
                temp.append("车位,");
            if (t.getDryingArea()!=null&&t.getDryingArea()==1){
                if (a<4) {
                    temp.append("有天台,");
                    a++;
                }
            }
            if (t.getBalcony()==null){
                temp.append("平台,");
            }else if (t.getBalcony()==1){
                temp.append("平台,");
            if (t.getGarden()!=null&&t.getGarden()==1){
                if (a<4) {
                    temp.append("有花园,");
                    a++;
                }
            }
            if (t.getKeepPet()==null){
                temp.append("宠物,");
            }else if (t.getKeepPet()==1){
                temp.append("宠物,");
             if (t.getCarport()!=null&&t.getCarport()==1){
                 if (a<4) {
                     temp.append("有车位,");
                     a++;
                 }
            }
            if (t.getKeepPet()!=null&&t.getKeepPet()==1){
                if (a<4) {
                    temp.append("可养宠物,");
                    a++;
                }
            }
            String string = temp.toString();
            if (StringUtils.hasLength(string)){
@@ -388,15 +407,12 @@
            }else{
                t.setHead("");
            }
        }
        searchIntermediaryRes.setList(testing);
        searchIntermediaryRes.setTotal(testing.size());
        searchIntermediaryRes.setTotal(collect1.size());
        return ResultUtil.success(searchIntermediaryRes);
    }
    public static List<CollectListRes> testing(long total, long current, long size, List<CollectListRes> str){
        List<CollectListRes> result = new ArrayList<>();
@@ -406,22 +422,10 @@
        long startIndex = page.getStartIndex();
        //获取集合下标结束值
        long endInddex = 0;
        /**
         * 如果初始值startIndex(size * current)超过总记录数 或者 入参size(一页显示多少条)大于总记录树,
         * 则下标结束值均设置为集合大小
         */
        if(startIndex + page.getCurrent() >= total || size > total){
            endInddex = total;
        }else {
            /**当最后一页,开始下标加上要取值的size 大于总条数,则最终索引改为集合大小-1=》为
             *集合的最后下标值,防止下标溢出
             **/
            if(total < startIndex + page.getSize()){
                endInddex = total - 1 ;
            }else {
                //否则为startIndex(size * current 从哪里开始取)加上一页显示多少条得到结束值
                endInddex = startIndex  + page.getSize();
            }
            endInddex = Math.min(startIndex + page.getSize(), total);
        }
        //如果输入的开始查询下标大于集合大小,则查询为空值
        if(startIndex > total){
@@ -429,19 +433,17 @@
        }else{
            result = str.subList((int)startIndex,(int)endInddex);
        }
        /**
         * 此处返回结果可以改为Page<T> T为对应业务的实体类型,最终把分页结果再塞入page的records再返回则得到与
         * mybatisplus一样的结构
         *  page.setRecords(list);
         *  return page;
         */
        return result;
    }
    @Override
    public ResultUtil<CollectRes> release(UserInfoQuery query) {
        AppUser appUser = appUserService.getAppUser();
        if(null != appUser && (appUser.getStatus() == 2|| appUser.getStatus() == 3)){
            return ResultUtil.errorLogin("当前账号已被冻结或删除");
        }
        // 房源ids
        List<Integer> ids = collectionHouseResourceService.selectList(new EntityWrapper<CollectionHouseResource>()
                .eq("app_user_id", appUserService.getAppUser().getId()))
                .eq("app_user_id", appUser.getId()))
                .stream().map(CollectionHouseResource::getHouseResourceId).collect(Collectors.toList());
            List<Integer> collect = houseResourceService.selectList(new EntityWrapper<HouseResource>()
                    .eq("is_delete", 0)
@@ -461,6 +463,10 @@
            collect1 = new ArrayList<>();
        }
        for (CollectListRes collectListRes : collect1) {
            // 查询房源的收藏量
            int house_resource_id = collectionHouseResourceService.selectList(new EntityWrapper<CollectionHouseResource>()
                    .eq("house_resource_id", collectListRes.getId())).size();
            collectListRes.setCollect(house_resource_id);
            // 根据区id 查询下级
            Region city = regionService.selectById(collectListRes.getCityId());
            StringBuilder stringBuilder = new StringBuilder("");
@@ -494,10 +500,23 @@
            SearchHousingDemandRes searchHousingDemandRes = housingDemandService.searchHousingDemand2(demand);
            List<SearchHousingDemandListRes> list1 = searchHousingDemandRes.getList();
            for (SearchHousingDemandListRes temp : list1) {
                if (StringUtils.hasLength(temp.getHouseTypeId())){
                    String[] split = temp.getHouseTypeId().split(",");
                    if (split.length>0){
                        HouseType houseType = houseTypeService.selectById(split[0]);
                        if (houseType!=null)temp.setHouseTypeName(houseType.getName());
                    }
                }
                CollectListRes collectListRes = new CollectListRes();
                // 求房源的收藏数量
                int housing_demand_id = collectionHousingDemandService.selectList(new EntityWrapper<CollectionHousingDemand>()
                        .eq("housing_demand_id", temp.getId())).size();
                collectListRes.setSaleAmount(temp.getSaleAmount());
                collectListRes.setData(1);
                BeanUtils.copyProperties(temp,collectListRes);
                collectListRes.setCollect(housing_demand_id);
                StringBuilder stringBuilder = new StringBuilder("");
                if (temp.getAddress()!=null){
                    for (String address : temp.getAddress()) {
@@ -507,16 +526,68 @@
                    String substring = string.substring(0, string.length() - 1);
                    collectListRes.setAddress(substring);
                }
                if (temp.getRentalDuration()!=null){
                    Integer rentalDuration = temp.getRentalDuration();
                    // 计算年数和剩余月数
                    int years = rentalDuration / 12;
                    int remainingMonths = rentalDuration % 12;
                    if (years==0){
                        collectListRes.setLeaseTime(remainingMonths+"月");
                    }else{
                        if (remainingMonths==0){
                            collectListRes.setLeaseTime(years+"年");
                        }else{
                            collectListRes.setLeaseTime(years+"年"+remainingMonths+"月");
                        }
                    }
                }
                collect1.add(collectListRes);
            }
        }
        CollectRes searchIntermediaryRes = new CollectRes();
        Collections.sort(collect1, Comparator.comparing(CollectListRes::getInsertTime).reversed());
        List<CollectListRes> testing = testing(collect1.size(), query.getPageNum(), query.getPageSize(), collect1);
        for (CollectListRes t : testing) {
            // 将时间转化为指定格式
            // 创建一个日期格式化对象,指定要转换的格式
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日");
            String format = formatter.format(t.getInsertTime());
            t.setTime(format);
            StringBuilder temp = new StringBuilder("");
            if (StringUtils.hasLength(t.getHouseTypeName())){
                temp.append(t.getHouseTypeName()+",");
            }
            if (t.getElevator()!=null&&t.getElevator()==1){
                temp.append("有电梯,");
            }
            if (t.getBalcony()!=null&&t.getBalcony()==1){
                temp.append("有阳台,");
            }
            if (t.getDryingArea()!=null&&t.getDryingArea()==1){
                temp.append("有天台,");
            }
            if (t.getGarden()!=null&&t.getGarden()==1){
                temp.append("有花园,");
            }
            if (t.getCarport()!=null&&t.getCarport()==1){
                temp.append("有车位,");
            }
            if (t.getKeepPet()!=null&&t.getKeepPet()==1){
                temp.append("可养宠物,");
            }
            String string = temp.toString();
            if (StringUtils.hasLength(string)){
                String substring = string.substring(0, string.length() - 1);
                t.setHead(substring);
            }else{
                t.setHead("");
            }
        }
        searchIntermediaryRes.setList(testing);
        searchIntermediaryRes.setTotal(testing.size());
        searchIntermediaryRes.setTotal(collect1.size());
        return ResultUtil.success(searchIntermediaryRes);
    }
@@ -542,6 +613,7 @@
        appUser.setStatus(1);
        appUser.setAuth(0);
        appUser.setInsertTime(new Date());
        appUser.setProfilePhoto("https://bizuphk.oss-cn-hongkong.aliyuncs.com/1703841554373");
        this.insert(appUser);
        return appUser;
    }
@@ -569,7 +641,6 @@
     * @return
     */
    private Integer getAppUserIdFromToken(String token){
        System.err.println("token--->" + token);
        String key = token;
        int length = token.length();
        if(length > 32){
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/BannerServiceImpl.java
@@ -23,7 +23,7 @@
     * @return
     */
    @Override
    public List<BannerRes> getBanners(Integer position) {
        return this.baseMapper.getBanners(position);
    public BannerRes getBanner(Integer position) {
        return this.baseMapper.getBanner(position);
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java
@@ -6,6 +6,7 @@
import com.alipay.api.internal.util.codec.Base64;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.mongodb.client.result.UpdateResult;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.file.OSSService;
import com.stylefeng.guns.modular.system.dao.HouseResourceMapper;
@@ -19,6 +20,7 @@
import com.stylefeng.guns.modular.system.warpper.req.SearchHouseResourceReq;
import com.stylefeng.guns.modular.system.warpper.req.UserInfoQuery;
import com.stylefeng.guns.modular.system.warpper.res.*;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.http.entity.ContentType;
import org.springframework.beans.BeanUtils;
@@ -29,8 +31,12 @@
import org.springframework.data.geo.Metrics;
import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.CriteriaDefinition;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.http.*;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
@@ -77,6 +83,8 @@
    private WxAppletTools wxAppletTools;
    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private IUserService userService;
    @Autowired
    private OSSService ossService;
@@ -134,12 +142,23 @@
    public SearchHouseResourceRes searchHouseResource(SearchHouseResourceReq req) {
        req.setPageNum((req.getPageNum() - 1) * req.getPageSize());
        //租房处理推荐和记录历史搜索数据
        if(req.getType() == 1){
            fillSearchHistory(req);
        }
        fillSearchHistory(req);
        //区域
        List<Integer> districtIds = new ArrayList<>();
        List<Integer> cityIds = new ArrayList<>();
        if (req.getDataType()!=null && req.getDataType()==1 && req.getUserType()==5 && req.getDistrict()==null && req.getArea()==null){
            // 如果用户有历史 并且在首页列表的时候 看他有没有历史搜索
            if (appUserService.getAppUser()!=null){
                SearchHistoryCondition app_user_id = searchHistoryConditionService.selectOne(new EntityWrapper<SearchHistoryCondition>()
                        .eq("app_user_id", appUserService.getAppUser().getId()));
                if (app_user_id!=null){
                    if(StringUtils.hasLength(app_user_id.getDistrict()) ){
                        districtIds.add(Integer.valueOf(app_user_id.getDistrict()));
                    }
                }
            }
        }
        if (req.getDistrict() != null &&(!req.getDistrict().equals("")) ){
            // 一级id
            Integer integer = Integer.valueOf(req.getDistrict());
@@ -150,6 +169,12 @@
                    cityIds.add(Integer.valueOf(s));
                }
            }
        }else if (StringUtils.hasLength(req.getArea())){
            String[] split = req.getArea().split(",");
            for (String s : split) {
                cityIds.add(Integer.valueOf(s));
            }
            // 根据用户历史搜索 推荐对应的区域
        }
//        if(StringUtils.hasLength(req.getDistrict())){
//            cityIds = new ArrayList<>();
@@ -184,8 +209,6 @@
                saleAmountStart = Double.valueOf(split[0]);
                saleAmountEnd = Double.valueOf(split[1]);
            }
        }
        //户型
        List<String> houseModels = null;
@@ -202,11 +225,24 @@
                houseTypeIds.add(Integer.valueOf(s));
            }
        }
        SearchHouseResourceRes searchHouseResource = new SearchHouseResourceRes();
        List<SearchHouseResourceListRes> searchHouseResourceListRes = this.baseMapper.searchHouseResource(req, cityIds, districtIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
        // 如果有根据用户历史来搜索必看 如果没有搜索出数据 那么查询所有必看
        if (req.getDataType()!=null&&req.getDataType()==1 && (!StringUtils.hasLength(req.getDistrict())) && searchHouseResourceListRes!=null&&searchHouseResourceListRes.size()==0){
            cityIds=null;
            districtIds=null;
            searchHouseResourceListRes = this.baseMapper.searchHouseResource(req, cityIds, districtIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
        }
        for (SearchHouseResourceListRes t : searchHouseResourceListRes) {
            if (t.getIsManage()!=null && t.getIsManage() == 1){
                // 后台添加设置为中介房源
                t.setHouseResource(3);
            }
        }
        searchHouseResource.setList(searchHouseResourceListRes);
        searchHouseResource.setTotal(searchHouseResourceListRes.size());
        List<SearchHouseResourceListRes> searchHouseResourceListRes1 = this.baseMapper.searchHouseResource1(req, cityIds, districtIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
        searchHouseResource.setTotal(searchHouseResourceListRes1.size());
        return searchHouseResource;
    }
@@ -275,6 +311,13 @@
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        AppUser appUser = appUserService.getAppUser();
        HouseResource houseResource = this.selectById(id);
        SearchHouseResourceReq req = new SearchHouseResourceReq();
        if (houseResource.getDistrictId()!=null)req.setDistrict(houseResource.getCityId().toString());
        if (houseResource.getSaleAmount()!=null)req.setSaleAmount(houseResource.getSaleAmount().toString());
        req.setHouseModel(houseResource.getHouseModel());
        req.setElevator(houseResource.getElevator());
        if (houseResource.getHouseTypeId()!=null)req.setHouseTypeId(houseResource.getHouseTypeId().toString());
        fillSearchHistory(req);
        HouseResourceInfoRes houseResourceInfoRes = new HouseResourceInfoRes();
        houseResourceInfoRes.setDataType(houseResource.getDataType());
        houseResourceInfoRes.setId(id);
@@ -291,7 +334,9 @@
        if (houseType!=null)houseResourceInfoRes.setHouseType(houseType.getName());
        houseResourceInfoRes.setFloor(houseResource.getFloor());
        houseResourceInfoRes.setElevator(houseResource.getElevator());
        houseResourceInfoRes.setDryingArea(houseResource.getDryingArea());
        if (houseResource.getBalcony()!=null&&houseResource.getBalcony()==1)houseResourceInfoRes.setDryingAreas("阳台");
        if (houseResource.getDryingArea()!=null&&houseResource.getDryingArea()==1)houseResourceInfoRes.setDryingAreas("天台");
        if (houseResource.getAir()!=null&&houseResource.getAir()==1)houseResourceInfoRes.setDryingAreas("无");
        houseResourceInfoRes.setHouseArea(houseResource.getHouseArea());
        houseResourceInfoRes.setKeepPet(houseResource.getKeepPet());
        Region region = regionService.selectById(houseResource.getDistrictId());
@@ -312,6 +357,15 @@
        houseResourceInfoRes.setNickname(appUser1.getNickname());
        houseResourceInfoRes.setUserType(appUser1.getUserType());
        houseResourceInfoRes.setInsertTime(sdf.format(houseResource.getInsertTime()));
        // 后台添加的
        if (houseResource.getIsManage()!=null && houseResource.getIsManage()==1){
            User user = userService.selectById(houseResource.getInsertUserId());
            if (user!=null){
                houseResourceInfoRes.setNickname(user.getName());
                houseResourceInfoRes.setProfilePhoto(user.getAvatar());
                houseResourceInfoRes.setUserType(3);
            }
        }
        if (houseResource.getUpdateTime()!=null){
            houseResourceInfoRes.setUpdateTime(sdf.format(houseResource.getUpdateTime()));
        }
@@ -327,7 +381,6 @@
        addViewsNumber(houseResource);
        return houseResourceInfoRes;
    }
    /**
     * 添加访问次数记录
@@ -352,15 +405,18 @@
        Double x = Double.valueOf(houseResource.getLongitude());
        Double y = Double.valueOf(houseResource.getLatitude());
        Point point = new Point(x, y);
        Circle circle = new Circle(point, new Distance(100000, Metrics.KILOMETERS));
        Circle circle = new Circle(point, new Distance(5, Metrics.KILOMETERS));
        Query query = Query.query(Criteria.where("geoJsonPoint").withinSphere(circle));
        List<PointLocation> pointLocations = mongoTemplate.find(query, PointLocation.class);
        List<Integer> ids = pointLocations.stream().map(PointLocation::getHouseId).collect(Collectors.toList());
        if (ids.size()!= 0){
        List<HouseResource> houseResources = this.selectBatchIds(ids);
        List<SearchHouseResourceListRes> list = new ArrayList<>();
            List<HouseResource> collect = houseResources.stream().filter(t -> !t.getId().equals(id) && t.getAuthStatus() == 2 && t.getType() == 2
                    && t.getStatus() == 1 && t.getIsDelete() == 0 && t.getDataType() == houseResource.getDataType())
                    .collect(Collectors.toList());
            List<SearchHouseResourceListRes> list = new ArrayList<>();
        //遍历解析出返回数据
        for (HouseResource resource : houseResources) {
        for (HouseResource resource : collect) {
            SearchHouseResourceListRes searchHouseResourceListRes = new SearchHouseResourceListRes();
            searchHouseResourceListRes.setId(resource.getId());
            AppUser appUser = appUserService.selectById(resource.getAppUserId());
@@ -398,10 +454,10 @@
    @Override
    public ContactInformationRes getContactInformation(Integer id) {
        HouseResource houseResource = this.selectById(id);
        AppUser appUser = appUserService.selectById(houseResource.getAppUserId());
        ContactInformationRes contactInformationRes = new ContactInformationRes();
        contactInformationRes.setWhatsApp(appUser.getWatchApp());
        contactInformationRes.setPhone(appUser.getPhone());
        contactInformationRes.setWatchApp(houseResource.getWatchApp());
        contactInformationRes.setPhone(houseResource.getPhone());
        contactInformationRes.setWechatQrCode(houseResource.getWechatQRCode());
        return contactInformationRes;
    }
@@ -420,26 +476,20 @@
                .eq("status", 1));
        if (appUser!=null){
            if (req.getId()==null){
                if (req.getType()!=1){
                if (appUser.getAuditStatus()!=2){
                if (req.getType()==2){
                    if (StringUtils.hasLength(req.getWechatQRCode()))appUser.setWechatQrCode1(req.getWechatQRCode());
                    if (StringUtils.hasLength(req.getWatchApp()))appUser.setWatchApp1(req.getWatchApp());
                    if (StringUtils.hasLength(req.getPhone()))appUser.setPhone1(req.getPhone());
                    appUserService.updateById(appUser);
                if (appUser.getAuth()!=2){
                    // 未认证 只能能发布三条房源信息
                    List<HouseResource> houseResources = this.selectList(new EntityWrapper<HouseResource>()
                            .eq("app_user_id", appUserId)
                            .eq("is_delete", 1)
                            .eq("status", 1)
                            .eq("is_delete", 0)
                            .eq("type", 2)
                    );
                    if (houseResources.size()>=3){
                        return ResultUtil.error("中介账号未认证,只能同时上架3条房源信息");
                    }
                }else if (appUser.getAuditStatus()==2){
                    // 已经认证 只能能发布20条房源信息
                    List<HouseResource> houseResources = this.selectList(new EntityWrapper<HouseResource>()
                            .eq("app_user_id", appUserId)
                            .eq("is_delete", 1)
                            .eq("status", 1)
                    );
                    if (houseResources.size()>=20){
                        return ResultUtil.error("当前中介账号只能同时上架20条房源信息");
                        return ResultUtil.error("未认证中介或认证未通过,只能同时发布3条房源信息");
                    }
                }
                }
@@ -453,10 +503,10 @@
            houseResource.setIsDelete(0);
            houseResource.setInsertUserId(appUserId);
            houseResource.setViewsNumber(0);
            houseResource.setUpdateTime(new Date());
            // todo 修改回审核和上下架状态
            houseResource.setStatus(1);
            houseResource.setDataType(req.getDataType());
            houseResource.setAuthStatus(1);
            houseResource.setLeaseTime(req.getTime());
            houseResource.setAppUserId(appUserService.getAppUser().getId());
@@ -520,17 +570,51 @@
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        return null;
                    }
                }
                this.baseMapper.insert(houseResource);
                if (req.getId()==null){
                    this.baseMapper.insert(houseResource);
                }else{
                    this.baseMapper.updateById(houseResource);
                }
            }else{
                if (req.getId()==null){
                    this.baseMapper.insert(houseResource);
                }else{
                    this.baseMapper.updateById(houseResource);
                }
            }
            if (req.getType()==2 && req.getId()==null){
                PointLocation pointLocation = new PointLocation();
                GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(req.getLongitude()),Double.valueOf(req.getLatitude()));
                pointLocation.setGeoJsonPoint(geoJsonPoint);
                pointLocation.setHouseId(houseResource.getId());
                mongoTemplate.insert(pointLocation);
                houseResource.setCode(pointLocation.getId());
                this.baseMapper.updateById(houseResource);
            }
            if (req.getType()==2 && req.getId()!=null){
                HouseResource houseResource1 = this.baseMapper.selectById(req.getId());
                if (!StringUtils.hasLength(houseResource1.getCode())){
                    PointLocation pointLocation = new PointLocation();
                    GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(req.getLongitude()),Double.valueOf(req.getLatitude()));
                    pointLocation.setGeoJsonPoint(geoJsonPoint);
                    pointLocation.setHouseId(req.getId());
                    mongoTemplate.insert(pointLocation);
                    houseResource1.setCode(pointLocation.getId());
                    this.baseMapper.updateById(houseResource1);
                }
                Query query = Query.query(Criteria.where("_id").is(houseResource1.getCode()));
                PointLocation pointLocation = new PointLocation();
                pointLocation.setId(houseResource1.getCode());
                pointLocation.setHouseId(houseResource.getId());
                GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(req.getLongitude()),Double.valueOf(req.getLatitude()));
                pointLocation.setGeoJsonPoint(geoJsonPoint);
                org.bson.Document document = (org.bson.Document)mongoTemplate.getConverter() .convertToMongoType(pointLocation);
                Update update = Update.fromDocument (document);
                UpdateResult updateResult = mongoTemplate.updateFirst(query, update, PointLocation.class);
                System.err.println(updateResult.getModifiedCount());
            }
            return ResultUtil.success();
        }
@@ -540,8 +624,14 @@
    @Override
    public ResultUtil confirm(Integer userType) {
        AppUser appUser = appUserService.getAppUser();
        if (userType==2 && appUser.getUserType()==2){
        }else{
            appUser.setChangeTime(new Date());
        }
        appUser.setUserType(userType);
        appUserService.updateById(appUser);
        return ResultUtil.success();
    }
@@ -558,28 +648,28 @@
            // 最多只能发布三条房源信息
            int size = this.baseMapper.selectList(new EntityWrapper<HouseResource>()
                    .eq("app_user_id", appUser.getId())
                    .eq("is_delete", 1)
                    .eq("is_delete", 0)
                    .eq("type",2)
            ).size();
            if (3-size<0)size=0;
            if (3-size<0){
                return ResultUtil.success(0);
            }
            return ResultUtil.success(3-size);
        }
        if (appUser.getUserType()==3){
            // 如果是中介 判断他是否认证成功
            if (appUser.getAuditStatus()==2){
                // 可以发布20条
                // 最多只能发布三条房源信息
                int size = this.baseMapper.selectList(new EntityWrapper<HouseResource>()
                        .eq("app_user_id", appUser.getId())
                        .eq("is_delete", 1)
                ).size();
                if (20-size<0)size=0;
                return ResultUtil.success(3-size);
            if (appUser.getAuth()==2){
                return ResultUtil.success(99999);
            }else{
                // 如果是中介但是还未认证 最多只能上架三条
                int size = this.baseMapper.selectList(new EntityWrapper<HouseResource>()
                        .eq("app_user_id", appUser.getId())
                        .eq("is_delete", 1)
                        .eq("is_delete", 0)
                        .eq("type",2)
                ).size();
                if (3-size<0)size=0;
                if (3-size<0){
                    return ResultUtil.success(0);
                }
                return ResultUtil.success(3-size);
            }
        }
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java
@@ -93,7 +93,18 @@
        housingDemand.setInsertUserId(appUser.getId());
        housingDemand.setAppUserId(appUser.getId());
        housingDemand.setStatus(1);
        housingDemand.setUpdateTime(new Date());
        if (StringUtils.hasLength(req.getSaleAmount())&&req.getSaleAmount().equals("2000")){
            housingDemand.setSaleAmount("2000-99999999");
        }
        if (StringUtils.hasLength(req.getSaleAmount())&&req.getSaleAmount().equals("500")){
            housingDemand.setSaleAmount("0-500");
        }
        if (req.getType()==2){
            if (StringUtils.hasLength(req.getWechatQRCode()))appUser.setWechatQrCode1(req.getWechatQRCode());
            if (StringUtils.hasLength(req.getWatchApp()))appUser.setWatchApp1(req.getWatchApp());
            if (StringUtils.hasLength(req.getPhone()))appUser.setPhone1(req.getPhone());
            appUserService.updateById(appUser);
            InputStream inputStream = null;
            OutputStream outputStream = null;
            String accessToken = wxAppletTools.getAccessToken();
@@ -149,9 +160,9 @@
                    return null;
                }
            }
            this.insert(housingDemand);
            this.insertOrUpdate(housingDemand);
        }else{
            this.updateById(housingDemand);
            this.insertOrUpdate(housingDemand);
        }
        List<HousingDemandDistrict> list = new ArrayList<>();
        if(ToolUtil.isNotEmpty(req.getDistrict())){
@@ -206,7 +217,7 @@
        Double saleAmountEnd = null;
        if(StringUtils.hasLength(req.getSaleAmount())){
            if (req.getSaleAmount().contains("以上")){
                saleAmountEnd =1000000.0;
                saleAmountEnd =2001.0;
                saleAmountStart = 2000.0;
            }else if (req.getSaleAmount().contains("以下")){
                saleAmountEnd =500.0;
@@ -231,53 +242,85 @@
            for (String s : split) {
                houseTypeIds.add(Integer.valueOf(s));
            }
            houseTypeIds.add(0);
        }
        SearchHousingDemandRes searchHouseResource = new SearchHousingDemandRes();
        List<SearchHousingDemandListRes> searchHouseResourceListRes = this.baseMapper.searchHousingDemand
                (req, districtIds,areaIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
        for (SearchHousingDemandListRes searchHouseResourceListRe : searchHouseResourceListRes) {
            List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId()));
            // 获取到房源区域id集合
            List<HousingDemandDistrict> list1 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId())
            ).stream().filter(t -> t.getCityId() == 1).collect(Collectors.toList());
            List<HousingDemandDistrict> list2 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId())
            ).stream().filter(t -> t.getCityId() == 2).collect(Collectors.toList());
            List<HousingDemandDistrict> list3 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId())
            ).stream().filter(t -> t.getCityId() == 3).collect(Collectors.toList());
            List<String> dis = new ArrayList<>();
            for (HousingDemandDistrict housingDemandDistrict : list) {
                Region region = regionService.selectById(housingDemandDistrict.getCityId());
            StringBuilder s1 = new StringBuilder("香港岛>");
            StringBuilder s2 = new StringBuilder("九龙>");
            StringBuilder s3 = new StringBuilder("新界>");
            for (HousingDemandDistrict housingDemandDistrict : list1) {
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
                s1.append((null == region1 ? "不限" : region1.getName())+"/");
            }
            for (HousingDemandDistrict housingDemandDistrict : list2) {
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                s2.append((null == region1 ? "不限" : region1.getName())+"/");
            }
            for (HousingDemandDistrict housingDemandDistrict : list3) {
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                s3.append((null == region1 ? "不限" : region1.getName())+"/");
            }
            String string1 = s1.toString();
            String string2 = s2.toString();
            String string3 = s3.toString();
            String substring1=string1;
            String substring2=string2;
            String substring3=string3;
            if (string1.endsWith("/")){
                substring1 = string1.substring(0, string1.length() - 1);
            }
            if (string2.endsWith("/")){
                substring2 = string2.substring(0, string2.length() - 1);
            }
            if (string3.endsWith("/")){
                substring3 = string3.substring(0, string3.length() - 1);
            }
            if (!substring1.equals("香港岛>")){
                dis.add(substring1);
            }
            if (!substring2.equals("九龙>")){
                dis.add(substring2);
            }
            if (!substring3.equals("新界>")){
                dis.add(substring3);
            }
            //城市不限用空判断
            searchHouseResourceListRe.setAddress(dis.size() == 0 ? null : dis);
        }
        List<SearchHousingDemandListRes> collect = new ArrayList<>();
        if (req.getRentalDuration()!=null){
            if (req.getRentalDuration().equals("一年以上")){
                collect = searchHouseResourceListRes.stream().filter(t -> t.getRentalDuration() >= 12)
        if (StringUtils.hasLength(req.getRentalDuration())){
            if (req.getRentalDuration().equals("2")){
                collect = searchHouseResourceListRes.stream().filter(t -> t.getRentalDuration()!=null && t.getRentalDuration()>= 12)
                        .collect(Collectors.toList());
            }else if (req.getRentalDuration().equals("一年以下")){
                collect = searchHouseResourceListRes.stream().filter(t -> t.getRentalDuration() < 12)
            }else if (req.getRentalDuration().equals("1")){
                collect = searchHouseResourceListRes.stream().filter(t ->t.getRentalDuration()!=null && t.getRentalDuration() < 12)
                        .collect(Collectors.toList());
            }
            searchHouseResource.setList(collect);
            searchHouseResource.setTotal(collect.size());
        }else{
            searchHouseResource.setList(searchHouseResourceListRes);
            searchHouseResource.setTotal(searchHouseResourceListRes.size());
        }
        Integer integer = this.baseMapper.searchHousingDemandCount(req, districtIds,areaIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
        return searchHouseResource;
    }
    /**
     * 搜索求房源列表数据
     * @return
     */
    @Override
@@ -285,16 +328,56 @@
        SearchHousingDemandRes searchHouseResource = new SearchHousingDemandRes();
        List<SearchHousingDemandListRes> searchHouseResourceListRes = this.baseMapper.searchHousingDemand1(id);
        for (SearchHousingDemandListRes searchHouseResourceListRe : searchHouseResourceListRes) {
            List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId()));
            // 获取到房源区域id集合
            List<HousingDemandDistrict> list1 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId())
            ).stream().filter(t -> t.getCityId() == 1).collect(Collectors.toList());
            List<HousingDemandDistrict> list2 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId())
            ).stream().filter(t -> t.getCityId() == 2).collect(Collectors.toList());
            List<HousingDemandDistrict> list3 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId())
            ).stream().filter(t -> t.getCityId() == 3).collect(Collectors.toList());
            List<String> dis = new ArrayList<>();
            for (HousingDemandDistrict housingDemandDistrict : list) {
                Region region = regionService.selectById(housingDemandDistrict.getCityId());
            StringBuilder s1 = new StringBuilder("香港岛>");
            StringBuilder s2 = new StringBuilder("九龙>");
            StringBuilder s3 = new StringBuilder("新界>");
            for (HousingDemandDistrict housingDemandDistrict : list1) {
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
                s1.append((null == region1 ? "不限" : region1.getName())+"/");
            }
            for (HousingDemandDistrict housingDemandDistrict : list2) {
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                s2.append((null == region1 ? "不限" : region1.getName())+"/");
            }
            for (HousingDemandDistrict housingDemandDistrict : list3) {
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                s3.append((null == region1 ? "不限" : region1.getName())+"/");
            }
            String string1 = s1.toString();
            String string2 = s2.toString();
            String string3 = s3.toString();
            String substring1=string1;
            String substring2=string2;
            String substring3=string3;
            if (string1.endsWith("/")){
                substring1 = string1.substring(0, string1.length() - 1);
            }
            if (string2.endsWith("/")){
                substring2 = string2.substring(0, string2.length() - 1);
            }
            if (string3.endsWith("/")){
                substring3 = string3.substring(0, string3.length() - 1);
            }
            if (!substring1.equals("香港岛>")){
                dis.add(substring1);
            }
            if (!substring2.equals("九龙>")){
                dis.add(substring2);
            }
            if (!substring3.equals("新界>")){
                dis.add(substring3);
            }
            //城市不限用空判断
            searchHouseResourceListRe.setAddress(dis.size() == 0 ? null : dis);
@@ -308,7 +391,6 @@
    public SearchHousingDemandRes searchHousingDemand2(List<Integer> id) {
        SearchHousingDemandRes searchHouseResource = new SearchHousingDemandRes();
        List<SearchHousingDemandListRes> searchHouseResourceListRes = this.baseMapper.searchHousingDemand2(id);
        for (SearchHousingDemandListRes searchHouseResourceListRe : searchHouseResourceListRes) {
            List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                    .eq("housing_demand_id", searchHouseResourceListRe.getId()));
@@ -317,7 +399,6 @@
                Region region = regionService.selectById(housingDemandDistrict.getCityId());
                Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
                dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
            }
            //城市不限用空判断
            searchHouseResourceListRe.setAddress(dis.size() == 0 ? null : dis);
@@ -326,9 +407,8 @@
        searchHouseResource.setTotal(searchHouseResourceListRes.size());
        return searchHouseResource;
    }
    /**
     * 不带分页的求房源列表
     * 求房源详情
     * @param id
     * @return
     */
@@ -347,27 +427,86 @@
        housingDemandInfoRes.setRentalDuration(housingDemand.getRentalDuration());
        housingDemandInfoRes.setSaleDate(housingDemand.getSaleDate());
        if (StringUtils.hasLength(housingDemand.getHouseTypeId())){
            String[] split = housingDemand.getHouseTypeId().split(",");
            String houseType = "";
            for (String s : split) {
                HouseType htype = houseTypeService.selectById(s);
                houseType += htype.getName() + " / ";
            if (housingDemand.getHouseTypeId().equals("0")){
                housingDemandInfoRes.setHouseType("不限");
            }else{
                String[] split = housingDemand.getHouseTypeId().split(",");
                String houseType = "";
                for (String s : split) {
                    HouseType htype = houseTypeService.selectById(s);
                    if (htype!=null)houseType += htype.getName() + " / ";
                }
                if (StringUtils.hasLength(houseType))housingDemandInfoRes.setHouseType(houseType.substring(0, houseType.lastIndexOf("/")));
            }
            housingDemandInfoRes.setHouseType(houseType.substring(0, houseType.lastIndexOf("/")));
        }
        housingDemandInfoRes.setFloor(housingDemand.getFloor());
        housingDemandInfoRes.setElevator(housingDemand.getElevator());
        housingDemandInfoRes.setDryingArea(housingDemand.getDryingArea());
        StringBuilder stringBuilder = new StringBuilder("");
        if (housingDemand.getBalcony()==1 && housingDemand.getAir()==1 && housingDemand.getDryingArea()==1){
            stringBuilder.append("不限");
        }else{
            if (housingDemand.getBalcony()!=null && housingDemand.getBalcony() == 1){
                stringBuilder.append("阳台");
            }
            if (housingDemand.getDryingArea()!=null && housingDemand.getDryingArea() == 1){
                stringBuilder.append("| 天台");
            }
            if (housingDemand.getAir()!=null && housingDemand.getAir() == 1){
                stringBuilder.append("| 无");
            }
        }
        housingDemandInfoRes.setDryingArea(stringBuilder.toString());
        housingDemandInfoRes.setHouseArea(housingDemand.getHouseArea());
        housingDemandInfoRes.setKeepPet(housingDemand.getKeepPet());
        List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                .eq("housing_demand_id", id));
        // 获取到房源区域id集合
        List<HousingDemandDistrict> list1 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                .eq("housing_demand_id", id)
        ).stream().filter(t -> t.getCityId() == 1).collect(Collectors.toList());
        List<HousingDemandDistrict> list2 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                .eq("housing_demand_id", id)
        ).stream().filter(t -> t.getCityId() == 2).collect(Collectors.toList());
        List<HousingDemandDistrict> list3 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
                .eq("housing_demand_id", id)
        ).stream().filter(t -> t.getCityId() == 3).collect(Collectors.toList());
        List<String> dis = new ArrayList<>();
        for (HousingDemandDistrict housingDemandDistrict : list) {
            Region region = regionService.selectById(housingDemandDistrict.getCityId());
        StringBuilder s1 = new StringBuilder("香港岛>");
        StringBuilder s2 = new StringBuilder("九龙>");
        StringBuilder s3 = new StringBuilder("新界>");
        for (HousingDemandDistrict housingDemandDistrict : list1) {
            Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
            dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
            s1.append((null == region1 ? "不限" : region1.getName())+"/");
        }
        for (HousingDemandDistrict housingDemandDistrict : list2) {
            Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
            s2.append((null == region1 ? "不限" : region1.getName())+"/");
        }
        for (HousingDemandDistrict housingDemandDistrict : list3) {
            Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
            s3.append((null == region1 ? "不限" : region1.getName())+"/");
        }
        String string1 = s1.toString();
        String string2 = s2.toString();
        String string3 = s3.toString();
        String substring1=string1;
        String substring2=string2;
        String substring3=string3;
        if (string1.endsWith("/")){
            substring1 = string1.substring(0, string1.length() - 1);
        }
        if (string2.endsWith("/")){
            substring2 = string2.substring(0, string2.length() - 1);
        }
        if (string3.endsWith("/")){
            substring3 = string3.substring(0, string3.length() - 1);
        }
        if (!substring1.equals("香港岛>")){
            dis.add(substring1);
        }
        if (!substring2.equals("九龙>")){
            dis.add(substring2);
        }
        if (!substring3.equals("新界>")){
            dis.add(substring3);
        }
        //城市不限用空判断
        housingDemandInfoRes.setAddress(dis.size() == 0 ? null : dis);
@@ -378,7 +517,7 @@
        housingDemandInfoRes.setNickname(appUser1.getNickname());
        housingDemandInfoRes.setInsertTime(sdf.format(housingDemand.getInsertTime()));
        if (housingDemand.getUpdateTime()==null){
            housingDemandInfoRes.setUpdateTime(sdf.format(housingDemand.getInsertTime()));
            housingDemandInfoRes.setUpdateTime(null);
        }else{
            housingDemandInfoRes.setUpdateTime(sdf.format(housingDemand.getUpdateTime()));
        }
@@ -417,11 +556,10 @@
    @Override
    public ContactInformationRes getContactInformation(Integer id) {
        HousingDemand houseResource = this.selectById(id);
        AppUser appUser = appUserService.selectById(houseResource.getAppUserId());
        ContactInformationRes contactInformationRes = new ContactInformationRes();
        contactInformationRes.setWhatsApp(appUser.getWatchApp());
        contactInformationRes.setPhone(appUser.getPhone());
        contactInformationRes.setWechatQrCode(appUser.getWechatQRCode());
        contactInformationRes.setWatchApp(houseResource.getWatchApp());
        contactInformationRes.setPhone(houseResource.getPhone());
        contactInformationRes.setWechatQrCode(houseResource.getWechatQRCode());
        return contactInformationRes;
    }
@@ -435,10 +573,14 @@
        if(null == appUser){
            return ResultUtil.tokenErr();
        }
        int num = this.selectCount(new EntityWrapper<HousingDemand>().eq("is_delete", 0)
        int num = this.selectCount(new EntityWrapper<HousingDemand>()
                .eq("is_delete", 0)
                .eq("app_user_id", appUser.getId())
                .eq("status", 1)
                .eq("type", 2)
        );
        if (appUser.getAuth()==2){
            return ResultUtil.success(99999);
        }
        return ResultUtil.success(appUser.getUserType() != 3 ? (3 - num) : -1);
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReportHouseResourceServiceImpl.java
@@ -40,31 +40,39 @@
        if(null == appUser){
            return ResultUtil.tokenErr();
        }
        // 查询当前房源被举报通过了多少次
        int house_resource_id = this.selectList(new EntityWrapper<ReportHouseResource>()
                .eq("house_resource_id", req.getHouseResourceId())
                .eq("audit",1)).size();
        if (house_resource_id >= 3){
        .eq("audit",1)).size();
        if (house_resource_id >= 2){
            HouseResource houseResource = houseResourceService.selectById(req.getHouseResourceId());
            houseResource.setIsDelete(1);
            houseResource.setStatus(0);
            houseResourceService.updateById(houseResource);
            //组装数据对象
            ReportHouseResource reportHouseResource = new ReportHouseResource();
            reportHouseResource.setAppUserId(appUser.getId());
            reportHouseResource.setContent(req.getContent());
            reportHouseResource.setHouseResourceId(req.getHouseResourceId());
            reportHouseResource.setInsertTime(new Date());
            reportHouseResource.setAudit(0);
            this.insert(reportHouseResource);
            return  ResultUtil.success();
        }else{
            HouseResource houseResource = houseResourceService.selectById(req.getHouseResourceId());
            houseResource.setStatus(0);
            houseResource.setAuthStatus(1);
            houseResourceService.updateById(houseResource);
            //组装数据对象
            ReportHouseResource reportHouseResource = new ReportHouseResource();
            reportHouseResource.setAppUserId(appUser.getId());
            reportHouseResource.setContent(req.getContent());
            reportHouseResource.setHouseResourceId(req.getHouseResourceId());
            reportHouseResource.setInsertTime(new Date());
            reportHouseResource.setAudit(0);
            this.insert(reportHouseResource);
            houseResourceService.updateById(houseResource);
        }
        //组装数据对象
        ReportHouseResource reportHouseResource = new ReportHouseResource();
        reportHouseResource.setAppUserId(appUser.getId());
        reportHouseResource.setContent(req.getContent());
        reportHouseResource.setHouseResourceId(req.getHouseResourceId());
        reportHouseResource.setInsertTime(new Date());
        reportHouseResource.setAudit(0);
        this.insert(reportHouseResource);
        // 查询当前房源被举报通过了多少次
//        if (house_resource_id==1 || house_resource_id==2){
//            HouseResource houseResource = houseResourceService.selectById(req.getHouseResourceId());
//            houseResource.setAuthStatus(1);
//            houseResourceService.updateById(houseResource);
//        }
        return ResultUtil.success();
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/HttpUtils.java
New file
@@ -0,0 +1,263 @@
package com.stylefeng.guns.modular.system.util;
import com.aliyun.oss.ServiceException;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.*;
import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
/**
 * 通用http发送方法
 *
 * @author ruoyi
 */
public class HttpUtils
{
    private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
    /**
     * 向指定 URL 发送GET方法的请求
     *
     * @param url 发送请求的 URL
     * @return 所代表远程资源的响应结果
     */
    public static String sendGet(String url)
    {
        return sendGet(url, StringUtils.EMPTY);
    }
    /**
     * 向指定 URL 发送GET方法的请求
     *
     * @param url 发送请求的 URL
     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
     * @return 所代表远程资源的响应结果
     */
    public static String sendGet(String url, String param)
    {
        return sendGet(url, param, Constants.UTF8);
    }
    /**
     * 向指定 URL 发送GET方法的请求
     *
     * @param url 发送请求的 URL
     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
     * @param contentType 编码类型
     * @return 所代表远程资源的响应结果
     */
    public static String sendGet(String url, String param, String contentType)
    {
        StringBuilder result = new StringBuilder();
        BufferedReader in = null;
        try
        {
            String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
            log.info("sendGet - {}", urlNameString);
            URL realUrl = new URL(urlNameString);
            URLConnection connection = realUrl.openConnection();
            connection.setRequestProperty("accept", "*/*");
            connection.setRequestProperty("connection", "Keep-Alive");
            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            connection.connect();
            in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
            String line;
            while ((line = in.readLine()) != null)
            {
                result.append(line);
            }
            log.info("recv - {}", result);
        }
        catch (ConnectException e)
        {
            log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
        }
        catch (SocketTimeoutException e)
        {
            log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
        }
        catch (IOException e)
        {
            log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
        }
        catch (Exception e)
        {
            log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
        }
        finally
        {
            try
            {
                if (in != null)
                {
                    in.close();
                }
            }
            catch (Exception ex)
            {
                log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
            }
        }
        return result.toString();
    }
    /**
     * 向指定 URL 发送POST方法的请求
     *
     * @param url 发送请求的 URL
     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
     * @return 所代表远程资源的响应结果
     */
    public static String sendPost(String url, String param)
    {
        PrintWriter out = null;
        BufferedReader in = null;
        StringBuilder result = new StringBuilder();
        try
        {
            log.info("sendPost - {}", url);
            URL realUrl = new URL(url);
            URLConnection conn = realUrl.openConnection();
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            conn.setRequestProperty("Accept-Charset", "utf-8");
            conn.setRequestProperty("contentType", "utf-8");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            out = new PrintWriter(conn.getOutputStream());
            out.print(param);
            out.flush();
            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
            String line;
            while ((line = in.readLine()) != null)
            {
                result.append(line);
            }
            log.info("recv - {}", result);
        }
        catch (ConnectException e)
        {
            log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
        }
        catch (SocketTimeoutException e)
        {
            log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
        }
        catch (IOException e)
        {
            log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
        }
        catch (Exception e)
        {
            log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
        }
        finally
        {
            try
            {
                if (out != null)
                {
                    out.close();
                }
                if (in != null)
                {
                    in.close();
                }
            }
            catch (IOException ex)
            {
                log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
            }
        }
        return result.toString();
    }
    public static String sendSSLPost(String url, String param)
    {
        StringBuilder result = new StringBuilder();
        String urlNameString = url + "?" + param;
        try
        {
            log.info("sendSSLPost - {}", urlNameString);
            SSLContext sc = SSLContext.getInstance("SSL");
            sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
            URL console = new URL(urlNameString);
            HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            conn.setRequestProperty("Accept-Charset", "utf-8");
            conn.setRequestProperty("contentType", "utf-8");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setSSLSocketFactory(sc.getSocketFactory());
            conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
            conn.connect();
            InputStream is = conn.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String ret = "";
            while ((ret = br.readLine()) != null)
            {
                if (ret != null && !"".equals(ret.trim()))
                {
                    result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
                }
            }
            log.info("recv - {}", result);
            conn.disconnect();
            br.close();
        }
        catch (ConnectException e)
        {
            log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
        }
        catch (SocketTimeoutException e)
        {
            log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
        }
        catch (IOException e)
        {
            log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
        }
        catch (Exception e)
        {
            log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
        }
        return result.toString();
    }
    private static class TrustAnyTrustManager implements X509TrustManager
    {
        @Override
        public void checkClientTrusted(X509Certificate[] chain, String authType)
        {
        }
        @Override
        public void checkServerTrusted(X509Certificate[] chain, String authType)
        {
        }
        @Override
        public X509Certificate[] getAcceptedIssuers()
        {
            return new X509Certificate[] {};
        }
    }
    private static class TrustAnyHostnameVerifier implements HostnameVerifier
    {
        @Override
        public boolean verify(String hostname, SSLSession session)
        {
            return true;
        }
    }
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/ResultUtil.java
@@ -16,6 +16,10 @@
    public static final Integer RUNTIME_ERROR = 400;
    public static final Integer ERROR = 500;
    // 手机号被冻结
    public static final Integer ERROR_Login = 501;
    // 用户发布数量超限
    public static final Integer ERROR_ADD = 502;
    public static final Integer TOKEN_ERROR = 600;
@@ -78,6 +82,20 @@
    public static ResultUtil error(String mag){
        return ResultUtil.getResult(ResultUtil.ERROR, mag, new Object());
    }
    /**
     * 登录错误信息 当前手机号被冻结
     * @return
     */
    public static ResultUtil errorLogin(String mag){
        return ResultUtil.getResult(ResultUtil.ERROR_Login, mag, new Object());
    }
    /**
     * 发布错误信息 当前用户发布条数已经超过三条
     * @return
     */
    public static ResultUtil errorAdd(String mag){
        return ResultUtil.getResult(ResultUtil.ERROR_ADD, mag, new Object());
    }
    /**
     * 错误信息
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtilHouseResource.java
File was deleted
guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/weChat/WeChatUtil.java
@@ -7,6 +7,9 @@
import com.stylefeng.guns.modular.system.util.UUIDUtil;
import com.stylefeng.guns.modular.system.util.httpClinet.HttpClientUtil;
import com.stylefeng.guns.modular.system.util.httpClinet.HttpResult;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,9 +60,10 @@
    @Autowired
    private RedisUtil redisUtil;
    // 获取微信用户access_token的接口地址
    private static final String ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token";
    // 获取微信用户信息的接口地址
    private static final String USER_INFO_URL = "https://api.weixin.qq.com/sns/userinfo";
    {
        new Thread(new Runnable() {
            @Override
@@ -95,24 +99,34 @@
     * @return
     */
    public Map<String, Object> code2Session(String jscode) throws Exception{
        System.err.println("看看调用奥");
        System.err.println("jsCode"+"========="+jscode);
        String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxAppletsAppid + "&secret=" + wxAppletsAppSecret
                + "&js_code=" + jscode + "&grant_type=authorization_code";
//        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="+wxAppletsAppid+"&secret="+wxAppletsAppSecret+"&code="+jscode+"&grant_type=authorization_code";
        HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "form");
        if(null == httpResult || httpResult.getCode() != 200){
            return null;
        }
        JSONObject jsonObject = JSON.parseObject(httpResult.getData());
        System.err.println("返回json串"+jsonObject);
        int errcode = jsonObject.getIntValue("errcode");
        Map<String, Object> map = new HashMap<>();
        map.put("errcode", errcode);
        System.err.println("返回code"+errcode);
        System.err.println("调用返回"+jsonObject);
        System.err.println("响应结果"+httpResult);
        if(errcode == 0){//成功
            Map<String, Object> userInfo = getUserInfo(jsonObject.getString("session_key"), jsonObject.getString("openid"));
            System.err.println(userInfo);
            // 用户名
//            String nickname = userInfo.get("nickname").toString();
//            // 用户头像
//            String headimgurl = userInfo.get("headimgurl").toString();
//            System.err.println("用户名:"+nickname);
//            System.err.println("头像:"+headimgurl);
            map.put("openid", jsonObject.getString("openid"));
            map.put("sessionKey", jsonObject.getString("session_key"));
            map.put("unionid", jsonObject.getString("unionid"));
            String wxAppletsAccessToken = getWxAppletsAccessToken();
            System.err.println("看看accesstoken:"+wxAppletsAccessToken);
            Map<String, Object> openid = getUserInfo(wxAppletsAccessToken, jsonObject.getString("openid"));
            System.err.println("用户信息:"+ openid);
            return map;
        }
        if(errcode == -1){//系统繁忙,此时请开发者稍候再试
@@ -145,6 +159,7 @@
        if(httpResult.getCode() != 200){
            return "";
        }
        System.err.println("获取AAAAAAAAAAAAAAAAAAAAAAAAAA:"+httpResult);
        JSONObject jsonObject = JSON.parseObject(httpResult.getData());
        return jsonObject.getString("access_token");
    }
@@ -191,8 +206,6 @@
        map.put("signature", signature);
        return  map;
    }
    /**
     * 网站应用登录
@@ -301,6 +314,29 @@
        return map;
    }
    /**
     * 获取微信用户的access_token
     *
     * @param code 微信小程序登录时获取的code
     * @return 包含access_token和openid的Map
     * @throws Exception
     */
    public  Map<String, String> getAccessToken(String code) throws Exception {
        OkHttpClient client = new OkHttpClient();
        String url = ACCESS_TOKEN_URL + "?appid=" +  wxAppletsAppid+ "&secret=" + wxAppletsAppSecret + "&code=" + code
                + "&grant_type=authorization_code";
        Request request = new Request.Builder().url(url).get().build();
        Response response = client.newCall(request).execute();
        String responseStr = response.body().string();
        System.err.println("响应结果"+responseStr);
        JSONObject jsonObject = JSON.parseObject(responseStr);
        String accessToken = jsonObject.getString("access_token");
        String openid = jsonObject.getString("openid");
        Map<String, String> map = new HashMap<>();
        map.put("access_token", accessToken);
        map.put("openid", openid);
        return map;
    }
    /***
     * 获取acess_token (公众号)
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/req/AddHouseReq.java
@@ -35,13 +35,12 @@
    private Integer dryingArea;
    @ApiModelProperty(value = "无(0=否,1=是)", required = true)
    private Integer air;
    @ApiModelProperty(value = "是否有阳台(0=否,1=是)", required = true)
    private Integer balcony;
    @ApiModelProperty(value = "是否有花园(0=否,1=是)", required = true)
    private Integer garden;
    @ApiModelProperty(value = "是否有平台(0=否,1=是)", required = true)
    private Integer platform;
    @ApiModelProperty(value = "是否有阳台(0=否,1=是)", required = true)
    private Integer balcony;
    @ApiModelProperty(value = "是否有花园(0=否,1=是)", required = true)
    private Integer garden;
    @ApiModelProperty(value = "是否有车位(0=否,1=是)", required = true)
    private Integer carport;
    @ApiModelProperty(value ="公司盘 0=否1=是",required = false)
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/req/HousingDemandReq.java
@@ -36,7 +36,7 @@
    private String floor;
    @ApiModelProperty("是否有电梯(0=否,1=是)")
    private Integer elevator;
    @ApiModelProperty("是否有天台(0=否,1=是)")
    @ApiModelProperty("晾晒区天台(0=否,1=是)")
    private Integer dryingArea;
    @ApiModelProperty("是否有花园(0=否,1=是)")
    private Integer garden;
@@ -46,7 +46,7 @@
    private Integer balcony;
    @ApiModelProperty("是否可养宠物(0=否,1=是)")
    private Integer keepPet;
    @ApiModelProperty(value = "是否有平台(0=否,1=是)", required = true)
    @ApiModelProperty(value = "晾晒区是否有平台(0=否,1=是)", required = true)
    private Integer platform;
    @ApiModelProperty("更多介绍")
    private String moreIntroduction;
@@ -54,7 +54,7 @@
    private Integer status;
    @ApiModelProperty(value ="1=保存并退出,2=发布",required = true)
    private Integer type;
    @ApiModelProperty("无(0=否,1=是)")
    @ApiModelProperty("晾晒区无(0=否,1=是)")
    private Integer air;
    @ApiModelProperty("是否公司盘(0=否,1=是)")
    private Integer firmHouse;
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/req/SearchHouseResourceReq.java
@@ -13,9 +13,9 @@
@Data
@ApiModel
public class SearchHouseResourceReq {
    @ApiModelProperty(value = "1=出租,2=卖房", required = true)
    @ApiModelProperty(value = "1=出租,2=卖房")
    private Integer type;
    @ApiModelProperty(value = "2=个人房源,3=中介房源,4=公司盘", required = true)
    @ApiModelProperty(value = "2=个人房源,3=中介房源,4=公司盘,5=首页列表 ")
    private Integer userType;
    @ApiModelProperty(value = "搜索内容", required = false)
    private String content;
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/AppletLoginRes.java
@@ -17,7 +17,7 @@
    @ApiModelProperty("登录用户类型1=普通用户 2=房东 3=中介")
    private Integer userType;
    @ApiModelProperty("1=未认证 2=已认证通过 3=已认证待审核 4=已认证被拒绝 ")
    @ApiModelProperty("0=未认证 1=已认证通过 2=已认证待审核 3=已认证被拒绝 ")
    private Integer state;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/CollectListRes.java
@@ -21,6 +21,10 @@
    private Integer appuserId;
    @ApiModelProperty("房源类型 1=出租 2=买卖")
    private Integer dataType;
    @ApiModelProperty("房屋类型id")
    private String houseTypeId;
    @ApiModelProperty("房屋类型名称")
    private String houseTypeName;
    @ApiModelProperty("标题")
    private String title;
    @ApiModelProperty("市id")
@@ -40,17 +44,19 @@
    @ApiModelProperty("发布时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date insertTime;
    @ApiModelProperty("发布时间")
    private String time;
    @ApiModelProperty("展示使用的房源id")
    private String code;
    @ApiModelProperty("是否有电梯(0=否,1=是)")
    private Integer elevator;
    @ApiModelProperty("是否有晾晒区(0=否,1=是)")
    @ApiModelProperty("晾晒区天台(0=否,1=是)")
    private Integer dryingArea;
    @ApiModelProperty("是否有花园(0=否,1=是)")
    private Integer garden;
    @ApiModelProperty("是否有车位(0=否,1=是)")
    private Integer carport;
    @ApiModelProperty("是否有平台(0=否,1=是)")
    @ApiModelProperty("是否有阳台(0=否,1=是)")
    private Integer balcony;
    @ApiModelProperty("是否可养宠物(0=否,1=是)")
    private Integer keepPet;
@@ -80,7 +86,8 @@
    private Date upTime;
    @ApiModelProperty("阳台 花园 。。。")
    private String head;
    @ApiModelProperty("房源审核状态")
    private Integer authStatus;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/ContactInformationRes.java
@@ -12,7 +12,7 @@
@ApiModel
public class ContactInformationRes {
    @ApiModelProperty("WhatsApp")
    private String whatsApp;
    private String watchApp;
    @ApiModelProperty("电话号码")
    private String phone;
    @ApiModelProperty("微信二维码")
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/HouseResourceInfoRes.java
@@ -37,6 +37,8 @@
    private Integer elevator;
    @ApiModelProperty("是否有晾晒区(0=否,1=是)")
    private Integer dryingArea;
    @ApiModelProperty("是否有晾晒区拼接")
    private String dryingAreas;
    @ApiModelProperty("面积")
    private String houseArea;
    @ApiModelProperty("是否可养宠物(0=否,1=是)")
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/HousingDemandInfoRes.java
@@ -32,10 +32,10 @@
    private String houseType;
    @ApiModelProperty("楼层")
    private String floor;
    @ApiModelProperty("是否有电梯(0=否,1=是)")
    @ApiModelProperty("是否有电梯(0=否,1=是 2不限)")
    private Integer elevator;
    @ApiModelProperty("是否有晾晒区(0=否,1=是)")
    private Integer dryingArea;
    @ApiModelProperty("是否有晾晒区")
    private String dryingArea;
    @ApiModelProperty("面积")
    private String houseArea;
    @ApiModelProperty("是否可养宠物(0=否,1=是)")
@@ -62,4 +62,5 @@
    private Integer collection;
    @ApiModelProperty("求房源二维码")
    private String qrCode;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/SearchHouseResourceListRes.java
@@ -35,6 +35,8 @@
    private String profilePhoto;
    @ApiModelProperty("昵称")
    private String nickname;
    @ApiModelProperty("房屋类型名称")
    private String houseTypeName;
    @ApiModelProperty("是否有电梯(0=否,1=是)")
    private Integer elevator;
    @ApiModelProperty("是否有天台(0=否,1=是)")
@@ -53,4 +55,6 @@
    private Integer keepPet;
    @ApiModelProperty("租期")
    private String leaseTime;
    @ApiModelProperty("是否为平台添加")
    private Integer isManage;
}
guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/res/SearchHousingDemandListRes.java
@@ -27,6 +27,10 @@
    private String title;
    @ApiModelProperty("户型")
    private String houseModel;
    @ApiModelProperty("房屋类型id")
    private String houseTypeId;
    @ApiModelProperty("房屋类型名称")
    private String houseTypeName;
    @ApiModelProperty("地址")
    private List<String> address;
    @ApiModelProperty("价格")
@@ -43,14 +47,12 @@
    private Integer dryingArea;
    @ApiModelProperty("是否有阳台(0=否,1=是)")
    private Integer balcony;
    @ApiModelProperty("是否有车位(0=否,1=是)")
    private Integer carport;
    @ApiModelProperty("是否有平台(0=否,1=是)")
    private Integer platform;
    @ApiModelProperty("是否有花园(0=否,1=是)")
    private Integer garden;
    @ApiModelProperty("是否可养宠物(0=否,1=是)")
    private Integer keepPet;
    @ApiModelProperty("类型 1=草稿 2=发布")
@@ -64,4 +66,6 @@
    private Integer viewsNumber;
    @ApiModelProperty("收藏量")
    private Integer collect;
    @ApiModelProperty("顶上去时间")
    private Date upTime;
}
guns-admin/src/main/resources/application-dev.yml
@@ -1,5 +1,5 @@
server:
  port: 82
  port: 81
spring:
  datasource:
@@ -58,17 +58,14 @@
  data:
    mongodb:
      # 指定MongoDB服务地址
      host: 192.168.110.64
      host: 192.168.110.188
      # 指定端口,默认就为27017
      port: 27017
      # 指定使用的数据库(集合)
      database: applet
      # 登录认证的逻辑库名
      authentication-database: applet
      # 用户名
      username: root
      # 密码
      password: root
---
oss:
  endpoint: oss-cn-hongkong.aliyuncs.com