瀏覽代碼

分批次提交

傅行帆 4 年之前
父節點
當前提交
9dde5b1c07

+ 109
- 0
example/src/main/java/com/example/foobar/controller/FooBarController.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.controller;
18
+
19
+import com.example.foobar.entity.FooBar;
20
+import com.example.foobar.param.FooBarPageParam;
21
+import com.example.foobar.service.FooBarService;
22
+import io.geekidea.springbootplus.framework.common.api.ApiResult;
23
+import io.geekidea.springbootplus.framework.common.controller.BaseController;
24
+import io.geekidea.springbootplus.framework.core.pagination.Paging;
25
+import io.geekidea.springbootplus.framework.core.validator.groups.Add;
26
+import io.geekidea.springbootplus.framework.core.validator.groups.Update;
27
+import io.geekidea.springbootplus.framework.log.annotation.Module;
28
+import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
29
+import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
30
+import io.swagger.annotations.Api;
31
+import io.swagger.annotations.ApiOperation;
32
+import lombok.extern.slf4j.Slf4j;
33
+import org.springframework.beans.factory.annotation.Autowired;
34
+import org.springframework.validation.annotation.Validated;
35
+import org.springframework.web.bind.annotation.*;
36
+
37
+/**
38
+ * FooBar 控制器
39
+ *
40
+ * @author geekidea
41
+ * @since 2020-03-24
42
+ */
43
+@Slf4j
44
+@RestController
45
+@RequestMapping("/fooBar")
46
+@Module("foobar")
47
+@Api(value = "FooBarAPI", tags = {"FooBar"})
48
+public class FooBarController extends BaseController {
49
+
50
+    @Autowired
51
+    private FooBarService fooBarService;
52
+
53
+    /**
54
+     * 添加FooBar
55
+     */
56
+    @PostMapping("/add")
57
+    @OperationLog(name = "添加FooBar", type = OperationLogType.ADD)
58
+    @ApiOperation(value = "添加FooBar", response = ApiResult.class)
59
+    public ApiResult<Boolean> addFooBar(@Validated(Add.class) @RequestBody FooBar fooBar) throws Exception {
60
+        boolean flag = fooBarService.saveFooBar(fooBar);
61
+        return ApiResult.result(flag);
62
+    }
63
+
64
+    /**
65
+     * 修改FooBar
66
+     */
67
+    @PostMapping("/update")
68
+    @OperationLog(name = "修改FooBar", type = OperationLogType.UPDATE)
69
+    @ApiOperation(value = "修改FooBar", response = ApiResult.class)
70
+    public ApiResult<Boolean> updateFooBar(@Validated(Update.class) @RequestBody FooBar fooBar) throws Exception {
71
+        boolean flag = fooBarService.updateFooBar(fooBar);
72
+        return ApiResult.result(flag);
73
+    }
74
+
75
+    /**
76
+     * 删除FooBar
77
+     */
78
+    @PostMapping("/delete/{id}")
79
+    @OperationLog(name = "删除FooBar", type = OperationLogType.DELETE)
80
+    @ApiOperation(value = "删除FooBar", response = ApiResult.class)
81
+    public ApiResult<Boolean> deleteFooBar(@PathVariable("id") Long id) throws Exception {
82
+        boolean flag = fooBarService.deleteFooBar(id);
83
+        return ApiResult.result(flag);
84
+    }
85
+
86
+    /**
87
+     * 获取FooBar详情
88
+     */
89
+    @GetMapping("/info/{id}")
90
+    @OperationLog(name = "FooBar详情", type = OperationLogType.INFO)
91
+    @ApiOperation(value = "FooBar详情", response = FooBar.class)
92
+    public ApiResult<FooBar> getFooBar(@PathVariable("id") Long id) throws Exception {
93
+        FooBar fooBar = fooBarService.getById(id);
94
+        return ApiResult.ok(fooBar);
95
+    }
96
+
97
+    /**
98
+     * FooBar分页列表
99
+     */
100
+    @PostMapping("/getPageList")
101
+    @OperationLog(name = "FooBar分页列表", type = OperationLogType.PAGE)
102
+    @ApiOperation(value = "FooBar分页列表", response = FooBar.class)
103
+    public ApiResult<Paging<FooBar>> getFooBarPageList(@Validated @RequestBody FooBarPageParam fooBarPageParam) throws Exception {
104
+        Paging<FooBar> paging = fooBarService.getFooBarPageList(fooBarPageParam);
105
+        return ApiResult.ok(paging);
106
+    }
107
+
108
+}
109
+

+ 79
- 0
example/src/main/java/com/example/foobar/entity/FooBar.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.entity;
18
+
19
+import com.baomidou.mybatisplus.annotation.IdType;
20
+import com.baomidou.mybatisplus.annotation.TableId;
21
+import com.baomidou.mybatisplus.annotation.Version;
22
+import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
23
+import io.geekidea.springbootplus.framework.core.validator.groups.Update;
24
+import io.swagger.annotations.ApiModel;
25
+import io.swagger.annotations.ApiModelProperty;
26
+import lombok.Data;
27
+import lombok.EqualsAndHashCode;
28
+import lombok.experimental.Accessors;
29
+
30
+import javax.validation.constraints.NotBlank;
31
+import javax.validation.constraints.NotNull;
32
+import java.util.Date;
33
+
34
+/**
35
+ * FooBar
36
+ *
37
+ * @author geekidea
38
+ * @since 2020-03-24
39
+ */
40
+@Data
41
+@Accessors(chain = true)
42
+@EqualsAndHashCode(callSuper = true)
43
+@ApiModel(value = "FooBar对象")
44
+public class FooBar extends BaseEntity {
45
+    private static final long serialVersionUID = 1L;
46
+
47
+    @NotNull(message = "id不能为空", groups = {Update.class})
48
+    @ApiModelProperty("ID")
49
+    @TableId(value = "id", type = IdType.AUTO)
50
+    private Long id;
51
+
52
+    @NotBlank(message = "Name不能为空")
53
+    @ApiModelProperty("Name")
54
+    private String name;
55
+
56
+    @ApiModelProperty("Foo")
57
+    private String foo;
58
+
59
+    @NotBlank(message = "Bar不能为空")
60
+    @ApiModelProperty("Bar")
61
+    private String bar;
62
+
63
+    @ApiModelProperty("Remark")
64
+    private String remark;
65
+
66
+    @ApiModelProperty("State,0:Disable,1:Enable")
67
+    private Integer state;
68
+
69
+    @ApiModelProperty("Version")
70
+    @Version
71
+    private Integer version;
72
+
73
+    @ApiModelProperty("Create Time")
74
+    private Date createTime;
75
+
76
+    @ApiModelProperty("Update Time")
77
+    private Date updateTime;
78
+
79
+}

+ 33
- 0
example/src/main/java/com/example/foobar/mapper/FooBarMapper.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.mapper;
18
+
19
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20
+import com.example.foobar.entity.FooBar;
21
+import org.springframework.stereotype.Repository;
22
+
23
+/**
24
+ * FooBar Mapper 接口
25
+ *
26
+ * @author geekidea
27
+ * @since 2020-03-24
28
+ */
29
+@Repository
30
+public interface FooBarMapper extends BaseMapper<FooBar> {
31
+
32
+
33
+}

+ 39
- 0
example/src/main/java/com/example/foobar/param/FooBarPageParam.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.param;
18
+
19
+import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
20
+import io.swagger.annotations.ApiModel;
21
+import lombok.Data;
22
+import lombok.EqualsAndHashCode;
23
+import lombok.experimental.Accessors;
24
+
25
+/**
26
+ * <pre>
27
+ * FooBar 分页参数对象
28
+ * </pre>
29
+ *
30
+ * @author geekidea
31
+ * @date 2020-03-24
32
+ */
33
+@Data
34
+@Accessors(chain = true)
35
+@EqualsAndHashCode(callSuper = true)
36
+@ApiModel(value = "FooBar分页参数")
37
+public class FooBarPageParam extends BasePageOrderParam {
38
+    private static final long serialVersionUID = 1L;
39
+}

