Skip to content

Commit 8983b9d

Browse files
committed
完成基础代码生成逻辑
1 parent 654a490 commit 8983b9d

26 files changed

+641
-164
lines changed

quick-platform-common/src/main/java/com/quick/common/base/rest/BaseController.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
*/
66
public interface BaseController {
77

8+
default BaseResp<Boolean> success() {
9+
return BaseResp.success();
10+
}
11+
12+
default <T> BaseResp<T> success(T data) {
13+
return success(data,"");
14+
}
15+
816
default <T> BaseResp<T> success(T data, String msg) {
917
return BaseResp.success(data, msg);
1018
}

quick-platform-common/src/main/java/com/quick/common/base/rest/BaseResp.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ public BaseResp(ResultStatus resultStatus, T data) {
9595
this.currentTime = new Date().getTime();
9696
}
9797

98+
public static BaseResp<Boolean> success() {
99+
BaseResp<Boolean> response = new BaseResp<Boolean>();
100+
response.setCode(ResultStatus.SUCCESS);
101+
return response;
102+
}
103+
98104
public static <T> BaseResp<T> success(T data, String msg) {
99105
BaseResp<T> response = new BaseResp<T>();
100106
response.setCode(ResultStatus.SUCCESS);

quick-sample-server/sample-server/src/main/java/com/quick/controller/SampleController.java

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.quick.controller;
2+
3+
import com.quick.entity.SampleTable;
4+
import com.quick.service.SampleTableService;
5+
import cn.hutool.core.lang.Assert;
6+
import com.quick.common.base.rest.BaseResp;
7+
import org.springframework.web.bind.annotation.*;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.http.MediaType;
10+
import com.quick.common.base.rest.BaseController;
11+
12+
13+
/**
14+
* <p>
15+
* 前端控制器
16+
* </p>
17+
*
18+
* @author vector4wang
19+
* @version ${cfg.version}
20+
* @since 2023-10-17
21+
*/
22+
@RestController
23+
@RequestMapping(value = {"/sampleTable" },
24+
produces = MediaType.APPLICATION_JSON_VALUE)
25+
public class SampleTableController implements BaseController {
26+
27+
@Autowired
28+
private SampleTableService sampleTableService;
29+
30+
@ResponseBody
31+
@RequestMapping(value = "/list", method = RequestMethod.POST)
32+
public BaseResp list(@RequestBody SampleTable page) {
33+
34+
return success(sampleTableService.pageList(page));
35+
}
36+
37+
38+
@ResponseBody
39+
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
40+
public BaseResp<SampleTable> detail(@PathVariable String id) {
41+
return success(sampleTableService.getById(id));
42+
}
43+
44+
@ResponseBody
45+
@RequestMapping(value = "save", method = RequestMethod.POST)
46+
public BaseResp<Boolean> save(@RequestBody SampleTable sampleTable) {
47+
sampleTableService.saveEntity(sampleTable);
48+
return success();
49+
}
50+
51+
@ResponseBody
52+
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
53+
public BaseResp<Boolean> update(@PathVariable String id, @RequestBody SampleTable sampleTable) {
54+
Assert.notEmpty(id, "ID不能为空");
55+
sampleTableService.updateById(sampleTable);
56+
return success();
57+
}
58+
59+
60+
@ResponseBody
61+
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
62+
public BaseResp<Boolean> delete(@PathVariable String id) {
63+
sampleTableService.delete(id);
64+
return success();
65+
}
66+
67+
}

quick-sample-server/sample-server/src/main/java/com/quick/entity/Sample.java

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.quick.entity;
2+
3+
import com.baomidou.mybatisplus.annotation.TableField;
4+
import com.baomidou.mybatisplus.annotation.TableId;
5+
import com.baomidou.mybatisplus.annotation.TableName;
6+
import lombok.Data;
7+
import lombok.experimental.Accessors;
8+
9+
import java.io.Serializable;
10+
import java.time.LocalDateTime;
11+
12+
13+
/**
14+
* <p>
15+
*
16+
* </p>
17+
*
18+
* @author vector4wang
19+
* @version ${cfg.version}
20+
* @since 2023-10-17
21+
*/
22+
@Data
23+
@Accessors(chain = true)
24+
@TableName("sample_table")
25+
public class SampleTable implements Serializable {
26+
27+
private static final long serialVersionUID = 1L;
28+
29+
30+
@TableId("id")
31+
@TableField("id")
32+
private Long id;
33+
private String name;
34+
private String userCode;
35+
private String address;
36+
private LocalDateTime createTime;
37+
private LocalDateTime updateTime;
38+
39+
40+
}

quick-sample-server/sample-server/src/main/java/com/quick/mapper/SampleMapper.java

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.quick.mapper;
2+
3+
import com.quick.entity.SampleTable;
4+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5+
import org.springframework.stereotype.Repository;
6+
7+
/**
8+
* <p>
9+
* Mapper 接口
10+
* </p>
11+
*
12+
* @author vector4wang
13+
* @since 2023-10-17
14+
* @version ${cfg.version}
15+
*/
16+
@Repository
17+
public interface SampleTableMapper extends BaseMapper<SampleTable> {
18+
}

quick-sample-server/sample-server/src/main/java/com/quick/service/SampleService.java

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.quick.service;
2+
3+
import com.quick.entity.SampleTable;
4+
import com.baomidou.mybatisplus.extension.service.IService;
5+
6+
import java.util.List;
7+
8+
/**
9+
* <p>
10+
* 服务类
11+
* </p>
12+
*
13+
* @author vector4wang
14+
* @since 2023-10-17
15+
* @version ${cfg.version}
16+
*/
17+
public interface SampleTableService extends IService<SampleTable> {
18+
19+
20+
List<SampleTable> pageList(SampleTable sampleTable);
21+
22+
boolean saveEntity(SampleTable sampleTable);
23+
24+
void delete(String id);
25+
26+
27+
}

0 commit comments

Comments
 (0)