| | |
| | | package com.stylefeng.guns.modular.api; |
| | | |
| | | import com.stylefeng.guns.modular.system.model.AppUser; |
| | | import com.stylefeng.guns.modular.system.model.FeedBack; |
| | | import com.stylefeng.guns.modular.system.model.HouseResource; |
| | | import com.stylefeng.guns.modular.system.service.IAppUserService; |
| | | import com.stylefeng.guns.modular.system.service.IFeedBackService; |
| | | import com.stylefeng.guns.modular.system.service.IHouseResourceService; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | 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.Page; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.warpper.req.*; |
| | | import com.stylefeng.guns.modular.system.warpper.res.AppletLoginRes; |
| | |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | private IFeedBackService feedBackService; |
| | | @Autowired |
| | | private IHouseResourceService houseResourceService; |
| | | |
| | | |
| | | @Autowired |
| | | private IHousingDemandService housingDemandService; |
| | | @Autowired |
| | | private IHouseTypeService houseTypeService; |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | @Autowired |
| | | private IBannerService bannerService; |
| | | @ResponseBody |
| | | @GetMapping("/base/appUser/agreement") |
| | | @ApiOperation(value = "协议", tags = {"协议"}) |
| | | public ResultUtil agreement(Integer type){ |
| | | Banner banners = bannerService.selectOne(new EntityWrapper<Banner>().eq("position",type)); |
| | | return ResultUtil.success(banners); |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/appUser/appletLogin") |
| | | @ApiOperation(value = "微信小程序登录", tags = {"登录注册"}) |
| | |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header") |
| | | }) |
| | | public ResultUtil<AppUser> userInfo(){ |
| | | |
| | | return appUserService.userInfo(); |
| | | } |
| | | |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", required = true, paramType = "header") |
| | | }) |
| | | public ResultUtil<CollectRes> release(){ |
| | | return appUserService.collect(); |
| | | public ResultUtil<CollectRes> release(UserInfoQuery query){ |
| | | return appUserService.collect(query); |
| | | } |
| | | |
| | | // todo 放行 |
| | |
| | | return appUserService.release(query); |
| | | } |
| | | |
| | | |
| | | // todo 放行 |
| | | @ResponseBody |
| | | @GetMapping("/base/appUser/edit/{id}") |
| | | @GetMapping("/base/appUser/edit/{id}/{data}") |
| | | @ApiOperation(value = "编辑发布的房源", tags = {"个人中心"}) |
| | | public ResultUtil<HouseResource> edit(@PathVariable("id") Integer id){ |
| | | |
| | | return ResultUtil.success(houseResourceService.selectById(id)); |
| | | public ResultUtil<Object> edit(@PathVariable("id") Integer id,@PathVariable("data")Integer type){ |
| | | // type=1 求房源 |
| | | if (type == 1){ |
| | | HousingDemand housingDemand = housingDemandService.selectById(id); |
| | | if (StringUtils.hasLength(housingDemand.getDistrict())){ |
| | | JSONArray jsonArray = JSON.parseArray(housingDemand.getDistrict()); |
| | | housingDemand.setDistrict(jsonArray.toString()); |
| | | } |
| | | if (housingDemand.getHouseTypeId()!=null && (!housingDemand.getHouseTypeId().equals("0"))){ |
| | | HouseType houseType = houseTypeService.selectById(housingDemand.getHouseTypeId()); |
| | | housingDemand.setHouseTypeName(houseType.getName()); |
| | | } |
| | | if (housingDemand.getHouseTypeId()!=null && housingDemand.getHouseTypeId().equals("0")){ |
| | | housingDemand.setHouseTypeName("不限"); |
| | | } |
| | | // 查询求房源选择的区域 |
| | | 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 (houseResource.getCityId()!=null){ |
| | | Region region = regionService.selectById(houseResource.getCityId()); |
| | | houseResource.setCityName(region.getName()); |
| | | } |
| | | if (houseResource.getDistrictId()!=null && houseResource.getDistrictId()==0){ |
| | | houseResource.setDistrictName("不限"); |
| | | }else{ |
| | | Region region = regionService.selectById(houseResource.getDistrictId()); |
| | | houseResource.setDistrictName(region.getName()); |
| | | } |
| | | return ResultUtil.success(houseResource); |
| | | } |
| | | } |
| | | // todo 放行 |
| | | @ResponseBody |
| | |
| | | @ApiOperation(value = "中介认证", tags = {"个人中心"}) |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", |
| | | required = true, paramType = "header") |
| | | public ResultUtil auth(@RequestBody AppUser appUser){ |
| | | public ResultUtil auth(@RequestBody AuthDTO dto){ |
| | | AppUser appUser1 = appUserService.getAppUser(); |
| | | appUser1.setAgentLicenceCode(appUser.getAgentLicenceCode()); |
| | | appUser1.setCompanyName(appUser.getCompanyName()); |
| | | appUser1.setCompanyAddress(appUser.getCompanyAddress()); |
| | | appUser1.setBusinessCardPhoto(appUser.getBusinessCardPhoto()); |
| | | appUser1.setCityId(appUser.getCityId()); |
| | | appUser1.setDistrictId(appUser.getDistrictId()); |
| | | appUser1.setAuditStatus(1); |
| | | 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); |
| | | return ResultUtil.success(); |
| | | } |
| | | // // todo 放行 |
| | | // @ResponseBody |
| | | // @GetMapping("/base/appUser/editSubmit") |
| | | // @ApiOperation(value = "编辑提交", tags = {"个人中心"}) |
| | | // @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", |
| | | // required = true, paramType = "header") |
| | | // public ResultUtil editSubmit(@RequestBody AddHouseReq req){ |
| | | // HouseResource houseResource = new HouseResource(); |
| | | // BeanUtils.copyProperties(req,houseResource); |
| | | // houseResource.setInsertTime(new Date()); |
| | | // houseResource.setAuthStatus(1); |
| | | // houseResource.setIsDelete(0); |
| | | // houseResource.setUpdateUserId(appUserService.getAppUser().getId()); |
| | | // houseResource.setUpdateTime(new Date()); |
| | | // houseResource.setStatus(0); |
| | | // houseResource.setLeaseTime(req.getTime()); |
| | | // houseResource.setFirmHouse(req.getFirmHouse()); |
| | | // if (req.getTime().contains("年")){ |
| | | // houseResource.setRentalDuration(2); |
| | | // }else{ |
| | | // houseResource.setRentalDuration(1); |
| | | // } |
| | | // return ResultUtil.success(); |
| | | // } |
| | | // todo 放行 |
| | | @ResponseBody |
| | | @GetMapping("/base/appUser/editSubmit") |
| | | @ApiOperation(value = "编辑提交", tags = {"个人中心"}) |
| | | @PostMapping("/base/appUser/operate") |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer eyJhbGciOiJIUzUxMiJ....", |
| | | required = true, paramType = "header") |
| | | public ResultUtil editSubmit(@RequestBody AddHouseReq req){ |
| | | HouseResource houseResource = new HouseResource(); |
| | | BeanUtils.copyProperties(req,houseResource); |
| | | houseResource.setInsertTime(new Date()); |
| | | houseResource.setAuthStatus(1); |
| | | houseResource.setIsDelete(0); |
| | | houseResource.setUpdateUserId(appUserService.getAppUser().getId()); |
| | | houseResource.setUpdateTime(new Date()); |
| | | houseResource.setStatus(0); |
| | | houseResource.setLeaseTime(req.getTime()); |
| | | houseResource.setFirmHouse(req.getFirmHouse()); |
| | | if (req.getTime().contains("年")){ |
| | | houseResource.setRentalDuration(2); |
| | | }else{ |
| | | houseResource.setRentalDuration(1); |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | // todo 放行 |
| | | @ResponseBody |
| | | @GetMapping("/base/appUser/operate") |
| | | @ApiOperation(value = "发布-删除/下架/顶上去", tags = {"个人中心"}) |
| | | @ApiOperation(value = "发布-删除/下架/顶上去/上架", tags = {"个人中心"}) |
| | | public ResultUtil delete(@RequestBody UserInfoDTO dto){ |
| | | AppUser appUser = appUserService.getAppUser(); |
| | | Integer id = appUser.getId(); |
| | | if (dto.getData() == 2){ |
| | | switch (dto.getType()){ |
| | | case 1: |
| | | HouseResource houseResource = houseResourceService.selectById(dto.getId()); |
| | |
| | | case 3: |
| | | HouseResource houseResource2 = houseResourceService.selectById(dto.getId()); |
| | | houseResource2.setInsertTime(new Date()); |
| | | houseResource2.setUpTime(new Date()); |
| | | 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条房源信息"); |
| | | } |
| | | } |
| | | HouseResource houseResource3 = houseResourceService.selectById(dto.getId()); |
| | | houseResource3.setStatus(1); |
| | | houseResourceService.updateById(houseResource3); |
| | | break; |
| | | } |
| | | }else{ |
| | | switch (dto.getType()){ |
| | | case 1: |
| | | HousingDemand houseResource = housingDemandService.selectById(dto.getId()); |
| | | houseResource.setIsDelete(1); |
| | | housingDemandService.updateById(houseResource); |
| | | break; |
| | | case 2: |
| | | HousingDemand houseResource1 = housingDemandService.selectById(dto.getId()); |
| | | houseResource1.setStatus(0); |
| | | housingDemandService.updateById(houseResource1); |
| | | break; |
| | | case 3: |
| | | HousingDemand houseResource2 = housingDemandService.selectById(dto.getId()); |
| | | houseResource2.setInsertTime(new Date()); |
| | | housingDemandService.updateById(houseResource2); |
| | | break; |
| | | case 4: |
| | | HousingDemand houseResource3 = housingDemandService.selectById(dto.getId()); |
| | | houseResource3.setStatus(1); |
| | | housingDemandService.updateById(houseResource3); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return ResultUtil.success(); |