+ 69
- 0
example/src/main/java/com/example/foobar/service/FooBarService.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.service;
18
+
19
+import com.example.foobar.entity.FooBar;
20
+import com.example.foobar.param.FooBarPageParam;
21
+import io.geekidea.springbootplus.framework.common.service.BaseService;
22
+import io.geekidea.springbootplus.framework.core.pagination.Paging;
23
+
24
+/**
25
+ * FooBar 服务类
26
+ *
27
+ * @author geekidea
28
+ * @since 2020-03-24
29
+ */
30
+public interface FooBarService extends BaseService<FooBar> {
31
+
32
+    /**
33
+     * 保存
34
+     *
35
+     * @param fooBar
36
+     * @return
37
+     * @throws Exception
38
+     */
39
+    boolean saveFooBar(FooBar fooBar) throws Exception;
40
+
41
+    /**
42
+     * 修改
43
+     *
44
+     * @param fooBar
45
+     * @return
46
+     * @throws Exception
47
+     */
48
+    boolean updateFooBar(FooBar fooBar) throws Exception;
49
+
50
+    /**
51
+     * 删除
52
+     *
53
+     * @param id
54
+     * @return
55
+     * @throws Exception
56
+     */
57
+    boolean deleteFooBar(Long id) throws Exception;
58
+
59
+
60
+    /**
61
+     * 获取分页对象
62
+     *
63
+     * @param fooBarQueryParam
64
+     * @return
65
+     * @throws Exception
66
+     */
67
+    Paging<FooBar> getFooBarPageList(FooBarPageParam fooBarPageParam) throws Exception;
68
+
69
+}

+ 77
- 0
example/src/main/java/com/example/foobar/service/impl/FooBarServiceImpl.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.service.impl;
18
+
19
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
20
+import com.baomidou.mybatisplus.core.metadata.IPage;
21
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
22
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
23
+import com.example.foobar.entity.FooBar;
24
+import com.example.foobar.mapper.FooBarMapper;
25
+import com.example.foobar.param.FooBarPageParam;
26
+import com.example.foobar.service.FooBarService;
27
+import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
28
+import io.geekidea.springbootplus.framework.core.pagination.OrderMapping;
29
+import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
30
+import io.geekidea.springbootplus.framework.core.pagination.Paging;
31
+import lombok.extern.slf4j.Slf4j;
32
+import org.springframework.beans.factory.annotation.Autowired;
33
+import org.springframework.stereotype.Service;
34
+import org.springframework.transaction.annotation.Transactional;
35
+
36
+/**
37
+ * FooBar 服务实现类
38
+ *
39
+ * @author geekidea
40
+ * @since 2020-03-24
41
+ */
42
+@Slf4j
43
+@Service
44
+public class FooBarServiceImpl extends BaseServiceImpl<FooBarMapper, FooBar> implements FooBarService {
45
+
46
+    @Autowired
47
+    private FooBarMapper fooBarMapper;
48
+
49
+    @Transactional(rollbackFor = Exception.class)
50
+    @Override
51
+    public boolean saveFooBar(FooBar fooBar) throws Exception {
52
+        return super.save(fooBar);
53
+    }
54
+
55
+    @Transactional(rollbackFor = Exception.class)
56
+    @Override
57
+    public boolean updateFooBar(FooBar fooBar) throws Exception {
58
+        return super.updateById(fooBar);
59
+    }
60
+
61
+    @Transactional(rollbackFor = Exception.class)
62
+    @Override
63
+    public boolean deleteFooBar(Long id) throws Exception {
64
+        return super.removeById(id);
65
+    }
66
+
67
+    @Override
68
+    public Paging<FooBar> getFooBarPageList(FooBarPageParam fooBarPageParam) throws Exception {
69
+        OrderMapping orderMapping = new OrderMapping()
70
+                .mapping("updateTime", "update_time");
71
+        Page<FooBar> page = new PageInfo<>(fooBarPageParam, OrderItem.desc(getLambdaColumn(FooBar::getCreateTime)), orderMapping);
72
+        LambdaQueryWrapper<FooBar> wrapper = new LambdaQueryWrapper<>();
73
+        IPage<FooBar> iPage = fooBarMapper.selectPage(page, wrapper);
74
+        return new Paging<FooBar>(iPage);
75
+    }
76
+
77
+}

