88import info .xiaomo .core .untils .RandomUtil ;
99import info .xiaomo .website .model .AdminModel ;
1010import info .xiaomo .website .service .AdminUserService ;
11- import io .swagger .annotations .*;
1211import org .springframework .beans .factory .annotation .Autowired ;
13- import org .springframework .http .MediaType ;
1412import org .springframework .web .bind .annotation .*;
1513
1614import java .util .List ;
3937 */
4038@ RestController
4139@ RequestMapping ("/adminUser" )
42- @ Api (value = "AdminUserController" , description = "后台用户相关api" )
4340public class AdminUserController extends BaseController {
4441
4542 private final AdminUserService service ;
@@ -55,15 +52,6 @@ public AdminUserController(AdminUserService service) {
5552 * @return Result
5653 */
5754 @ RequestMapping (value = "login/{userName}/{password}" , method = RequestMethod .POST )
58- @ ApiOperation (value = "获取用户信息" , notes = "根据用户帐号和密码登录后台" , httpMethod = "POST" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
59- @ ApiImplicitParams ({
60- @ ApiImplicitParam (name = "userName" , value = "用户名" , required = true , dataType = "Result" , paramType = "path" ),
61- @ ApiImplicitParam (name = "password" , value = "用户名" , required = true , dataType = "Result" , paramType = "path" )
62- })
63- @ ApiResponses (value = {
64- @ ApiResponse (code = 404 , message = "Not Found" ),
65- @ ApiResponse (code = 400 , message = "No Name Provided" ),
66- })
6755 public Result login (@ PathVariable ("userName" ) String userName , @ PathVariable ("password" ) String password ) {
6856 AdminModel adminModel = service .findAdminUserByUserName (userName );
6957 if (adminModel == null ) {
@@ -81,12 +69,7 @@ public Result login(@PathVariable("userName") String userName, @PathVariable("pa
8169 *
8270 * @return Result
8371 */
84- @ ApiOperation (value = "添加后台用户" , notes = "传一个管理员用户模型过来然后保存到数据库" , httpMethod = "POST" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
8572 @ RequestMapping (value = "add" , method = RequestMethod .POST )
86- @ ApiResponses (value = {
87- @ ApiResponse (code = 404 , message = "Not Found" ),
88- @ ApiResponse (code = 400 , message = "No Name Provided" ),
89- })
9073 public Result add (@ RequestBody AdminModel model ) {
9174 AdminModel adminModel = service .findAdminUserByUserName (model .getUserName ());
9275 if (adminModel != null ) {
@@ -105,15 +88,7 @@ public Result add(@RequestBody AdminModel model) {
10588 * @param id id
10689 * @return Result
10790 */
108- @ ApiOperation (value = "查找用户" , notes = "根据传来的id查找用户并返回" , httpMethod = "GET" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
10991 @ RequestMapping (value = "findById/{id}" , method = RequestMethod .GET )
110- @ ApiImplicitParams ({
111- @ ApiImplicitParam (name = "id" , value = "后台用户唯一id" , required = true , dataType = "Long" , paramType = "path" )
112- })
113- @ ApiResponses (value = {
114- @ ApiResponse (code = 404 , message = "Not Found" ),
115- @ ApiResponse (code = 400 , message = "No Name Provided" ),
116- })
11792 public Result findUserById (@ PathVariable ("id" ) Long id ) {
11893 AdminModel adminModel = service .findAdminUserById (id );
11994 if (adminModel == null ) {
@@ -128,15 +103,7 @@ public Result findUserById(@PathVariable("id") Long id) {
128103 * @param userName userName
129104 * @return Result
130105 */
131- @ ApiOperation (value = "查找用户" , notes = "根据传来的用户名查找用户并返回" , httpMethod = "GET" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
132106 @ RequestMapping (value = "findByName/{userName}" , method = RequestMethod .GET )
133- @ ApiImplicitParams ({
134- @ ApiImplicitParam (name = "userName" , value = "用户名" , required = true , dataType = "String" , paramType = "path" )
135- })
136- @ ApiResponses (value = {
137- @ ApiResponse (code = 404 , message = "Not Found" ),
138- @ ApiResponse (code = 400 , message = "No Name Provided" ),
139- })
140107 public Result findByName (@ PathVariable ("userName" ) String userName ) {
141108 AdminModel adminModel = service .findAdminUserByUserName (userName );
142109 if (adminModel == null ) {
@@ -152,11 +119,6 @@ public Result findByName(@PathVariable("userName") String userName) {
152119 * @throws UserNotFoundException UserNotFoundException
153120 */
154121 @ RequestMapping (value = "changePassword" , method = RequestMethod .POST )
155- @ ApiOperation (value = "修改用户密码" , notes = "传来模型验证并修改密码" , httpMethod = "POST" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
156- @ ApiResponses (value = {
157- @ ApiResponse (code = 404 , message = "Not Found" ),
158- @ ApiResponse (code = 400 , message = "No Name Provided" ),
159- })
160122 public Result changePassword (@ RequestBody AdminModel model ) throws UserNotFoundException {
161123 AdminModel adminModel = service .findAdminUserByUserName (model .getUserName ());
162124 if (adminModel == null ) {
@@ -176,11 +138,6 @@ public Result changePassword(@RequestBody AdminModel model) throws UserNotFoundE
176138 * @return 不分页
177139 */
178140 @ RequestMapping (value = "findAll" , method = RequestMethod .GET )
179- @ ApiOperation (value = "返回所有用户信息" , notes = "不分页" , httpMethod = "GET" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
180- @ ApiResponses (value = {
181- @ ApiResponse (code = 404 , message = "Not Found" ),
182- @ ApiResponse (code = 400 , message = "No Name Provided" ),
183- })
184141 public Result getAll () {
185142 List <AdminModel > pages = service .getAdminUsers ();
186143 if (pages == null || pages .size () <= 0 ) {
@@ -197,14 +154,6 @@ public Result getAll() {
197154 * @throws UserNotFoundException UserNotFoundException
198155 */
199156 @ RequestMapping (value = "delete/{id}" , method = RequestMethod .GET )
200- @ ApiOperation (value = "删除用户" , notes = "根据传入的id删除对应的用户" , httpMethod = "GET" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
201- @ ApiImplicitParams ({
202- @ ApiImplicitParam (name = "id" , value = "用户唯一id" , required = true , dataType = "Long" , paramType = "path" )
203- })
204- @ ApiResponses (value = {
205- @ ApiResponse (code = 404 , message = "Not Found" ),
206- @ ApiResponse (code = 400 , message = "No Name Provided" ),
207- })
208157 public Result deleteUserById (@ PathVariable ("id" ) Long id ) throws UserNotFoundException {
209158 AdminModel adminModel = service .findAdminUserById (id );
210159 if (adminModel == null ) {
@@ -222,14 +171,6 @@ public Result deleteUserById(@PathVariable("id") Long id) throws UserNotFoundExc
222171 * @throws UserNotFoundException UserNotFoundException
223172 */
224173 @ RequestMapping (value = "update/{userName}" , method = RequestMethod .POST )
225- @ ApiOperation (value = "更新用户信息" , notes = "根据传入的模型更新用户信息" , httpMethod = "POST" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
226- @ ApiImplicitParams ({
227- @ ApiImplicitParam (name = "userName" , value = "用户名" , required = true , dataType = "String" , paramType = "path" )
228- })
229- @ ApiResponses (value = {
230- @ ApiResponse (code = 404 , message = "Not Found" ),
231- @ ApiResponse (code = 400 , message = "No Name Provided" ),
232- })
233174 public Result update (@ PathVariable ("userName" ) String userName ) throws UserNotFoundException {
234175 AdminModel adminModel = service .findAdminUserByUserName (userName );
235176 if (adminModel == null ) {
@@ -248,14 +189,6 @@ public Result update(@PathVariable("userName") String userName) throws UserNotFo
248189 * @throws UserNotFoundException UserNotFoundException
249190 */
250191 @ RequestMapping (value = "forbid/{id}" , method = RequestMethod .GET )
251- @ ApiOperation (value = "封号" , notes = "根据传入的id对修改对应帐号状态" , httpMethod = "GET" , produces = MediaType .APPLICATION_JSON_UTF8_VALUE )
252- @ ApiImplicitParams ({
253- @ ApiImplicitParam (name = "id" , value = "后台用户唯一id" , required = true , dataType = "Long" , paramType = "path" )
254- })
255- @ ApiResponses (value = {
256- @ ApiResponse (code = 404 , message = "Not Found" ),
257- @ ApiResponse (code = 400 , message = "No Name Provided" ),
258- })
259192 public Result forbid (@ PathVariable ("id" ) Long id ) throws UserNotFoundException {
260193 AdminModel model = service .findAdminUserById (id );
261194 if (model == null ) {
0 commit comments