forked from abel533/MyBatis-Spring-Boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
693 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/main/java/tk/mybatis/springboot/controller/CityController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014-2016 [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package tk.mybatis.springboot.controller; | ||
|
||
import com.github.pagehelper.PageInfo; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.servlet.ModelAndView; | ||
import org.springframework.web.servlet.mvc.support.RedirectAttributes; | ||
import tk.mybatis.springboot.model.City; | ||
import tk.mybatis.springboot.service.CityService; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author liuzh | ||
* @since 2015-12-19 11:10 | ||
*/ | ||
@RestController | ||
@RequestMapping("/cities") | ||
public class CityController { | ||
|
||
@Autowired | ||
private CityService cityService; | ||
|
||
@RequestMapping | ||
public PageInfo<City> getAll(City city) { | ||
List<City> countryList = cityService.getAll(city); | ||
return new PageInfo<City>(countryList); | ||
} | ||
|
||
@RequestMapping(value = "/add") | ||
public City add() { | ||
return new City(); | ||
} | ||
|
||
@RequestMapping(value = "/view/{id}") | ||
public City view(@PathVariable Integer id) { | ||
ModelAndView result = new ModelAndView(); | ||
City city = cityService.getById(id); | ||
return city; | ||
} | ||
|
||
@RequestMapping(value = "/delete/{id}") | ||
public ModelMap delete(@PathVariable Integer id) { | ||
ModelMap result = new ModelMap(); | ||
cityService.deleteById(id); | ||
result.put("msg", "删除成功!"); | ||
return result; | ||
} | ||
|
||
@RequestMapping(value = "/save", method = RequestMethod.POST) | ||
public ModelMap save(City city) { | ||
ModelMap result = new ModelMap(); | ||
String msg = city.getId() == null ? "新增成功!" : "更新成功!"; | ||
cityService.save(city); | ||
result.put("city", city); | ||
result.put("msg", msg); | ||
return result; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/tk/mybatis/springboot/controller/UserInfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014-2016 [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package tk.mybatis.springboot.controller; | ||
|
||
import com.github.pagehelper.PageInfo; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.ui.ModelMap; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.servlet.ModelAndView; | ||
import tk.mybatis.springboot.model.UserInfo; | ||
import tk.mybatis.springboot.service.UserInfoService; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author liuzh | ||
* @since 2015-12-19 11:10 | ||
*/ | ||
@RestController | ||
@RequestMapping("/users") | ||
public class UserInfoController { | ||
|
||
@Autowired | ||
private UserInfoService userInfoService; | ||
|
||
@RequestMapping | ||
public PageInfo<UserInfo> getAll(UserInfo userInfo) { | ||
List<UserInfo> userInfoList = userInfoService.getAll(userInfo); | ||
return new PageInfo<UserInfo>(userInfoList); | ||
} | ||
|
||
@RequestMapping(value = "/add") | ||
public UserInfo add() { | ||
return new UserInfo(); | ||
} | ||
|
||
@RequestMapping(value = "/view/{id}") | ||
public UserInfo view(@PathVariable Integer id) { | ||
ModelAndView result = new ModelAndView(); | ||
UserInfo userInfo = userInfoService.getById(id); | ||
return userInfo; | ||
} | ||
|
||
@RequestMapping(value = "/delete/{id}") | ||
public ModelMap delete(@PathVariable Integer id) { | ||
ModelMap result = new ModelMap(); | ||
userInfoService.deleteById(id); | ||
result.put("msg", "删除成功!"); | ||
return result; | ||
} | ||
|
||
@RequestMapping(value = "/save", method = RequestMethod.POST) | ||
public ModelMap save(UserInfo userInfo) { | ||
ModelMap result = new ModelMap(); | ||
String msg = userInfo.getId() == null ? "新增成功!" : "更新成功!"; | ||
userInfoService.save(userInfo); | ||
result.put("userInfo", userInfo); | ||
result.put("msg", msg); | ||
return result; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/tk/mybatis/springboot/mapper/CityMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014-2016 [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package tk.mybatis.springboot.mapper; | ||
|
||
import tk.mybatis.springboot.model.City; | ||
import tk.mybatis.springboot.util.MyMapper; | ||
|
||
/** | ||
* @author liuzh_3nofxnp | ||
* @since 2016-01-22 22:17 | ||
*/ | ||
public interface CityMapper extends MyMapper<City> { | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/tk/mybatis/springboot/mapper/UserInfoMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014-2016 [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package tk.mybatis.springboot.mapper; | ||
|
||
import tk.mybatis.springboot.model.UserInfo; | ||
import tk.mybatis.springboot.util.MyMapper; | ||
|
||
/** | ||
* @author liuzh_3nofxnp | ||
* @since 2016-01-22 22:17 | ||
*/ | ||
public interface UserInfoMapper extends MyMapper<UserInfo> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2014-2016 [email protected] | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package tk.mybatis.springboot.model; | ||
|
||
import javax.persistence.*; | ||
|
||
/** | ||
* 基础信息 | ||
* | ||
* @author liuzh | ||
* @since 2016-01-31 21:42 | ||
*/ | ||
public class BaseEntity { | ||
@Id | ||
@Column(name = "Id") | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Integer id; | ||
|
||
@Transient | ||
private Integer page = 1; | ||
|
||
@Transient | ||
private Integer rows = 10; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Integer id) { | ||
this.id = id; | ||
} | ||
|
||
public Integer getPage() { | ||
return page; | ||
} | ||
|
||
public void setPage(Integer page) { | ||
this.page = page; | ||
} | ||
|
||
public Integer getRows() { | ||
return rows; | ||
} | ||
|
||
public void setRows(Integer rows) { | ||
this.rows = rows; | ||
} | ||
} |
Oops, something went wrong.