+ 68
- 0
example/src/main/java/com/example/foobar/vo/FooBarQueryVo.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.foobar.vo;
18
+
19
+import io.swagger.annotations.ApiModel;
20
+import io.swagger.annotations.ApiModelProperty;
21
+import lombok.Data;
22
+import lombok.experimental.Accessors;
23
+
24
+import java.io.Serializable;
25
+import java.util.Date;
26
+
27
+/**
28
+ * <pre>
29
+ * FooBar 查询结果对象
30
+ * </pre>
31
+ *
32
+ * @author geekidea
33
+ * @date 2020-03-23
34
+ */
35
+@Data
36
+@Accessors(chain = true)
37
+@ApiModel(value = "FooBarQueryVo对象")
38
+public class FooBarQueryVo implements Serializable {
39
+    private static final long serialVersionUID = 1L;
40
+
41
+    @ApiModelProperty("ID")
42
+    private Long id;
43
+
44
+    @ApiModelProperty("Name")
45
+    private String name;
46
+
47
+    @ApiModelProperty("Foo")
48
+    private String foo;
49
+
50
+    @ApiModelProperty("Bar")
51
+    private String bar;
52
+
53
+    @ApiModelProperty("Remark")
54
+    private String remark;
55
+
56
+    @ApiModelProperty("State,0:Disable,1:Enable")
57
+    private Integer state;
58
+
59
+    @ApiModelProperty("Version")
60
+    private Integer version;
61
+
62
+    @ApiModelProperty("Create Time")
63
+    private Date createTime;
64
+
65
+    @ApiModelProperty("Update Time")
66
+    private Date updateTime;
67
+
68
+}

+ 111
- 0
example/src/main/java/com/example/order/controller/ExampleOrderController.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.order.controller;
18
+
19
+import com.example.order.entity.ExampleOrder;
20
+import com.example.order.service.ExampleOrderService;
21
+import lombok.extern.slf4j.Slf4j;
22
+import com.example.order.param.ExampleOrderPageParam;
23
+import io.geekidea.springbootplus.framework.common.controller.BaseController;
24
+import io.geekidea.springbootplus.framework.common.api.ApiResult;
25
+import io.geekidea.springbootplus.framework.core.pagination.Paging;
26
+import io.geekidea.springbootplus.framework.common.param.IdParam;
27
+import io.geekidea.springbootplus.framework.log.annotation.Module;
28
+import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
29
+import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
30
+import io.geekidea.springbootplus.framework.core.validator.groups.Add;
31
+import io.geekidea.springbootplus.framework.core.validator.groups.Update;
32
+import org.springframework.validation.annotation.Validated;
33
+import org.apache.shiro.authz.annotation.RequiresPermissions;
34
+import io.swagger.annotations.Api;
35
+import io.swagger.annotations.ApiOperation;
36
+import org.springframework.beans.factory.annotation.Autowired;
37
+import org.springframework.web.bind.annotation.*;
38
+
39
+/**
40
+ * 订单示例 控制器
41
+ *
42
+ * @author geekidea
43
+ * @since 2020-03-27
44
+ */
45
+@Slf4j
46
+@RestController
47
+@RequestMapping("/exampleOrder")
48
+@Module("order")
49
+@Api(value = "ExampleOrderAPI", tags = {"ExampleOrder"})
50
+public class ExampleOrderController extends BaseController {
51
+
52
+    @Autowired
53
+    private ExampleOrderService exampleOrderService;
54
+
55
+    /**
56
+     * 添加订单示例
57
+     */
58
+    @PostMapping("/add")
59
+    @OperationLog(name = "添加订单示例", type = OperationLogType.ADD)
60
+    @ApiOperation(value = "添加订单示例", response = ApiResult.class)
61
+    public ApiResult<Boolean> addExampleOrder(@Validated(Add.class) @RequestBody ExampleOrder exampleOrder) throws Exception {
62
+        boolean flag = exampleOrderService.saveExampleOrder(exampleOrder);
63
+        return ApiResult.result(flag);
64
+    }
65
+
66
+    /**
67
+     * 修改订单示例
68
+     */
69
+    @PostMapping("/update")
70
+    @OperationLog(name = "修改订单示例", type = OperationLogType.UPDATE)
71
+    @ApiOperation(value = "修改订单示例", response = ApiResult.class)
72
+    public ApiResult<Boolean> updateExampleOrder(@Validated(Update.class) @RequestBody ExampleOrder exampleOrder) throws Exception {
73
+        boolean flag = exampleOrderService.updateExampleOrder(exampleOrder);
74
+        return ApiResult.result(flag);
75
+    }
76
+
77
+    /**
78
+     * 删除订单示例
79
+     */
80
+    @PostMapping("/delete/{id}")
81
+    @OperationLog(name = "删除订单示例", type = OperationLogType.DELETE)
82
+    @ApiOperation(value = "删除订单示例", response = ApiResult.class)
83
+    public ApiResult<Boolean> deleteExampleOrder(@PathVariable("id") Long id) throws Exception {
84
+        boolean flag = exampleOrderService.deleteExampleOrder(id);
85
+        return ApiResult.result(flag);
86
+    }
87
+
88
+    /**
89
+     * 获取订单示例详情
90
+     */
91
+    @GetMapping("/info/{id}")
92
+    @OperationLog(name = "订单示例详情", type = OperationLogType.INFO)
93
+    @ApiOperation(value = "订单示例详情", response = ExampleOrder.class)
94
+    public ApiResult<ExampleOrder> getExampleOrder(@PathVariable("id") Long id) throws Exception {
95
+        ExampleOrder exampleOrder = exampleOrderService.getById(id);
96
+        return ApiResult.ok(exampleOrder);
97
+    }
98
+
99
+    /**
100
+     * 订单示例分页列表
101
+     */
102
+    @PostMapping("/getPageList")
103
+    @OperationLog(name = "订单示例分页列表", type = OperationLogType.PAGE)
104
+    @ApiOperation(value = "订单示例分页列表", response = ExampleOrder.class)
105
+    public ApiResult<Paging<ExampleOrder>> getExampleOrderPageList(@Validated @RequestBody ExampleOrderPageParam exampleOrderPageParam) throws Exception {
106
+        Paging<ExampleOrder> paging = exampleOrderService.getExampleOrderPageList(exampleOrderPageParam);
107
+        return ApiResult.ok(paging);
108
+    }
109
+
110
+}
111
+

