Commit 91bb0c07f2f9d46ce12f9e2183a2c97035f46498
1 parent
08918cf7
404报错修改
Showing
2 changed files
with
121 additions
and
119 deletions
.gitignore
src/main/java/com/huaheng/pc/config/locationType/controller/LocationTypeController.java
1 | 1 | package com.huaheng.pc.config.locationType.controller; |
2 | 2 | |
3 | - | |
4 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
5 | 4 | import com.baomidou.mybatisplus.core.metadata.IPage; |
6 | 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
... | ... | @@ -17,133 +16,134 @@ import com.huaheng.framework.web.page.TableDataInfo; |
17 | 16 | import com.huaheng.framework.web.page.TableSupport; |
18 | 17 | import com.huaheng.pc.config.locationType.domain.LocationType; |
19 | 18 | import com.huaheng.pc.config.locationType.service.LocationTypeService; |
20 | -import com.huaheng.pc.general.location.domain.Location; | |
21 | -import com.huaheng.pc.general.location.service.LocationService; | |
22 | 19 | import org.apache.shiro.authz.annotation.RequiresPermissions; |
23 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
24 | 21 | import org.springframework.stereotype.Controller; |
25 | 22 | import org.springframework.ui.ModelMap; |
26 | 23 | import org.springframework.web.bind.annotation.*; |
27 | 24 | |
28 | -import java.util.Arrays; | |
29 | 25 | import java.util.List; |
30 | 26 | |
27 | +/** | |
28 | + * 库位类型 信息操作处理 | |
29 | + * | |
30 | + * @author huaheng | |
31 | + * @date 2018-08-19 | |
32 | + */ | |
31 | 33 | @Controller |
32 | 34 | @RequestMapping("/config/locationType") |
33 | -public class LocationTypeController extends BaseController { | |
34 | - | |
35 | +public class LocationTypeController extends BaseController | |
36 | +{ | |
35 | 37 | private String prefix = "config/locationType"; |
36 | - | |
37 | - @Autowired | |
38 | - private LocationTypeService locationTypeService; | |
39 | - @Autowired | |
40 | - private LocationService locationService; | |
41 | - | |
42 | - @RequestMapping("config:locationType:view") | |
43 | - @GetMapping() | |
44 | - public String locationType() | |
45 | - { | |
46 | - return prefix + "/locationType"; | |
47 | - } | |
48 | - | |
49 | - /** | |
50 | - * 查询库位类型列表 | |
51 | - */ | |
52 | - @RequiresPermissions("config:locationType:list") | |
53 | - @Log(title = "通用-库位类型管理", operating = "查看库位类型列表", action = BusinessType.GRANT) | |
54 | - @PostMapping("/list") | |
55 | - @ResponseBody | |
56 | - public TableDataInfo list(LocationType locationType,String createdBegin, String createdEnd) { | |
57 | - LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
58 | - PageDomain pageDomain = TableSupport.buildPageRequest(); | |
59 | - Integer pageNum = pageDomain.getPageNum(); | |
60 | - Integer pageSize = pageDomain.getPageSize(); | |
61 | - | |
62 | - lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin),LocationType::getCreated, createdBegin) | |
63 | - .le(StringUtils.isNotEmpty(createdEnd), LocationType::getCreated, createdEnd) | |
64 | - .eq(LocationType::getWarehouseCode, ShiroUtils.getWarehouseCode()) | |
65 | - .eq(StringUtils.isNotEmpty(locationType.getCode()),LocationType::getCode,locationType.getCode()) | |
66 | - .like(StringUtils.isNotEmpty(locationType.getName()),LocationType::getName,locationType.getName()); | |
67 | - | |
68 | - if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ | |
69 | - /** | |
70 | - * 使用分页查询 | |
71 | - */ | |
72 | - Page<LocationType> page = new Page<>(pageNum, pageSize); | |
73 | - IPage<LocationType> iPage = locationTypeService.page(page, lambdaQueryWrapper); | |
74 | - return getDataTable(iPage.getRecords()); | |
75 | - } else { | |
76 | - List<LocationType> list = locationTypeService.list(lambdaQueryWrapper); | |
77 | - return getDataTable(list); | |
78 | - } | |
79 | - } | |
80 | - | |
81 | - /** | |
82 | - * 新增库位类型 | |
83 | - */ | |
84 | - @GetMapping("/add") | |
85 | - public String add() { | |
86 | - return prefix + "/add"; | |
87 | - } | |
88 | - | |
89 | - /** | |
90 | - * 新增保存库位类型 | |
91 | - */ | |
92 | - @RequiresPermissions("config:locationType:add") | |
93 | - @Log(title = "通用-库位类型管理", operating = "新增库位类型", action = BusinessType.INSERT) | |
94 | - @PostMapping("/add") | |
95 | - @ResponseBody | |
96 | - public AjaxResult addSave(LocationType locationType) { | |
97 | - Boolean result = locationTypeService.save(locationType); | |
98 | - return toAjax(result); | |
99 | - } | |
100 | - | |
101 | - /** | |
102 | - * 修改库位类型 | |
103 | - */ | |
104 | - @GetMapping("/edit/{id}") | |
105 | - public String edit(@PathVariable("id") Integer id, ModelMap mmap) { | |
106 | - LocationType locationType = locationTypeService.getById(id); | |
107 | - mmap.put("locationType", locationType); | |
108 | - return prefix + "/edit"; | |
109 | - } | |
110 | - | |
111 | - /** | |
112 | - * 修改保存库位类型 | |
113 | - */ | |
114 | - @RequiresPermissions("config:locationType:edit") | |
115 | - @Log(title = "通用-库位类型管理", operating = "修改库位类型", action = BusinessType.UPDATE) | |
116 | - @PostMapping("/edit") | |
117 | - @ResponseBody | |
118 | - public AjaxResult editSave(LocationType locationType) { | |
119 | - locationType.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
120 | - Boolean result = locationTypeService.updateById(locationType); | |
121 | - return toAjax(result); | |
122 | - } | |
123 | - | |
124 | - /** | |
125 | - * 删除库位 | |
126 | - */ | |
127 | - @RequiresPermissions("config:locationType:remove") | |
128 | - @Log(title = "通用-库位类型管理", operating = "删除库位类型", action = BusinessType.DELETE) | |
129 | - @PostMapping( "/remove") | |
130 | - @ResponseBody | |
131 | - public AjaxResult remove(String ids) { | |
132 | - if (StringUtils.isEmpty(ids)){ | |
133 | - return AjaxResult.error("id不能为空"); | |
134 | - } | |
135 | - | |
136 | - for (Integer id : Convert.toIntArray(ids)) { | |
137 | - LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
138 | - lambdaQueryWrapper.eq(Location::getLocationType,id); | |
139 | - | |
140 | - int count = locationService.count(lambdaQueryWrapper); | |
141 | - if (count != 0){ | |
142 | - return AjaxResult.error("库位类型id="+id+",存在库位,不能删除。"); | |
143 | - } | |
144 | - } | |
145 | - List<Integer> list = Arrays.asList(Convert.toIntArray(ids)); | |
146 | - locationTypeService.removeByIds(list); | |
147 | - return AjaxResult.success("删除成功!"); | |
148 | - } | |
38 | + | |
39 | + @Autowired | |
40 | + private LocationTypeService locationTypeService; | |
41 | + | |
42 | + @RequiresPermissions("config:locationType:view") | |
43 | + @GetMapping() | |
44 | + public String locationType() | |
45 | + { | |
46 | + return prefix + "/locationType"; | |
47 | + } | |
48 | + | |
49 | + /** | |
50 | + * 查询库位类型列表 | |
51 | + */ | |
52 | + @RequiresPermissions("config:locationType:list") | |
53 | + @Log(title = "配置-库位类型设置", operating = "查看库位类型", action = BusinessType.GRANT) | |
54 | + @PostMapping("/list") | |
55 | + @ResponseBody | |
56 | + public TableDataInfo list(LocationType locationType,String createdBegin, String createdEnd) | |
57 | + { | |
58 | + LambdaQueryWrapper<LocationType> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
59 | + PageDomain pageDomain = TableSupport.buildPageRequest(); | |
60 | + Integer pageNum = pageDomain.getPageNum(); | |
61 | + Integer pageSize = pageDomain.getPageSize(); | |
62 | + | |
63 | + lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin),LocationType::getCreated, createdBegin) | |
64 | + .le(StringUtils.isNotEmpty(createdEnd), LocationType::getCreated, createdEnd) | |
65 | + .eq(LocationType::getWarehouseCode,ShiroUtils.getWarehouseCode()) | |
66 | + .eq(StringUtils.isNotEmpty(locationType.getCode()), LocationType::getCode, locationType.getCode()) | |
67 | + .like(StringUtils.isNotEmpty(locationType.getName()), LocationType::getName, locationType.getName()) | |
68 | + .orderByAsc(LocationType::getId); | |
69 | + | |
70 | + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ | |
71 | + /** | |
72 | + * 使用分页查询 | |
73 | + */ | |
74 | + Page<LocationType> page = new Page<>(pageNum, pageSize); | |
75 | + IPage<LocationType> iPage = locationTypeService.page(page, lambdaQueryWrapper); | |
76 | + return getMpDataTable(iPage.getRecords(),iPage.getTotal()); | |
77 | + } else { | |
78 | + List<LocationType> list = locationTypeService.list(lambdaQueryWrapper); | |
79 | + return getDataTable(list); | |
80 | + } | |
81 | + } | |
82 | + | |
83 | + /** | |
84 | + * 新增库位类型 | |
85 | + */ | |
86 | + @GetMapping("/add") | |
87 | + public String add() | |
88 | + { | |
89 | + return prefix + "/add"; | |
90 | + } | |
91 | + | |
92 | + /** | |
93 | + * 新增保存库位类型 | |
94 | + */ | |
95 | + @RequiresPermissions("config:locationType:add") | |
96 | + @Log(title = "配置-库位类型设置", operating = "新增库位类型", action = BusinessType.INSERT) | |
97 | + @PostMapping("/add") | |
98 | + @ResponseBody | |
99 | + public AjaxResult addSave(LocationType locationType) | |
100 | + { | |
101 | + locationType.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
102 | + locationType.setCreatedBy(ShiroUtils.getLoginName()); | |
103 | + locationType.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
104 | + return toAjax(locationTypeService.save(locationType)); | |
105 | + } | |
106 | + | |
107 | + /** | |
108 | + * 修改库位类型 | |
109 | + */ | |
110 | + @GetMapping("/edit/{id}") | |
111 | + public String edit(@PathVariable("id") Integer id, ModelMap mmap) | |
112 | + { | |
113 | + LocationType locationType = locationTypeService.getById(id); | |
114 | + mmap.put("locationType", locationType); | |
115 | + return prefix + "/edit"; | |
116 | + } | |
117 | + | |
118 | + /** | |
119 | + * 修改保存库位类型 | |
120 | + */ | |
121 | + @RequiresPermissions("config:locationType:edit") | |
122 | + @Log(title = "配置-库位类型设置", operating = "修改库位类型", action = BusinessType.UPDATE) | |
123 | + @PostMapping("/edit") | |
124 | + @ResponseBody | |
125 | + public AjaxResult editSave(LocationType locationType) | |
126 | + { | |
127 | + locationType.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
128 | + return toAjax(locationTypeService.saveOrUpdate(locationType)); | |
129 | + } | |
130 | + | |
131 | + /** | |
132 | + * 删除库位类型 | |
133 | + */ | |
134 | + @RequiresPermissions("config:locationType:remove") | |
135 | + @Log(title = "配置-库位类型设置", operating = "删除库位类型", action = BusinessType.DELETE) | |
136 | + @PostMapping( "/remove") | |
137 | + @ResponseBody | |
138 | + public AjaxResult remove(String ids) | |
139 | + { | |
140 | + if (StringUtils.isEmpty(ids)) | |
141 | + return AjaxResult.error("id不能为空"); | |
142 | + for (Integer id : Convert.toIntArray(ids)) | |
143 | + { | |
144 | + locationTypeService.removeById(id); | |
145 | + } | |
146 | + return AjaxResult.success("删除成功!"); | |
147 | + } | |
148 | + | |
149 | 149 | } |
... | ... |