package com.zy.asrs.controller; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.core.annotations.ManagerAuth; import com.core.common.Cools; import com.core.common.DateUtils; import com.core.common.R; import com.zy.asrs.entity.OrderDetlPakinLog; import com.zy.asrs.service.OrderDetlPakinLogService; import com.zy.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.Map; @RestController @RequestMapping("order/pakinLog") public class OrderDetlPakinLogController extends BaseController { @Autowired private OrderDetlPakinLogService orderDetlService; @RequestMapping(value = "/orderDetl/list/auth") @ManagerAuth public R list(@RequestParam(defaultValue = "1") Integer curr, @RequestParam(defaultValue = "10") Integer limit, @RequestParam(required = false) String orderByField, @RequestParam(required = false) String orderByType, @RequestParam Map param) { EntityWrapper wrapper = new EntityWrapper<>(); excludeTrash(param); convert(param, wrapper); if (!Cools.isEmpty(orderByField)) { wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); } else { wrapper.orderBy("create_time", false); } Page orderDetlPage = orderDetlService.selectPage(new Page<>(curr, limit), wrapper); return R.ok(orderDetlPage); } private void convert(Map map, EntityWrapper wrapper) { for (Map.Entry entry : map.entrySet()) { String key = entry.getKey(); String val = String.valueOf(entry.getValue()); if (Cools.isEmpty(val) || "null".equals(val)) { continue; } if (val.contains(RANGE_TIME_LINK)) { String[] dates = val.split(RANGE_TIME_LINK); wrapper.ge(key, DateUtils.convert(dates[0])); wrapper.le(key, DateUtils.convert(dates[1])); } else if ("order_id".equals(key) || "orderId".equals(key)) { // order_id使用精确匹配 wrapper.eq(key, val); } else { wrapper.like(key, val); } } } }