+ 74
- 0
example/src/main/java/com/example/order/entity/ExampleOrder.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.order.entity;
18
+
19
+import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
20
+import com.baomidou.mybatisplus.annotation.IdType;
21
+import java.util.Date;
22
+import com.baomidou.mybatisplus.annotation.Version;
23
+import com.baomidou.mybatisplus.annotation.TableId;
24
+import io.swagger.annotations.ApiModel;
25
+import io.swagger.annotations.ApiModelProperty;
26
+import lombok.Data;
27
+import lombok.EqualsAndHashCode;
28
+import lombok.experimental.Accessors;
29
+import javax.validation.constraints.NotBlank;
30
+import javax.validation.constraints.NotNull;
31
+import io.geekidea.springbootplus.framework.core.validator.groups.Update;
32
+
33
+/**
34
+ * 订单示例
35
+ *
36
+ * @author geekidea
37
+ * @since 2020-03-27
38
+ */
39
+@Data
40
+@Accessors(chain = true)
41
+@EqualsAndHashCode(callSuper = true)
42
+@ApiModel(value = "ExampleOrder对象")
43
+public class ExampleOrder extends BaseEntity {
44
+    private static final long serialVersionUID = 1L;
45
+
46
+    @NotNull(message = "id不能为空", groups = {Update.class})
47
+    @ApiModelProperty("主键")
48
+    @TableId(value = "id", type = IdType.AUTO)
49
+    private Long id;
50
+
51
+    @NotBlank(message = "订单名称不能为空")
52
+    @ApiModelProperty("订单名称")
53
+    private String name;
54
+
55
+    @ApiModelProperty("订单编号")
56
+    private String orderNo;
57
+
58
+    @ApiModelProperty("备注")
59
+    private String remark;
60
+
61
+    @ApiModelProperty("状态,0:禁用,1:启用")
62
+    private Integer state;
63
+
64
+    @ApiModelProperty("版本")
65
+    @Version
66
+    private Integer version;
67
+
68
+    @ApiModelProperty("创建时间")
69
+    private Date createTime;
70
+
71
+    @ApiModelProperty("修改时间")
72
+    private Date updateTime;
73
+
74
+}

+ 40
- 0
example/src/main/java/com/example/order/mapper/ExampleOrderMapper.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.order.mapper;
18
+
19
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
20
+import com.example.order.entity.ExampleOrder;
21
+import com.example.order.param.ExampleOrderPageParam;
22
+
23
+import org.springframework.stereotype.Repository;
24
+
25
+import com.baomidou.mybatisplus.core.metadata.IPage;
26
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
27
+import org.apache.ibatis.annotations.Param;
28
+import java.io.Serializable;
29
+
30
+/**
31
+ * 订单示例 Mapper 接口
32
+ *
33
+ * @author geekidea
34
+ * @since 2020-03-27
35
+ */
36
+@Repository
37
+public interface ExampleOrderMapper extends BaseMapper<ExampleOrder> {
38
+
39
+
40
+}

