Skip to content

Commit 263d1d2

Browse files
committed
change
1 parent 02938ee commit 263d1d2

File tree

6 files changed

+57
-10
lines changed

6 files changed

+57
-10
lines changed

frontend/src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
</el-col>
1111
</el-row>
1212

13-
<el-row>
13+
<!-- <el-row>
1414
<el-col :span="24">
1515
<footer class="footer">
1616
<db-footer></db-footer>
1717
</footer>
1818
1919
</el-col>
20-
</el-row>
20+
</el-row> -->
2121
</div>
2222
</template>
2323

frontend/src/components/DbTable.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
},
117117
changePage: function (currentPage) {
118118
this.currentPage = currentPage;
119+
console.log("当前页面是:"+this.currentPage)
119120
this.getCustomers()
120121
},
121122
editItem: function (index, rows) {

info.db

3 KB
Binary file not shown.

src/main/java/com/boylegu/springboot_vue/controller/MainController.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.boylegu.springboot_vue.controller;
22

3+
import ch.qos.logback.core.net.SyslogOutputStream;
34
import com.boylegu.springboot_vue.entities.Persons;
45

6+
import org.springframework.data.domain.Page;
57
import org.springframework.web.bind.annotation.RequestMapping;
68
import org.springframework.web.bind.annotation.RequestMethod;
79
import org.springframework.web.bind.annotation.RequestParam;
@@ -143,6 +145,16 @@ public ResponseEntity<Persons> getUserDetail(@PathVariable Long id) {
143145

144146
Persons user = personsRepository.findById(id);
145147

148+
149+
//当前ID
150+
// int curCount=personsRepository.findCount();
151+
// int curId=curCount+1;
152+
// Persons persons=new Persons();
153+
// persons.setId(curId);
154+
155+
156+
157+
146158
return new ResponseEntity<>(user, HttpStatus.OK);
147159
}
148160

@@ -167,12 +179,41 @@ public Persons updateUser(@PathVariable Long id, @RequestBody Persons data) {
167179
* @apiSuccess {String} zone
168180
169181
*/
182+
System.out.println("进入put函数");
170183
Persons user = personsRepository.findById(id);
171184

172185
user.setPhone(data.getPhone());
173186

174187
user.setZone(data.getZone());
175188

189+
190+
Persons newUser=new Persons();
191+
// personsRepository.delete(15L);
192+
193+
newUser.setZone("tianjin");
194+
newUser.setPhone("123456");
195+
newUser.setEmail("[email protected]");
196+
newUser.setUsername("i am 16 id");
197+
newUser.setSex("female");
198+
newUser.setCreate_datetime("2017-06-29 11:02:56");
199+
personsRepository.save(newUser);
200+
System.out.println("当前数据库记录总数是"+personsRepository.count());
201+
202+
Persons selectUser=personsRepository.findById(3L);
203+
System.out.println(selectUser.getId());
204+
System.out.println(selectUser.getPhone());
205+
System.out.println(selectUser.getZone());
206+
System.out.println(selectUser.getEmail());
207+
System.out.println(selectUser.getSex());
208+
System.out.println(selectUser.getUsername());
209+
210+
211+
212+
Sort sort = new Sort(Direction.ASC, "id");
213+
Pageable pageable = new PageRequest(3, 7, sort);
214+
Page<Persons> temp = personsRepository.findAll(pageable);
215+
System.out.println("111111");
216+
176217
return personsRepository.save(user);
177218
}
178219

src/main/java/com/boylegu/springboot_vue/controller/pagination/PaginationFormatting.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public AllType(String sexName, String emailName, Pageable pageable) { //String s
106106

107107
public Page<Persons> query() {
108108

109+
this.instance.flush();
109110
return this.instance.findAll(
110111

111112
this.pageable

src/main/java/com/boylegu/springboot_vue/dao/PersonsRepository.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
package com.boylegu.springboot_vue.dao;
22

3-
import org.springframework.data.jpa.repository.JpaRepository;
4-
import org.springframework.data.jpa.repository.Query;
3+
import com.boylegu.springboot_vue.entities.Persons;
54
import org.springframework.data.domain.Page;
65
import org.springframework.data.domain.Pageable;
7-
import org.springframework.stereotype.Repository;
8-
9-
import com.boylegu.springboot_vue.entities.Persons;
10-
import org.springframework.web.bind.annotation.RequestParam;
6+
import org.springframework.data.jpa.repository.JpaRepository;
7+
import org.springframework.data.jpa.repository.Query;
118

129
import java.util.List;
13-
import java.util.Map;
1410

1511

1612
public interface PersonsRepository extends JpaRepository<Persons, Long> {
1713

18-
public static final String FIND_SEX = "select DISTINCT sex from Persons p";
14+
//查找当前数据库中记录总数
15+
public static final String FIND_COUNT = "select count(*) from Persons p";
16+
@Query(FIND_COUNT)
17+
int findCount();
18+
19+
1920

21+
22+
public static final String FIND_SEX = "select DISTINCT sex from Persons p";
2023
@Query(FIND_SEX)
2124
List<Persons> findSex();
2225

26+
2327
Page<Persons> findAll(Pageable pageable);
2428

2529
Page<Persons> findBySexAndEmailContains(String sexName, String emailName, Pageable pageable);

0 commit comments

Comments
 (0)