Commit 2bb6895333eaba64d557feb277e217def7bb5649
Merge remote-tracking branch 'origin/develop' into develop
Showing
8 changed files
with
165 additions
and
36 deletions
src/main/java/com/huaheng/pc/config/zone/controller/ZoneController.java
0 → 100644
1 | +package com.huaheng.pc.config.zone.controller; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
4 | +import com.baomidou.mybatisplus.core.metadata.IPage; | |
5 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
6 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |
7 | +import com.huaheng.common.support.Convert; | |
8 | +import com.huaheng.common.utils.StringUtils; | |
9 | +import com.huaheng.common.utils.security.ShiroUtils; | |
10 | +import com.huaheng.framework.aspectj.lang.annotation.Log; | |
11 | +import com.huaheng.framework.aspectj.lang.constant.BusinessType; | |
12 | +import com.huaheng.framework.web.controller.BaseController; | |
13 | +import com.huaheng.framework.web.domain.AjaxResult; | |
14 | +import com.huaheng.framework.web.page.PageDomain; | |
15 | +import com.huaheng.framework.web.page.TableDataInfo; | |
16 | +import com.huaheng.framework.web.page.TableSupport; | |
17 | +import com.huaheng.pc.config.zone.domain.Zone; | |
18 | +import com.huaheng.pc.config.zone.service.ZoneService; | |
19 | +import org.apache.shiro.authz.annotation.RequiresPermissions; | |
20 | +import org.springframework.beans.factory.annotation.Autowired; | |
21 | +import org.springframework.stereotype.Controller; | |
22 | +import org.springframework.ui.ModelMap; | |
23 | +import org.springframework.web.bind.annotation.*; | |
24 | + | |
25 | +import java.util.List; | |
26 | + | |
27 | +@Controller | |
28 | +@RequestMapping("/config/zone") | |
29 | +public class ZoneController extends BaseController { | |
30 | + | |
31 | + private String prefix = "config/zone"; | |
32 | + | |
33 | + @Autowired | |
34 | + private ZoneService zoneService; | |
35 | + | |
36 | + @RequiresPermissions("config:zone:view") | |
37 | + @GetMapping() | |
38 | + public String zone() | |
39 | + { | |
40 | + return prefix + "/zone"; | |
41 | + } | |
42 | + | |
43 | + /** | |
44 | + * 查询库区列表 | |
45 | + */ | |
46 | + @RequiresPermissions("config:zone:list") | |
47 | + @Log(title = "配置-库区设置", operating = "查看库区列表", action = BusinessType.GRANT) | |
48 | + @PostMapping("/list") | |
49 | + @ResponseBody | |
50 | + public TableDataInfo list(Zone zone,String createdBegin, String createdEnd) | |
51 | + { | |
52 | + LambdaQueryWrapper<Zone> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
53 | + PageDomain pageDomain = TableSupport.buildPageRequest(); | |
54 | + Integer pageNum = pageDomain.getPageNum(); | |
55 | + Integer pageSize = pageDomain.getPageSize() >> 1; //除2 | |
56 | + | |
57 | + lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin),Zone::getCreated, createdBegin) | |
58 | + .le(StringUtils.isNotEmpty(createdEnd), Zone::getCreated, createdEnd) | |
59 | + .eq(StringUtils.isNotEmpty(zone.getCode()), Zone::getCode, zone.getCode()) | |
60 | + .like(StringUtils.isNotEmpty(zone.getName()), Zone::getName, zone.getName()) | |
61 | + .orderByAsc(Zone::getId); | |
62 | + | |
63 | + if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){ | |
64 | + /** | |
65 | + * 使用分页查询 | |
66 | + */ | |
67 | + Page<Zone> page = new Page<>(pageNum, pageSize); | |
68 | + IPage<Zone> iPage = zoneService.page(page, lambdaQueryWrapper); | |
69 | + return getDataTable(iPage.getRecords()); | |
70 | + } else { | |
71 | + List<Zone> list = zoneService.list(lambdaQueryWrapper); | |
72 | + return getDataTable(list); | |
73 | + } | |
74 | + } | |
75 | + | |
76 | + /** | |
77 | + * 新增库区 | |
78 | + */ | |
79 | + @GetMapping("/add") | |
80 | + public String add() | |
81 | + { | |
82 | + return prefix + "/add"; | |
83 | + } | |
84 | + | |
85 | + /** | |
86 | + * 新增保存库区 | |
87 | + */ | |
88 | + @RequiresPermissions("config:zone:add") | |
89 | + @Log(title = "配置-库区设置", operating = "新增库区", action = BusinessType.INSERT) | |
90 | + @PostMapping("/add") | |
91 | + @ResponseBody | |
92 | + public AjaxResult addSave(Zone zone) | |
93 | + { | |
94 | + zone.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
95 | + zone.setCreatedBy(ShiroUtils.getLoginName()); | |
96 | + zone.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
97 | + return toAjax(zoneService.save(zone)); | |
98 | + } | |
99 | + | |
100 | + /** | |
101 | + * 修改库区 | |
102 | + */ | |
103 | + @GetMapping("/edit/{id}") | |
104 | + public String edit(@PathVariable("id") Integer id, ModelMap mmap) | |
105 | + { | |
106 | + Zone zone = zoneService.getById(id); | |
107 | + mmap.put("zone", zone); | |
108 | + return prefix + "/edit"; | |
109 | + } | |
110 | + | |
111 | + /** | |
112 | + * 修改保存库区 | |
113 | + */ | |
114 | + @RequiresPermissions("config:zone:edit") | |
115 | + @Log(title = "配置-库区设置", operating = "修改库区", action = BusinessType.UPDATE) | |
116 | + @PostMapping("/edit") | |
117 | + @ResponseBody | |
118 | + public AjaxResult editSave(Zone zone) | |
119 | + { | |
120 | + zone.setLastUpdatedBy(ShiroUtils.getLoginName()); | |
121 | + return toAjax(zoneService.saveOrUpdate(zone)); | |
122 | + } | |
123 | + | |
124 | + /** | |
125 | + * 删除库区 | |
126 | + */ | |
127 | + @RequiresPermissions("config:zone:remove") | |
128 | + @Log(title = "配置-库区设置", operating = "删除库区", action = BusinessType.DELETE) | |
129 | + @PostMapping( "/remove") | |
130 | + @ResponseBody | |
131 | + public AjaxResult remove(String ids) | |
132 | + { | |
133 | + if (StringUtils.isEmpty(ids)) | |
134 | + return AjaxResult.error("id不能为空"); | |
135 | + for (Integer id : Convert.toIntArray(ids)) | |
136 | + { | |
137 | + Zone record = new Zone(); | |
138 | + zoneService.removeById(id); | |
139 | + } | |
140 | + return AjaxResult.success("删除成功!"); | |
141 | + } | |
142 | + | |
143 | + | |
144 | +} | |
... | ... |
src/main/java/com/huaheng/pc/general/zone/domain/Zone.java renamed to src/main/java/com/huaheng/pc/config/zone/domain/Zone.java
1 | -package com.huaheng.pc.general.zone.domain; | |
1 | +package com.huaheng.pc.config.zone.domain; | |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.annotation.IdType; |
4 | 4 | import com.baomidou.mybatisplus.annotation.TableField; |
5 | 5 | import com.baomidou.mybatisplus.annotation.TableId; |
6 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
7 | +import lombok.Data; | |
8 | + | |
7 | 9 | import java.io.Serializable; |
8 | 10 | import java.util.Date; |
9 | -import lombok.Data; | |
10 | 11 | |
11 | 12 | @Data |
12 | 13 | @TableName(value = "zone") |
... | ... |
src/main/java/com/huaheng/pc/general/zone/mapper/ZoneMapper.java renamed to src/main/java/com/huaheng/pc/config/zone/mapper/ZoneMapper.java
1 | -package com.huaheng.pc.general.zone.mapper; | |
1 | +package com.huaheng.pc.config.zone.mapper; | |
2 | 2 | |
3 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
4 | -import com.huaheng.pc.general.zone.domain.Zone; | |
4 | +import com.huaheng.pc.config.zone.domain.Zone; | |
5 | 5 | |
6 | 6 | public interface ZoneMapper extends BaseMapper<Zone> { |
7 | 7 | } |
8 | 8 | \ No newline at end of file |
... | ... |
src/main/java/com/huaheng/pc/general/zone/service/ZoneService.java renamed to src/main/java/com/huaheng/pc/config/zone/service/ZoneService.java
1 | -package com.huaheng.pc.general.zone.service; | |
1 | +package com.huaheng.pc.config.zone.service; | |
2 | 2 | |
3 | -import com.huaheng.pc.general.zone.domain.Zone; | |
4 | 3 | import com.baomidou.mybatisplus.extension.service.IService; |
4 | +import com.huaheng.pc.config.zone.domain.Zone; | |
5 | + | |
5 | 6 | public interface ZoneService extends IService<Zone>{ |
6 | 7 | |
7 | 8 | |
... | ... |
src/main/java/com/huaheng/pc/config/zone/service/ZoneServiceImpl.java
0 → 100644
1 | +package com.huaheng.pc.config.zone.service; | |
2 | + | |
3 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
4 | +import com.huaheng.pc.config.zone.domain.Zone; | |
5 | +import com.huaheng.pc.config.zone.mapper.ZoneMapper; | |
6 | +import org.springframework.stereotype.Service; | |
7 | + | |
8 | +@Service | |
9 | +public class ZoneServiceImpl extends ServiceImpl<ZoneMapper, Zone> implements ZoneService { | |
10 | + | |
11 | +} | |
... | ... |
src/main/java/com/huaheng/pc/general/zone/controller/ZoneController.java deleted
1 | -package com.huaheng.pc.general.zone.controller; | |
2 | - | |
3 | -import org.springframework.stereotype.Component; | |
4 | -import org.springframework.web.bind.annotation.RequestMapping; | |
5 | - | |
6 | -import javax.annotation.Resource; | |
7 | - | |
8 | -@Component | |
9 | -@RequestMapping | |
10 | -public class ZoneController { | |
11 | - | |
12 | - | |
13 | - | |
14 | - | |
15 | -} |
src/main/java/com/huaheng/pc/general/zone/service/ZoneServiceImpl.java deleted
1 | -package com.huaheng.pc.general.zone.service; | |
2 | - | |
3 | -import org.springframework.stereotype.Service; | |
4 | -import javax.annotation.Resource; | |
5 | -import java.util.List; | |
6 | -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |
7 | -import com.huaheng.pc.general.zone.domain.Zone; | |
8 | -import com.huaheng.pc.general.zone.mapper.ZoneMapper; | |
9 | -import com.huaheng.pc.general.zone.service.ZoneService; | |
10 | -@Service | |
11 | -public class ZoneServiceImpl extends ServiceImpl<ZoneMapper, Zone> implements ZoneService{ | |
12 | - | |
13 | -} |
src/main/resources/mybatis/general/ZoneMapper.xml renamed to src/main/resources/mybatis/config/ZoneMapper.xml
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | -<mapper namespace="com.huaheng.pc.general.zone.mapper.ZoneMapper"> | |
4 | - <resultMap id="BaseResultMap" type="com.huaheng.pc.general.zone.domain.Zone"> | |
3 | +<mapper namespace="com.huaheng.pc.config.zone.mapper.ZoneMapper"> | |
4 | + <resultMap id="BaseResultMap" type="com.huaheng.pc.config.zone.domain.Zone"> | |
5 | 5 | <!--@mbg.generated--> |
6 | 6 | <id column="id" jdbcType="INTEGER" property="id" /> |
7 | 7 | <result column="code" jdbcType="VARCHAR" property="code" /> |
... | ... |