+ 47
- 0
example/src/main/java/com/example/order/param/ExampleOrderPageParam.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.order.param;
18
+
19
+import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
20
+import io.swagger.annotations.ApiModel;
21
+import io.swagger.annotations.ApiModelProperty;
22
+import lombok.Data;
23
+import lombok.EqualsAndHashCode;
24
+import lombok.experimental.Accessors;
25
+
26
+/**
27
+ * <pre>
28
+ * 订单示例 分页参数对象
29
+ * </pre>
30
+ *
31
+ * @author geekidea
32
+ * @date 2020-03-27
33
+ */
34
+@Data
35
+@Accessors(chain = true)
36
+@EqualsAndHashCode(callSuper = true)
37
+@ApiModel(value = "订单示例分页参数")
38
+public class ExampleOrderPageParam extends BasePageOrderParam {
39
+    private static final long serialVersionUID = 6092080418269664419L;
40
+
41
+    @ApiModelProperty("订单名称")
42
+    private String name;
43
+
44
+    @ApiModelProperty("订单编号")
45
+    private String orderNo;
46
+
47
+}

+ 69
- 0
example/src/main/java/com/example/order/service/ExampleOrderService.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.order.service;
18
+
19
+import com.example.order.entity.ExampleOrder;
20
+import com.example.order.param.ExampleOrderPageParam;
21
+import io.geekidea.springbootplus.framework.common.service.BaseService;
22
+import io.geekidea.springbootplus.framework.core.pagination.Paging;
23
+
24
+/**
25
+ * 订单示例 服务类
26
+ *
27
+ * @author geekidea
28
+ * @since 2020-03-27
29
+ */
30
+public interface ExampleOrderService extends BaseService<ExampleOrder> {
31
+
32
+    /**
33
+     * 保存
34
+     *
35
+     * @param exampleOrder
36
+     * @return
37
+     * @throws Exception
38
+     */
39
+    boolean saveExampleOrder(ExampleOrder exampleOrder) throws Exception;
40
+
41
+    /**
42
+     * 修改
43
+     *
44
+     * @param exampleOrder
45
+     * @return
46
+     * @throws Exception
47
+     */
48
+    boolean updateExampleOrder(ExampleOrder exampleOrder) throws Exception;
49
+
50
+    /**
51
+     * 删除
52
+     *
53
+     * @param id
54
+     * @return
55
+     * @throws Exception
56
+     */
57
+    boolean deleteExampleOrder(Long id) throws Exception;
58
+
59
+
60
+    /**
61
+     * 获取分页对象
62
+     *
63
+     * @param exampleOrderQueryParam
64
+     * @return
65
+     * @throws Exception
66
+     */
67
+    Paging<ExampleOrder> getExampleOrderPageList(ExampleOrderPageParam exampleOrderPageParam) throws Exception;
68
+
69
+}

+ 90
- 0
example/src/main/java/com/example/order/service/impl/ExampleOrderServiceImpl.java 查看文件

