Browse Source
- 在多个控制器和服务中,将 Date 替换为 LocalDateTime - 更新日期格式化相关代码,以适应 LocalDateTime - 删除了一些未使用的日期工具类导入main
8 changed files with 39 additions and 113 deletions
@ -1,74 +0,0 @@ |
|||||
package com.gxwebsoft.house.controller; |
|
||||
|
|
||||
import com.gxwebsoft.common.core.web.ApiResult; |
|
||||
import com.gxwebsoft.common.core.web.BaseController; |
|
||||
import com.gxwebsoft.house.entity.HouseInfo; |
|
||||
import com.gxwebsoft.house.service.HouseInfoService; |
|
||||
import io.swagger.v3.oas.annotations.Operation; |
|
||||
import io.swagger.v3.oas.annotations.tags.Tag; |
|
||||
import org.springframework.web.bind.annotation.PostMapping; |
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||
import org.springframework.web.bind.annotation.RestController; |
|
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
import java.math.BigDecimal; |
|
||||
import java.time.LocalDateTime; |
|
||||
|
|
||||
/** |
|
||||
* 房源测试数据控制器 |
|
||||
* |
|
||||
* @author 科技小王子 |
|
||||
* @since 2025-08-07 |
|
||||
*/ |
|
||||
@Tag(name = "房源测试数据管理") |
|
||||
@RestController |
|
||||
@RequestMapping("/api/house/test-data") |
|
||||
public class HouseTestDataController extends BaseController { |
|
||||
|
|
||||
@Resource |
|
||||
private HouseInfoService houseInfoService; |
|
||||
|
|
||||
@Operation(summary = "创建测试数据") |
|
||||
@PostMapping("/create") |
|
||||
public ApiResult<?> createTestData() { |
|
||||
try { |
|
||||
// 创建5个测试房源,价格不同
|
|
||||
createTestHouse("碧园大厦B", "223", new BigDecimal("8920"), 10058); |
|
||||
createTestHouse("碧园大厦B", "155", new BigDecimal("6200"), 10058); |
|
||||
createTestHouse("碧园大厦B", "92", new BigDecimal("3680"), 10058); |
|
||||
createTestHouse("龙光国际A", "99", new BigDecimal("4455"), 10058); |
|
||||
createTestHouse("万达广场C", "120", new BigDecimal("5500"), 10058); |
|
||||
|
|
||||
return success("测试数据创建成功!"); |
|
||||
} catch (Exception e) { |
|
||||
return fail("创建测试数据失败:" + e.getMessage()); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private void createTestHouse(String title, String extent, BigDecimal monthlyRent, Integer tenantId) { |
|
||||
HouseInfo house = new HouseInfo(); |
|
||||
house.setHouseTitle(title); |
|
||||
house.setExtent(extent); |
|
||||
house.setMonthlyRent(monthlyRent); |
|
||||
house.setRent(monthlyRent); |
|
||||
house.setTenantId(tenantId); |
|
||||
house.setStatus(0); // 通过状态
|
|
||||
house.setDeleted(0); |
|
||||
house.setRecommend(0); |
|
||||
house.setUserId(1); |
|
||||
house.setCreateTime(new Date()); |
|
||||
house.setUpdateTime(new Date()); |
|
||||
house.setCityByHouse("南宁"); |
|
||||
house.setHouseType("办公室"); |
|
||||
house.setLeaseMethod("整租"); |
|
||||
house.setFloor("10层"); |
|
||||
house.setRealName("测试用户"); |
|
||||
house.setPhone("13800138000"); |
|
||||
house.setProvince("广西"); |
|
||||
house.setCity("南宁"); |
|
||||
house.setRegion("青秀区"); |
|
||||
house.setAddress("测试地址"); |
|
||||
|
|
||||
houseInfoService.save(house); |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue