WareHouseController.java
3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.huaheng.system.controller;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.core.web.controller.BaseController;
import com.huaheng.common.core.web.domain.AjaxResult;
import com.huaheng.common.core.web.page.PageDomain;
import com.huaheng.common.core.web.page.TableDataInfo;
import com.huaheng.common.core.web.page.TableSupport;
import com.huaheng.system.api.domain.Warehouse;
import com.huaheng.system.service.ISysUserService;
import com.huaheng.system.service.WarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/warehouse")
@Api(value = "仓库", tags = "仓库")
public class WareHouseController extends BaseController {
@Resource
private WarehouseService warehouseService;
@Resource
private ISysUserService userService;
/**
* 查询仓库列表
*/
@GetMapping("/list")
@ResponseBody
@ApiOperation(value = "查询仓库", notes = "查询仓库")
public TableDataInfo list(Warehouse warehouse,
String createdBegin,
String createdEnd) {
LambdaQueryWrapper<Warehouse> lambdaQueryWrapper = Wrappers.lambdaQuery();
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
lambdaQueryWrapper.gt(StrUtil.isNotEmpty(createdBegin), Warehouse::getCreated, createdBegin)
.lt(StrUtil.isNotEmpty(createdEnd), Warehouse::getCreated, createdEnd)
.eq(StrUtil.isNotEmpty(warehouse.getCode()), Warehouse::getCode, warehouse.getCode())
.like(StrUtil.isNotEmpty(warehouse.getName()), Warehouse::getName, warehouse.getName())
.eq(Warehouse::getDeleted, false)
.orderByDesc(Warehouse::getCreated);
/**
* 使用分页查询
*/
if (ObjectUtil.isNotNull(pageNum) && ObjectUtil.isNotNull(pageSize)) {
Page<Warehouse> page = new Page<>(pageNum, pageSize);
IPage<Warehouse> iPage = warehouseService.page(page, lambdaQueryWrapper);
return getMpDataTable(iPage.getRecords(), iPage.getTotal());
} else {
List<Warehouse> list = warehouseService.list(lambdaQueryWrapper);
return getDataTable(list);
}
}
/**
* 通过用户名获取可以登陆的仓库列表
*/
@GetMapping("/getWarehouseByUserCode")
@ResponseBody
@ApiOperation(value = "通过用户名获取可以用的仓库列表 ", notes = "通过用户名获取可以用的仓库列表")
public AjaxResult getWarehouseByUserCode(String username) {
if (StrUtil.isNotEmpty(username)) {
List<Map<String, Object>> list = userService.getWarehouseByUserCode(username);
return AjaxResult.success(list);
} else {
return AjaxResult.error("用户名不能为空");
}
}
}