1
+/*
2
+ * Copyright 2019-2029 geekidea(https://github.com/geekidea)
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ *     http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+package com.example.order.service.impl;
18
+
19
+import com.example.order.entity.ExampleOrder;
20
+import com.example.order.mapper.ExampleOrderMapper;
21
+import com.example.order.service.ExampleOrderService;
22
+import com.example.order.param.ExampleOrderPageParam;
23
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
24
+import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
25
+import io.geekidea.springbootplus.framework.core.pagination.Paging;
26
+import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
27
+import com.baomidou.mybatisplus.core.metadata.IPage;
28
+import com.baomidou.mybatisplus.core.metadata.OrderItem;
29
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
30
+import org.apache.commons.lang3.StringUtils;
31
+import org.springframework.transaction.annotation.Transactional;
32
+import lombok.extern.slf4j.Slf4j;
33
+import org.springframework.stereotype.Service;
34
+import org.springframework.beans.factory.annotation.Autowired;
35
+
36
+/**
37
+ * 订单示例 服务实现类
38
+ *
39
+ * @author geekidea
40
+ * @since 2020-03-27
41
+ */
42
+@Slf4j
43
+@Service
44
+public class ExampleOrderServiceImpl extends BaseServiceImpl<ExampleOrderMapper, ExampleOrder> implements ExampleOrderService {
45
+
46
+    @Autowired
47
+    private ExampleOrderMapper exampleOrderMapper;
48
+
49
+    @Transactional(rollbackFor = Exception.class)
50
+    @Override
51
+    public boolean saveExampleOrder(ExampleOrder exampleOrder) throws Exception {
52
+        return super.save(exampleOrder);
53
+    }
54
+
55
+    @Transactional(rollbackFor = Exception.class)
56
+    @Override
57
+    public boolean updateExampleOrder(ExampleOrder exampleOrder) throws Exception {
58
+        return super.updateById(exampleOrder);
59
+    }
60
+
61
+    @Transactional(rollbackFor = Exception.class)
62
+    @Override
63
+    public boolean deleteExampleOrder(Long id) throws Exception {
64
+        return super.removeById(id);
65
+    }
66
+
67
+    @Override
68
+    public Paging<ExampleOrder> getExampleOrderPageList(ExampleOrderPageParam exampleOrderPageParam) throws Exception {
69
+        Page<ExampleOrder> page = new PageInfo<>(exampleOrderPageParam, OrderItem.desc(getLambdaColumn(ExampleOrder::getCreateTime)));
70
+        LambdaQueryWrapper<ExampleOrder> wrapper = new LambdaQueryWrapper<>();
71
+        String keyword = exampleOrderPageParam.getKeyword();
72
+        String name = exampleOrderPageParam.getName();
73
+        String orderNo = exampleOrderPageParam.getOrderNo();
74
+        // keyword模糊查询
75
+        if (StringUtils.isNotBlank(keyword)) {
76
+            wrapper.like(ExampleOrder::getName, keyword).or().like(ExampleOrder::getOrderNo, keyword);
77
+        }
78
+        // name模糊查询
79
+        if (StringUtils.isNotBlank(name)) {
80
+            wrapper.like(ExampleOrder::getName, name);
81
+        }
82
+        // 订单号模糊查询
83
+        if (StringUtils.isNotBlank(orderNo)) {
84
+            wrapper.like(ExampleOrder::getOrderNo, orderNo);
85
+        }
86
+        IPage<ExampleOrder> iPage = exampleOrderMapper.selectPage(page, wrapper);
87
+        return new Paging<ExampleOrder>(iPage);
88
+    }
89
+
90
+}

