Skip to content

Commit 4d48cc6

Browse files
committed
目录结构的更新
1 parent 5e24740 commit 4d48cc6

File tree

13 files changed

+163
-17
lines changed

13 files changed

+163
-17
lines changed

admin-api/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
<version>1.3.2</version>
2525
</dependency>
2626

27+
<!--分页插件-->
28+
<dependency>
29+
<groupId>com.github.pagehelper</groupId>
30+
<artifactId>pagehelper</artifactId>
31+
<version>5.1.7</version>
32+
</dependency>
33+
2734
<dependency>
2835
<groupId>mysql</groupId>
2936
<artifactId>mysql-connector-java</artifactId>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.lmxdawn.admin.constant;
2+
3+
/**
4+
* cookie常量
5+
*/
6+
public interface CookieConstant {
7+
8+
String TOKEN = "token";
9+
10+
Integer EXPIRE = 7200;
11+
}
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
package com.lmxdawn.admin.controller;
22

3+
import com.github.pagehelper.PageInfo;
34
import com.lmxdawn.admin.entity.AuthAdmin;
45
import com.lmxdawn.admin.service.AuthAdminService;
6+
import com.lmxdawn.admin.utils.ResultVOUtil;
7+
import com.lmxdawn.admin.vo.PageSimpleVO;
8+
import com.lmxdawn.admin.vo.ResultVO;
59
import org.springframework.beans.factory.annotation.Autowired;
610
import org.springframework.web.bind.annotation.GetMapping;
11+
import org.springframework.web.bind.annotation.RequestParam;
712
import org.springframework.web.bind.annotation.RestController;
813

9-
import java.util.List;
10-
1114
@RestController
1215
public class HelloController {
1316

1417
@Autowired
1518
private AuthAdminService authAdminService;
1619

1720
@GetMapping("/hello")
18-
public List<AuthAdmin> hello() {
19-
List<AuthAdmin> authAdminList = authAdminService.findByPage(null, 1, 10);
20-
System.out.println(authAdminList);
21-
return authAdminList;
21+
public ResultVO hello(
22+
@RequestParam(value = "offset") Integer offset
23+
, @RequestParam("offset") Integer limit
24+
) {
25+
PageSimpleVO<AuthAdmin> authAdminPageSimpleVO = authAdminService.findByPage(null, offset, limit);
26+
return ResultVOUtil.error(1, "ssss");
27+
// return ResultVOUtil.success(authAdminPageSimpleVO);
2228
}
2329

2430
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.lmxdawn.admin.converter;
2+
3+
4+
/**
5+
* 某个对象转另外一个对象
6+
*/
7+
public class OrderForm2OrderDTOConverter {
8+
9+
public static Object convert(Object orderForm) {
10+
return new Object();
11+
}
12+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.lmxdawn.admin.enums;
2+
3+
import lombok.Getter;
4+
5+
/**
6+
* 返回结果的枚举类
7+
*/
8+
@Getter
9+
public enum ResultEnum {
10+
11+
SUCCESS(0, "成功"),
12+
13+
;
14+
15+
private Integer code;
16+
17+
private String message;
18+
19+
ResultEnum(Integer code, String message) {
20+
this.code = code;
21+
this.message = message;
22+
}
23+
}

admin-api/src/main/java/com/lmxdawn/admin/service/AuthAdminService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33

44
import com.lmxdawn.admin.entity.AuthAdmin;
5-
6-
import java.util.List;
5+
import com.lmxdawn.admin.vo.PageSimpleVO;
76

87
public interface AuthAdminService {
98

10-
List<AuthAdmin> findByPage(String username, Integer currPage, Integer pageSize);
9+
PageSimpleVO<AuthAdmin> findByPage(String username, Integer currPage, Integer pageSize);
1110

1211
}

admin-api/src/main/java/com/lmxdawn/admin/service/impl/AuthAdminServiceImpl.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package com.lmxdawn.admin.service.impl;
22

3+
import com.github.pagehelper.PageHelper;
4+
import com.github.pagehelper.PageInfo;
35
import com.lmxdawn.admin.dao.AuthAdminDao;
46
import com.lmxdawn.admin.entity.AuthAdmin;
57
import com.lmxdawn.admin.service.AuthAdminService;
8+
import com.lmxdawn.admin.vo.PageSimpleVO;
69
import org.springframework.stereotype.Service;
710

811
import javax.annotation.Resource;
@@ -17,14 +20,16 @@ public class AuthAdminServiceImpl implements AuthAdminService {
1720
private AuthAdminDao authAdminDao;
1821

1922
@Override
20-
public List<AuthAdmin> findByPage(String username, Integer currPage, Integer pageSize) {
21-
currPage = currPage > 0 ? currPage : 1;
22-
pageSize = pageSize > 0 && pageSize <= 20 ? pageSize : 20;
23+
public PageSimpleVO<AuthAdmin> findByPage(String username, Integer currPage, Integer pageSize) {
2324
Map<String, Object> map = new HashMap<>();
2425
map.put("username", username);
25-
map.put("currIndex", (currPage - 1) * pageSize);
26-
map.put("pageSize", pageSize);
27-
return authAdminDao.findByPage(map);
26+
PageHelper.offsetPage(currPage, pageSize);
27+
List<AuthAdmin> list = authAdminDao.findByPage(map);
28+
PageInfo<AuthAdmin> page = new PageInfo<>(list);
29+
PageSimpleVO<AuthAdmin> pageSimpleVO = new PageSimpleVO<>();
30+
pageSimpleVO.setTotal(page.getTotal());
31+
pageSimpleVO.setList(page.getList());
32+
return pageSimpleVO;
2833
}
2934

3035
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.lmxdawn.admin.utils;
2+
3+
import com.lmxdawn.admin.vo.ResultVO;
4+
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
/**
9+
* 返回结果的操作类
10+
*/
11+
public class ResultVOUtil {
12+
13+
/**
14+
* 成功时返回
15+
* @param data 返回的data对象
16+
* @return {@link ResultVO}
17+
*/
18+
public static ResultVO success(Object data) {
19+
ResultVO<Object> resultVO = new ResultVO<>();
20+
resultVO.setCode(0);
21+
resultVO.setMessage("success");
22+
resultVO.setData(data);
23+
return resultVO;
24+
}
25+
26+
/**
27+
* 错误时返回
28+
* @param code 错误码
29+
* @param message 错误信息
30+
* @return {@link ResultVO}
31+
*/
32+
public static ResultVO error(Integer code, String message) {
33+
ResultVO<Object> resultVO = new ResultVO<>();
34+
resultVO.setCode(code);
35+
resultVO.setMessage(message);
36+
Map data = new HashMap();
37+
resultVO.setData(data);
38+
return resultVO;
39+
}
40+
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.lmxdawn.admin.vo;
2+
3+
import lombok.Data;
4+
5+
import java.util.List;
6+
7+
/**
8+
* 简单的分页返回对象
9+
*/
10+
@Data
11+
public class PageSimpleVO<T> {
12+
// 总数
13+
private Long total;
14+
// 列表
15+
private List<T> list;
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.lmxdawn.admin.vo;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* 返回结果类
7+
* @param <T>
8+
*/
9+
@Data
10+
public class ResultVO<T> {
11+
12+
private Integer code;
13+
14+
private String message;
15+
16+
private T data;
17+
}

0 commit comments

Comments
 (0)