update
This commit is contained in:
parent
7b9a0f2833
commit
48090cb4d3
@ -1,93 +0,0 @@
|
|||||||
package io.modules.sys.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import io.common.annotation.LogOperation;
|
|
||||||
import io.common.constant.Constant;
|
|
||||||
import io.common.page.PageData;
|
|
||||||
import io.common.utils.Result;
|
|
||||||
import io.common.validator.AssertUtils;
|
|
||||||
import io.modules.item.dto.CommentDTO;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.dto.UserDTO;
|
|
||||||
import io.modules.item.service.CommentService;
|
|
||||||
import io.modules.item.service.HouseService;
|
|
||||||
import io.modules.item.service.UserService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 评论表
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/sys/comment")
|
|
||||||
@Tag(name="评论表")
|
|
||||||
@CrossOrigin
|
|
||||||
public class CommentController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CommentService commentService;
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
@Autowired
|
|
||||||
private HouseService itemService;
|
|
||||||
|
|
||||||
@Value("${upload.url}")
|
|
||||||
private String uploadUrl;
|
|
||||||
|
|
||||||
@GetMapping("page")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String"),
|
|
||||||
@Parameter(name = "itemId", description = "关联编号", in = ParameterIn.QUERY, ref="String")
|
|
||||||
})
|
|
||||||
public Result<PageData<CommentDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
|
|
||||||
PageData<CommentDTO> page = commentService.page(params);
|
|
||||||
List<CommentDTO> updatedPage = page.getList().stream()
|
|
||||||
.map(comment -> {
|
|
||||||
Long userId = comment.getUserId();
|
|
||||||
// 如果缓存中已经存在该用户的信息,直接使用
|
|
||||||
UserDTO user = userService.get(userId);
|
|
||||||
if (user != null) {
|
|
||||||
// 否则调用 userService 获取用户信息并缓存
|
|
||||||
comment.setNickName(user.getNickName()); // 设置昵称
|
|
||||||
}
|
|
||||||
Long itemId = comment.getItemId();
|
|
||||||
HouseDTO itemDTO = itemService.get(itemId);
|
|
||||||
if (itemDTO != null){
|
|
||||||
itemDTO.setImage(uploadUrl + itemDTO.getImage());;
|
|
||||||
}
|
|
||||||
comment.setItemDTO(itemDTO);
|
|
||||||
return comment;
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
page.setList(updatedPage);
|
|
||||||
return new Result<PageData<CommentDTO>>().ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
@LogOperation("删除")
|
|
||||||
public Result delete(@PathVariable Long id){
|
|
||||||
Long[] ids = new Long[] { id };
|
|
||||||
//效验数据
|
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
|
||||||
commentService.delete(ids);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
package io.modules.sys.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import io.common.annotation.LogOperation;
|
|
||||||
import io.common.constant.Constant;
|
|
||||||
import io.common.page.PageData;
|
|
||||||
import io.common.utils.Result;
|
|
||||||
import io.common.validator.AssertUtils;
|
|
||||||
import io.common.validator.ValidatorUtils;
|
|
||||||
import io.common.validator.group.AddGroup;
|
|
||||||
import io.common.validator.group.DefaultGroup;
|
|
||||||
import io.common.validator.group.UpdateGroup;
|
|
||||||
import io.modules.item.dto.CategoriesDTO;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.entity.ViewEntity;
|
|
||||||
import io.modules.item.service.CategoriesService;
|
|
||||||
import io.modules.item.service.HouseService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主表
|
|
||||||
*/
|
|
||||||
@CrossOrigin
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("sys/house")
|
|
||||||
@Tag(name = "主表")
|
|
||||||
public class HouseController {
|
|
||||||
@Autowired
|
|
||||||
private HouseService itemService;
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("query")
|
|
||||||
@Operation(summary = "首页顶部展示")
|
|
||||||
public Result<List<Object>> page() {
|
|
||||||
List<Object> res = itemService.query();
|
|
||||||
return new Result<List<Object>>().ok(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("view1")
|
|
||||||
@Operation(summary = "首页分析1")
|
|
||||||
public Result<List<ViewEntity>> view1() {
|
|
||||||
List<ViewEntity> res = itemService.view1();
|
|
||||||
return new Result<List<ViewEntity>>().ok(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("page")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
|
||||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
|
||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
|
||||||
@Parameter(name = "status", description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String")
|
|
||||||
})
|
|
||||||
public Result<PageData<HouseDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
|
||||||
|
|
||||||
PageData<HouseDTO> page = itemService.page(params);
|
|
||||||
List<HouseDTO> list = page.getList().stream().map(e -> {
|
|
||||||
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
page.setList(list);
|
|
||||||
return new Result<PageData<HouseDTO>>().ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
|
||||||
@Operation(summary = "信息")
|
|
||||||
public Result<HouseDTO> get(@PathVariable("id") Long id) {
|
|
||||||
HouseDTO data = itemService.get(id);
|
|
||||||
return new Result<HouseDTO>().ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@Operation(summary = "保存")
|
|
||||||
public Result save(@RequestBody HouseDTO dto) {
|
|
||||||
//效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
||||||
itemService.save(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
@Operation(summary = "修改")
|
|
||||||
public Result update(@RequestBody HouseDTO dto) { //效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
||||||
itemService.update(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
@LogOperation("删除")
|
|
||||||
public Result delete(@PathVariable Long id) {
|
|
||||||
Long[] ids = new Long[]{id};
|
|
||||||
//效验数据
|
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
|
||||||
itemService.delete(ids);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
package io.modules.sys.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import io.common.constant.Constant;
|
|
||||||
import io.common.page.PageData;
|
|
||||||
import io.common.utils.Result;
|
|
||||||
import io.common.validator.AssertUtils;
|
|
||||||
import io.common.validator.ValidatorUtils;
|
|
||||||
import io.common.validator.group.AddGroup;
|
|
||||||
import io.common.validator.group.DefaultGroup;
|
|
||||||
import io.common.validator.group.UpdateGroup;
|
|
||||||
import io.modules.item.dao.FrontUserDao;
|
|
||||||
import io.modules.item.dto.AddressDTO;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.dto.OrderDTO;
|
|
||||||
import io.modules.item.entity.FrontUserEntity;
|
|
||||||
import io.modules.item.service.AddressService;
|
|
||||||
import io.modules.item.service.HouseService;
|
|
||||||
import io.modules.item.service.OrderService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单表
|
|
||||||
*
|
|
||||||
* @author Mark #
|
|
||||||
* @since 1.0.0 2025-02-14
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("sys/order")
|
|
||||||
@Tag(name="订单表")
|
|
||||||
@CrossOrigin
|
|
||||||
public class OrderController {
|
|
||||||
@Autowired
|
|
||||||
private OrderService orderService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private HouseService itemService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FrontUserDao frontUserDao;
|
|
||||||
|
|
||||||
@Value("${upload.url}")
|
|
||||||
private String uploadUrl;
|
|
||||||
|
|
||||||
@GetMapping("page")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
|
||||||
})
|
|
||||||
public Result<PageData<OrderDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params){
|
|
||||||
PageData<OrderDTO> page = orderService.page(params);
|
|
||||||
List<OrderDTO> collect = page.getList().stream().map(e -> {
|
|
||||||
HouseDTO item = itemService.get(e.getItemId());
|
|
||||||
if(item != null){
|
|
||||||
item.setImage(uploadUrl + item.getImage());
|
|
||||||
}
|
|
||||||
e.setItem(item);
|
|
||||||
FrontUserEntity frontUserEntity = frontUserDao.selectById(e.getUserId());
|
|
||||||
e.setUserEntity(frontUserEntity);
|
|
||||||
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
page.setList(collect);
|
|
||||||
return new Result<PageData<OrderDTO>>().ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
|
||||||
@Operation(summary = "信息")
|
|
||||||
public Result<OrderDTO> get(@PathVariable("id") Long id){
|
|
||||||
OrderDTO data = orderService.get(id);
|
|
||||||
|
|
||||||
return new Result<OrderDTO>().ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@Operation(summary = "保存")
|
|
||||||
public Result save(@RequestBody OrderDTO dto){
|
|
||||||
//效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
||||||
orderService.save(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
@Operation(summary = "修改")
|
|
||||||
public Result update(@RequestBody OrderDTO dto){
|
|
||||||
//效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
||||||
orderService.update(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
public Result delete(@RequestBody Long[] ids){
|
|
||||||
//效验数据
|
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
|
||||||
orderService.delete(ids);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package io.modules.item.dao;
|
|
||||||
|
|
||||||
import io.common.dao.BaseDao;
|
|
||||||
import io.modules.item.entity.HouseEntity;
|
|
||||||
import io.modules.item.entity.ViewEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主表
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface ItemDao extends BaseDao<HouseEntity> {
|
|
||||||
|
|
||||||
@Select("select * from obs_category_summary")
|
|
||||||
List<ViewEntity> view1();
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package io.modules.item.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 房源表
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@TableName("tb_house")
|
|
||||||
public class HouseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编号
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
private String title; // 标题
|
|
||||||
private String name; // 小区名称
|
|
||||||
private String city; // 城市
|
|
||||||
private String type; // 户型
|
|
||||||
private String area; // 面积
|
|
||||||
private Integer floor; // 楼层
|
|
||||||
private String face; // 朝向
|
|
||||||
private String decoration; // 装修
|
|
||||||
private String image; // 图片URL
|
|
||||||
private Double price; // 价格(元/平方)
|
|
||||||
private String description; // 描述
|
|
||||||
private String tag; // 标签(逗号分隔)
|
|
||||||
|
|
||||||
private String hex; // 区块链密钥/哈希
|
|
||||||
|
|
||||||
private Integer sort = 1; // 排序权重(默认1)
|
|
||||||
private Integer status = 0; // 状态:0未审核,1上架,2审核失败
|
|
||||||
private Integer view = 0; // 点击次数(默认0)
|
|
||||||
|
|
||||||
private Date createTime; // 创建时间(自动更新)
|
|
||||||
|
|
||||||
private Long userId; // 用户编号
|
|
||||||
|
|
||||||
}
|
|
@ -7,9 +7,6 @@ import java.util.Date;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 省份信息
|
* 省份信息
|
||||||
*
|
|
||||||
* @author Mark #
|
|
||||||
* @since 1.0.0 2025-02-14
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName("tb_province")
|
@TableName("tb_province")
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package io.modules.item.service;
|
|
||||||
|
|
||||||
import io.common.service.CrudService;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.entity.HouseEntity;
|
|
||||||
import io.modules.item.entity.ViewEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主表
|
|
||||||
*/
|
|
||||||
public interface HouseService extends CrudService<HouseEntity, HouseDTO> {
|
|
||||||
|
|
||||||
List<HouseEntity> score();
|
|
||||||
|
|
||||||
List<Object> query();
|
|
||||||
|
|
||||||
List<ViewEntity> view1();
|
|
||||||
|
|
||||||
List<HouseEntity> commit();
|
|
||||||
|
|
||||||
List<HouseEntity> listUser(Long userId);
|
|
||||||
}
|
|
@ -1,133 +0,0 @@
|
|||||||
package io.modules.item.service.impl;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import io.common.service.impl.CrudServiceImpl;
|
|
||||||
import io.modules.item.dao.FrontUserDao;
|
|
||||||
import io.modules.item.dao.ItemDao;
|
|
||||||
import io.modules.item.dao.UserBehaviorDao;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.entity.HouseEntity;
|
|
||||||
import io.modules.item.entity.UserBehaviorEntity;
|
|
||||||
import io.modules.item.entity.ViewEntity;
|
|
||||||
import io.modules.item.service.HouseService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主表
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class HouseServiceImpl extends CrudServiceImpl<ItemDao, HouseEntity, HouseDTO> implements HouseService {
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private FrontUserDao frontUserDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserBehaviorDao userBehaviorDao;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryWrapper<HouseEntity> getWrapper(Map<String, Object> params){
|
|
||||||
String title = (String)params.get("title");
|
|
||||||
String status = (String)params.get("status");
|
|
||||||
String view = (String)params.get("view");
|
|
||||||
String userId = (String)params.get("userId");
|
|
||||||
|
|
||||||
QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>();
|
|
||||||
wrapper.like(StrUtil.isNotBlank(title), "title", title);
|
|
||||||
wrapper.like(StrUtil.isNotBlank(status), "status", status);
|
|
||||||
wrapper.like(StrUtil.isNotBlank(userId), "user_id", userId);
|
|
||||||
wrapper.orderByDesc(StrUtil.isNotBlank(view), "view");
|
|
||||||
wrapper.orderByDesc("create_time");
|
|
||||||
return wrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<HouseEntity> score() {
|
|
||||||
LambdaQueryWrapper<HouseEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.orderByDesc(HouseEntity::getView);
|
|
||||||
|
|
||||||
|
|
||||||
// 创建 Page 对象,设置当前页和每页大小
|
|
||||||
Page<HouseEntity> page = new Page<>(1, 10); // 第1页,每页10条
|
|
||||||
|
|
||||||
// 执行分页查询
|
|
||||||
IPage<HouseEntity> result = baseDao.selectPage(page, lwq);
|
|
||||||
|
|
||||||
// 获取查询结果
|
|
||||||
List<HouseEntity> list = result.getRecords();
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Object> query() {
|
|
||||||
ArrayList<Object> res = new ArrayList<>();
|
|
||||||
Long item_total = baseDao.selectCount(null);
|
|
||||||
//查询数据总和
|
|
||||||
HashMap<String, Object> a1 = new HashMap<>();
|
|
||||||
a1.put("name", "商品总量");
|
|
||||||
a1.put("value", item_total);
|
|
||||||
a1.put("tag", "条");
|
|
||||||
res.add(a1);
|
|
||||||
|
|
||||||
HashMap<String, Object> a2 = new HashMap<>();
|
|
||||||
a2.put("name", "用户总量");
|
|
||||||
a2.put("value", frontUserDao.selectCount(null));
|
|
||||||
a2.put("tag", "位");
|
|
||||||
res.add(a2);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ViewEntity> view1() {
|
|
||||||
List<ViewEntity> res = baseDao.view1();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<HouseEntity> commit() {
|
|
||||||
LambdaQueryWrapper<HouseEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.orderByDesc(HouseEntity::getView);
|
|
||||||
|
|
||||||
// 创建 Page 对象,设置当前页和每页大小
|
|
||||||
Page<HouseEntity> page = new Page<>(1, 10); // 第1页,每页10条
|
|
||||||
|
|
||||||
// 执行分页查询
|
|
||||||
IPage<HouseEntity> result = baseDao.selectPage(page, lwq);
|
|
||||||
|
|
||||||
// 获取查询结果
|
|
||||||
List<HouseEntity> list = result.getRecords();
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<HouseEntity> listUser(Long userId) {
|
|
||||||
LambdaQueryWrapper<UserBehaviorEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.eq(UserBehaviorEntity::getUserId,userId);
|
|
||||||
lwq.eq(UserBehaviorEntity::getType,1);
|
|
||||||
List<UserBehaviorEntity> list = userBehaviorDao.selectList(lwq);
|
|
||||||
if (list.isEmpty()){
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
List<HouseEntity> res = new ArrayList<>();
|
|
||||||
|
|
||||||
for (UserBehaviorEntity userBehaviorEntity : list) {
|
|
||||||
HouseEntity itemEntity = baseDao.selectById(userBehaviorEntity.getItemId());
|
|
||||||
if (itemEntity != null){
|
|
||||||
res.add(itemEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +1,8 @@
|
|||||||
package io.config;
|
package io.config;
|
||||||
|
|
||||||
|
import io.modules.item.dao.BookDao;
|
||||||
import io.modules.item.dao.ItemDao;
|
|
||||||
import io.modules.item.dao.OrderDao;
|
import io.modules.item.dao.OrderDao;
|
||||||
import io.modules.item.entity.HouseEntity;
|
import io.modules.item.entity.BookEntity;
|
||||||
import io.modules.item.entity.OrderEntity;
|
import io.modules.item.entity.OrderEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -25,7 +24,7 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class MyScheduledTask {
|
public class MyScheduledTask {
|
||||||
@Autowired
|
@Autowired
|
||||||
ItemDao itemDao;
|
BookDao itemDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
OrderDao orderDao;
|
OrderDao orderDao;
|
||||||
|
|
||||||
@ -33,8 +32,8 @@ public class MyScheduledTask {
|
|||||||
@Scheduled(fixedRate = 5000)
|
@Scheduled(fixedRate = 5000)
|
||||||
public void runEveryFiveSeconds1() {
|
public void runEveryFiveSeconds1() {
|
||||||
//需要检测的hex字段
|
//需要检测的hex字段
|
||||||
List<HouseEntity> list = itemDao.selectList(null);
|
List<BookEntity> list = itemDao.selectList(null);
|
||||||
for (HouseEntity itemEntity : list) {
|
for (BookEntity itemEntity : list) {
|
||||||
if (!isValidEthereumHexId(itemEntity.getHex(),64)){
|
if (!isValidEthereumHexId(itemEntity.getHex(),64)){
|
||||||
itemEntity.setHex(sendSetRequest(itemEntity.getId().toString(),itemEntity.toString()));
|
itemEntity.setHex(sendSetRequest(itemEntity.getId().toString(),itemEntity.toString()));
|
||||||
//更新数据
|
//更新数据
|
||||||
|
@ -1,113 +0,0 @@
|
|||||||
package io.controller;
|
|
||||||
|
|
||||||
|
|
||||||
import io.annotation.Login;
|
|
||||||
import io.common.constant.Constant;
|
|
||||||
import io.common.page.PageData;
|
|
||||||
import io.common.utils.Result;
|
|
||||||
import io.common.validator.AssertUtils;
|
|
||||||
import io.common.validator.ValidatorUtils;
|
|
||||||
import io.common.validator.group.AddGroup;
|
|
||||||
import io.common.validator.group.DefaultGroup;
|
|
||||||
import io.common.validator.group.UpdateGroup;
|
|
||||||
import io.modules.item.dto.CartDTO;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.service.CartService;
|
|
||||||
import io.modules.item.service.HouseService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 购物车
|
|
||||||
*
|
|
||||||
* @author Mark #
|
|
||||||
* @since 1.0.0 2025-03-12
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("api/cart")
|
|
||||||
@Tag(name="购物车")
|
|
||||||
@CrossOrigin
|
|
||||||
public class CartController {
|
|
||||||
@Autowired
|
|
||||||
private CartService cartService;
|
|
||||||
@Value("${upload.url}")
|
|
||||||
private String uploadUrl;
|
|
||||||
@Autowired
|
|
||||||
private HouseService itemService;
|
|
||||||
|
|
||||||
@GetMapping("page")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
|
||||||
})
|
|
||||||
@Login
|
|
||||||
public Result<PageData<CartDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params,@Parameter(hidden = true) @RequestAttribute("userId") Long userId){
|
|
||||||
params.put("userId",userId.toString());
|
|
||||||
PageData<CartDTO> page = cartService.page(params);
|
|
||||||
|
|
||||||
List<CartDTO> collect = page.getList().stream().map(e -> {
|
|
||||||
Long productId = e.getProductId();
|
|
||||||
HouseDTO itemDTO = itemService.get(productId);
|
|
||||||
if (itemDTO != null) {
|
|
||||||
itemDTO.setImage(uploadUrl + itemDTO.getImage());
|
|
||||||
e.setItem(itemDTO);
|
|
||||||
}
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
page.setList(collect);
|
|
||||||
return new Result<PageData<CartDTO>>().ok(page);
|
|
||||||
}
|
|
||||||
@GetMapping("{id}")
|
|
||||||
@Operation(summary = "信息")
|
|
||||||
public Result<CartDTO> get(@PathVariable("id") Long id){
|
|
||||||
CartDTO data = cartService.get(id);
|
|
||||||
|
|
||||||
return new Result<CartDTO>().ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@Operation(summary = "保存")
|
|
||||||
@Login
|
|
||||||
public Result save(@RequestBody CartDTO dto,@Parameter(hidden = true) @RequestAttribute("userId") Long userId){
|
|
||||||
dto.setUserId(userId);
|
|
||||||
//效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
||||||
cartService.save(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
@Operation(summary = "修改")
|
|
||||||
public Result update(@RequestBody CartDTO dto){
|
|
||||||
//效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
||||||
cartService.update(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
public Result delete(@PathVariable Long id) {
|
|
||||||
Long[] ids = new Long[]{id};
|
|
||||||
//效验数据
|
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
|
||||||
cartService.delete(ids);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,187 +0,0 @@
|
|||||||
package io.controller;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import io.annotation.Login;
|
|
||||||
import io.common.constant.Constant;
|
|
||||||
import io.common.page.PageData;
|
|
||||||
import io.common.utils.Result;
|
|
||||||
import io.common.validator.AssertUtils;
|
|
||||||
import io.common.validator.ValidatorUtils;
|
|
||||||
import io.common.validator.group.AddGroup;
|
|
||||||
import io.common.validator.group.DefaultGroup;
|
|
||||||
import io.common.validator.group.UpdateGroup;
|
|
||||||
import io.modules.item.dao.ItemDao;
|
|
||||||
import io.modules.item.dto.HouseDTO;
|
|
||||||
import io.modules.item.dto.OrderDTO;
|
|
||||||
import io.modules.item.entity.HouseEntity;
|
|
||||||
import io.modules.item.service.HouseService;
|
|
||||||
import io.modules.item.service.OrderService;
|
|
||||||
import io.modules.item.service.UserBehaviorService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@CrossOrigin
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/item")
|
|
||||||
@Tag(name = "主表")
|
|
||||||
public class ItemController {
|
|
||||||
@Autowired
|
|
||||||
private HouseService houseService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ItemDao itemDao;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderService orderService;
|
|
||||||
@Autowired
|
|
||||||
private UserBehaviorService userBehaviorService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("page")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref = "int"),
|
|
||||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY, required = true, ref = "int"),
|
|
||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref = "String"),
|
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
|
||||||
@Parameter(name = "status", description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref = "String"),
|
|
||||||
@Parameter(name = "view", description = "预览排序", in = ParameterIn.QUERY, ref = "String"),
|
|
||||||
})
|
|
||||||
public Result<PageData<HouseDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params) {
|
|
||||||
|
|
||||||
PageData<HouseDTO> page = houseService.page(params);
|
|
||||||
List<HouseDTO> list = page.getList().stream().map(e -> {
|
|
||||||
|
|
||||||
// 获取评价信息
|
|
||||||
List<OrderDTO> orderEntityList = orderService.getCommintList(e.getId());
|
|
||||||
e.setOrderEntityList(orderEntityList);
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
page.setList(list);
|
|
||||||
return new Result<PageData<HouseDTO>>().ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@GetMapping("push")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
public Result<List<HouseDTO>> page(@Parameter(hidden = true) @RequestParam Map<String, Object> params,@Parameter(hidden = true) @RequestAttribute("userId") Long userId) {
|
|
||||||
params.put("userId",userId.toString());
|
|
||||||
List<HouseDTO> page = houseService.list(params);
|
|
||||||
List<HouseDTO> list = page.stream().map(e -> {
|
|
||||||
// 获取评价信息
|
|
||||||
List<OrderDTO> orderEntityList = orderService.getCommintList(e.getId());
|
|
||||||
e.setOrderEntityList(orderEntityList);
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return new Result<List<HouseDTO>>().ok(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@GetMapping("list")
|
|
||||||
@Operation(summary = "查询收藏")
|
|
||||||
public Result<List<HouseEntity>> list(@Parameter(hidden = true) @RequestAttribute("userId") Long userId) {
|
|
||||||
List<HouseEntity> page = houseService.listUser(userId);
|
|
||||||
List<HouseEntity> list = page.stream().map(e -> {
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return new Result<List<HouseEntity>>().ok(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("hex")
|
|
||||||
public Result<HouseEntity> hex(@RequestParam String hexId) {
|
|
||||||
LambdaQueryWrapper<HouseEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.eq(HouseEntity::getHex, hexId);
|
|
||||||
List<HouseEntity> itemEntities = itemDao.selectList(lwq);
|
|
||||||
if (itemEntities.isEmpty()) {
|
|
||||||
return new Result<HouseEntity>().error("查询不到相关商品");
|
|
||||||
}
|
|
||||||
HouseEntity itemEntity = itemEntities.get(0);
|
|
||||||
|
|
||||||
return new Result<HouseEntity>().ok(itemEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分析
|
|
||||||
@GetMapping("score")
|
|
||||||
@Operation(summary = "评分人数排行")
|
|
||||||
public Result<List<HouseEntity>> score() {
|
|
||||||
List<HouseEntity> list = houseService.score();
|
|
||||||
List<HouseEntity> res = list.stream().map(e -> {
|
|
||||||
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return new Result<List<HouseEntity>>().ok(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分析
|
|
||||||
@GetMapping("commit")
|
|
||||||
@Operation(summary = "评论人数排行")
|
|
||||||
public Result<List<HouseEntity>> commit() {
|
|
||||||
List<HouseEntity> list = houseService.commit();
|
|
||||||
List<HouseEntity> res = list.stream().map(e -> {
|
|
||||||
|
|
||||||
return e;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
return new Result<List<HouseEntity>>().ok(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
|
||||||
@Operation(summary = "信息")
|
|
||||||
public Result<HouseDTO> get(@PathVariable("id") Long id) {
|
|
||||||
|
|
||||||
//获取详情
|
|
||||||
HouseDTO data = houseService.get(id);
|
|
||||||
// 添加预览
|
|
||||||
data.setView(data.getView() + 1);
|
|
||||||
// 更新
|
|
||||||
houseService.update(data);
|
|
||||||
|
|
||||||
//是否收藏
|
|
||||||
data.setIsFavorite(userBehaviorService.getIsFavorite(data.getId(), 1));
|
|
||||||
return new Result<HouseDTO>().ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@Operation(summary = "保存")
|
|
||||||
public Result save(@RequestBody HouseDTO dto) {
|
|
||||||
//效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
|
||||||
houseService.save(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@PutMapping
|
|
||||||
@Operation(summary = "修改")
|
|
||||||
public Result update(@RequestBody HouseDTO dto) { //效验数据
|
|
||||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
|
||||||
|
|
||||||
|
|
||||||
houseService.update(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
public Result delete(@RequestBody Long[] ids) {
|
|
||||||
//效验数据
|
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
|
||||||
houseService.delete(ids);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,198 +0,0 @@
|
|||||||
package io.controller;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import io.annotation.Login;
|
|
||||||
import io.common.constant.Constant;
|
|
||||||
import io.common.page.PageData;
|
|
||||||
import io.common.utils.Result;
|
|
||||||
import io.common.validator.AssertUtils;
|
|
||||||
import io.modules.item.dao.ItemDao;
|
|
||||||
import io.modules.item.dao.OrderDao;
|
|
||||||
import io.modules.item.dto.*;
|
|
||||||
import io.modules.item.entity.HouseEntity;
|
|
||||||
import io.modules.item.entity.OrderEntity;
|
|
||||||
import io.modules.item.service.*;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
/**
|
|
||||||
* 订单表
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/order")
|
|
||||||
@Tag(name="订单表")
|
|
||||||
@CrossOrigin
|
|
||||||
public class OrderController {
|
|
||||||
@Autowired
|
|
||||||
private OrderService orderService;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private OrderDao orderDao;
|
|
||||||
@Autowired
|
|
||||||
private ItemDao itemDao;
|
|
||||||
@Autowired
|
|
||||||
private HouseService itemService;
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@GetMapping("page")
|
|
||||||
@Operation(summary = "分页")
|
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = Constant.PAGE, description = "当前页码,从1开始", in = ParameterIn.QUERY, required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.LIMIT, description = "每页显示记录数", in = ParameterIn.QUERY,required = true, ref="int") ,
|
|
||||||
@Parameter(name = Constant.ORDER_FIELD, description = "排序字段", in = ParameterIn.QUERY, ref="String") ,
|
|
||||||
@Parameter(name = Constant.ORDER, description = "排序方式,可选值(asc、desc)", in = ParameterIn.QUERY, ref="String")
|
|
||||||
})
|
|
||||||
public Result<PageData<OrderDTO>> page(@Parameter(hidden = true) @RequestAttribute("userId") Long userId,@Parameter(hidden = true) @RequestParam Map<String, Object> params){
|
|
||||||
params.put("userId",userId);
|
|
||||||
PageData<OrderDTO> page = orderService.page(params);
|
|
||||||
List<OrderDTO> collect = page.getList().stream().map(e -> {
|
|
||||||
//拼接商品名称
|
|
||||||
HouseDTO itemDTO = itemService.get(e.getItemId());
|
|
||||||
if (itemDTO != null) {
|
|
||||||
e.setItem(itemDTO);
|
|
||||||
}
|
|
||||||
HouseDTO houseDTO = itemService.get(e.getUserHouseId());
|
|
||||||
if (itemDTO != null) {
|
|
||||||
e.setItemA(houseDTO);
|
|
||||||
}
|
|
||||||
return e; // 返回修改后的对象
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
page.setList(collect);
|
|
||||||
return new Result<PageData<OrderDTO>>().ok(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Login
|
|
||||||
@GetMapping("list")
|
|
||||||
public Result<List<OrderDTO>> list(@Parameter(hidden = true) @RequestAttribute("userId") Long userId){
|
|
||||||
|
|
||||||
//查询用户下所有房源信息
|
|
||||||
LambdaQueryWrapper<HouseEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.eq(HouseEntity::getUserId,userId);
|
|
||||||
List<HouseEntity> houseEntities = itemDao.selectList(lwq);
|
|
||||||
if (houseEntities.isEmpty()){
|
|
||||||
return new Result<List<OrderDTO>>().ok(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Long> idList = houseEntities.stream()
|
|
||||||
.map(HouseEntity::getId)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
|
|
||||||
List<OrderEntity> orderEntities = new ArrayList<>();
|
|
||||||
//查询订单中是否存在房源
|
|
||||||
for (Long aLong : idList) {
|
|
||||||
LambdaQueryWrapper<OrderEntity> wrapper = new LambdaQueryWrapper<>();
|
|
||||||
wrapper.eq(OrderEntity::getItemId,aLong);
|
|
||||||
List<OrderEntity> orderEntityList = orderDao.selectList(wrapper);
|
|
||||||
orderEntities.addAll(orderEntityList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (orderEntities.isEmpty()){
|
|
||||||
return new Result<List<OrderDTO>>().ok(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ArrayList<OrderDTO> list = new ArrayList<>();
|
|
||||||
for (OrderEntity orderEntity : orderEntities) {
|
|
||||||
|
|
||||||
OrderDTO orderDTO = new OrderDTO();
|
|
||||||
BeanUtils.copyProperties(orderEntity,orderDTO);
|
|
||||||
//申请人用户信息
|
|
||||||
Long itemUserId = orderEntity.getItemUserId();
|
|
||||||
UserDTO userDTO = userService.get(itemUserId);
|
|
||||||
orderDTO.setUser(userDTO);
|
|
||||||
//申请人房源信息
|
|
||||||
Long userHouseId = orderEntity.getUserHouseId();
|
|
||||||
HouseDTO houseDTO = itemService.get(userHouseId);
|
|
||||||
orderDTO.setItem(houseDTO);
|
|
||||||
list.add(orderDTO);
|
|
||||||
}
|
|
||||||
return new Result<List<OrderDTO>>().ok(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("hex")
|
|
||||||
@Operation(summary = "信息")
|
|
||||||
public Result<HexDto> get(@RequestParam("hex") String hex){
|
|
||||||
HexDto hexDto = new HexDto();
|
|
||||||
//通过hex查询订单
|
|
||||||
LambdaQueryWrapper<OrderEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.eq(OrderEntity::getHex,hex);
|
|
||||||
OrderEntity orderEntity = orderDao.selectOne(lwq);
|
|
||||||
if (orderEntity ==null){
|
|
||||||
return new Result<HexDto>().error("查询不到相关信息");
|
|
||||||
}
|
|
||||||
//可以查到
|
|
||||||
//1.A用户信息和房源编号 甲
|
|
||||||
Long itemIdA = orderEntity.getItemId();
|
|
||||||
hexDto.setHouseA(itemService.get(itemIdA));
|
|
||||||
Long itemUserIdA = orderEntity.getItemUserId();
|
|
||||||
hexDto.setUserA(userService.get(itemUserIdA));
|
|
||||||
//2.B用户信息和房源编号 乙
|
|
||||||
Long userIdB = orderEntity.getUserId();
|
|
||||||
hexDto.setUserB(userService.get(userIdB));
|
|
||||||
Long userHouseIdB = orderEntity.getUserHouseId();
|
|
||||||
hexDto.setHouseB(itemService.get(userHouseIdB));
|
|
||||||
hexDto.setDto(orderEntity);
|
|
||||||
return new Result<HexDto>().ok(hexDto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
|
||||||
@Operation(summary = "信息")
|
|
||||||
public Result<OrderDTO> get(@PathVariable("id") Long id){
|
|
||||||
OrderDTO data = orderService.get(id);
|
|
||||||
return new Result<OrderDTO>().ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
|
||||||
@Operation(summary = "保存")
|
|
||||||
@Login
|
|
||||||
public Result save(@RequestBody OrderDTO dto,@Parameter(hidden = true) @RequestAttribute("userId") Long userId){
|
|
||||||
dto.setUserId(userId);
|
|
||||||
//判断是否已经申请
|
|
||||||
LambdaQueryWrapper<OrderEntity> lwq = new LambdaQueryWrapper<>();
|
|
||||||
lwq.eq(OrderEntity::getUserId,userId);
|
|
||||||
lwq.eq(OrderEntity::getItemId,dto.getItemId());
|
|
||||||
if (orderDao.exists(lwq)){
|
|
||||||
return new Result().error("不能重复申请");
|
|
||||||
}
|
|
||||||
//房源用户编号
|
|
||||||
Long itemId = dto.getItemId();
|
|
||||||
HouseDTO houseDTO = itemService.get(itemId);
|
|
||||||
dto.setItemUserId(houseDTO.getUserId());
|
|
||||||
orderService.save(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
@PutMapping
|
|
||||||
@Operation(summary = "修改")
|
|
||||||
public Result update(@RequestBody OrderDTO dto){
|
|
||||||
orderService.update(dto);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
@DeleteMapping("{id}")
|
|
||||||
@Operation(summary = "删除")
|
|
||||||
public Result delete(@PathVariable Long id) {
|
|
||||||
Long[] ids = new Long[]{id};
|
|
||||||
//效验数据
|
|
||||||
AssertUtils.isArrayEmpty(ids, "id");
|
|
||||||
orderService.delete(ids);
|
|
||||||
return new Result();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user