+ 21
- 0
example/src/main/resources/mapper/foobar/FooBarMapper.xml 查看文件

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+  ~ Copyright 2019-2029 geekidea(https://github.com/geekidea)
4
+  ~
5
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
6
+  ~ you may not use this file except in compliance with the License.
7
+  ~ You may obtain a copy of the License at
8
+  ~
9
+  ~     http://www.apache.org/licenses/LICENSE-2.0
10
+  ~
11
+  ~ Unless required by applicable law or agreed to in writing, software
12
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
13
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+  ~ See the License for the specific language governing permissions and
15
+  ~ limitations under the License.
16
+  -->
17
+
18
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
19
+<mapper namespace="com.example.foobar.mapper.FooBarMapper">
20
+
21
+</mapper>

+ 21
- 0
example/src/main/resources/mapper/order/ExampleOrderMapper.xml 查看文件

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+  ~ Copyright 2019-2029 geekidea(https://github.com/geekidea)
4
+  ~
5
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
6
+  ~ you may not use this file except in compliance with the License.
7
+  ~ You may obtain a copy of the License at
8
+  ~
9
+  ~     http://www.apache.org/licenses/LICENSE-2.0
10
+  ~
11
+  ~ Unless required by applicable law or agreed to in writing, software
12
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
13
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+  ~ See the License for the specific language governing permissions and
15
+  ~ limitations under the License.
16
+  -->
17
+
18
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
19
+<mapper namespace="com.example.order.mapper.ExampleOrderMapper">
20
+
21
+</mapper>

+ 36
- 0
framework/.gitignore 查看文件

1
+/target/
2
+/classes
3
+!.mvn/wrapper/maven-wrapper.jar
4
+
5
+### STS ###
6
+.apt_generated
7
+.classpath
8
+.factorypath
9
+.project
10
+.settings
11
+.springBeans
12
+.sts4-cache
13
+
14
+### IntelliJ IDEA ###
15
+.idea
16
+*.iws
17
+*.iml
18
+*.ipr
19
+
20
+### NetBeans ###
21
+/nbproject/private/
22
+/build/
23
+/nbbuild/
24
+/dist/
25
+/nbdist/
26
+/.nb-gradle/
27
+
28
+.DS_Store
29
+
30
+*.log
31
+logs
32
+
33
+*.rdb
34
+
35
+
36
+

+ 1
- 0
framework/README.md 查看文件

1
+# framework 项目核心框架模块

+ 102
- 0
framework/pom.xml 查看文件

1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<!--
4
+  ~ Copyright 2019-2029 geekidea(https://github.com/geekidea)
5
+  ~
6
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
7
+  ~ you may not use this file except in compliance with the License.
8
+  ~ You may obtain a copy of the License at
9
+  ~
10
+  ~     http://www.apache.org/licenses/LICENSE-2.0
11
+  ~
12
+  ~ Unless required by applicable law or agreed to in writing, software
13
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
14
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+  ~ See the License for the specific language governing permissions and
16
+  ~ limitations under the License.
17
+  -->
18
+
19
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21
+    <modelVersion>4.0.0</modelVersion>
22
+
23
+    <parent>
24
+        <groupId>io.geekidea.springbootplus</groupId>
25
+        <artifactId>parent</artifactId>
26
+        <version>2.0</version>
27
+    </parent>
28
+
29
+    <artifactId>framework</artifactId>
30
+    <name>framework</name>
31
+    <description>spring-boot-plus脚手架核心模块</description>
32
+
33
+    <dependencies>
34
+        <!-- spring-boot start -->
35
+        <dependency>
36
+            <groupId>org.springframework.boot</groupId>
37
+            <artifactId>spring-boot-starter-aop</artifactId>
38
+        </dependency>
39
+        <dependency>
40
+            <groupId>org.springframework.boot</groupId>
41
+            <artifactId>spring-boot-starter-tomcat</artifactId>
42
+        </dependency>
43
+        <dependency>
44
+            <groupId>org.springframework.boot</groupId>
45
+            <artifactId>spring-boot-starter-jdbc</artifactId>
46
+        </dependency>
47
+        <dependency>
48
+            <groupId>org.springframework.boot</groupId>
49
+            <artifactId>spring-boot-starter-data-redis</artifactId>
50
+        </dependency>
51
+        <!-- spring-boot end -->
52
+
53
+        <!-- mybatis-plus begin -->
54
+        <dependency>
55
+            <groupId>com.baomidou</groupId>
56
+            <artifactId>mybatis-plus-boot-starter</artifactId>
57
+        </dependency>
58
+        <!-- mybatis-plus end -->
59
+
60
+        <!-- MySQL -->
61
+        <dependency>
62
+            <groupId>mysql</groupId>
63
+            <artifactId>mysql-connector-java</artifactId>
64
+        </dependency>
65
+
66
+        <!-- swagger start -->
67
+        <dependency>
68
+            <groupId>io.springfox</groupId>
69
+            <artifactId>springfox-swagger2</artifactId>
70
+        </dependency>
71
+        <dependency>
72
+            <groupId>io.springfox</groupId>
73
+            <artifactId>springfox-swagger-ui</artifactId>
74
+        </dependency>
75
+        <!-- swagger end -->
76
+        <dependency>
77
+            <groupId>com.github.xiaoymin</groupId>
78
+            <artifactId>knife4j-spring-boot-starter</artifactId>
79
+        </dependency>
80
+
81
+        <!-- Shiro+JWT start -->
82
+        <dependency>
83
+            <groupId>org.apache.shiro</groupId>
84
+            <artifactId>shiro-spring</artifactId>
85
+            <version>${shiro.version}</version>
86
+        </dependency>
87
+
88
+        <dependency>
89
+            <groupId>com.auth0</groupId>
90
+            <artifactId>java-jwt</artifactId>
91
+            <version>${jwt.version}</version>
92
+        </dependency>
93
+        <!-- Shiro+JWT end -->
94
+
95
+        <dependency>
96
+            <groupId>io.geekidea.springbootplus</groupId>
97
+            <artifactId>config</artifactId>
98
+        </dependency>
99
+
100
+    </dependencies>
101
+
102
+</project>