22
33import info .xiaomo .api .model .AdminModel ;
44import info .xiaomo .api .service .AdminUserService ;
5- import info .xiaomo .core .constant .Err ;
6- import info .xiaomo .core .controller .BaseController ;
7- import info .xiaomo .core .controller .Result ;
5+ import info .xiaomo .core .constant .Code ;
6+ import info .xiaomo .core .base .BaseController ;
7+ import info .xiaomo .core .base .Result ;
88import info .xiaomo .core .exception .UserNotFoundException ;
99import info .xiaomo .core .untils .MD5Util ;
1010import info .xiaomo .core .untils .RandomUtil ;
1111import io .swagger .annotations .*;
1212import org .springframework .beans .factory .annotation .Autowired ;
13+ import org .springframework .data .domain .Page ;
1314import org .springframework .http .MediaType ;
1415import org .springframework .web .bind .annotation .*;
1516
@@ -67,10 +68,10 @@ public AdminUserController(AdminUserService service) {
6768 public Result login (@ PathVariable ("userName" ) String userName , @ PathVariable ("password" ) String password ) {
6869 AdminModel adminModel = service .findAdminUserByUserName (userName );
6970 if (adminModel == null ) {
70- return new Result (Err .USER_NOT_FOUND .getResultCode (), Err .USER_NOT_FOUND .getMessage ());
71+ return new Result (Code .USER_NOT_FOUND .getResultCode (), Code .USER_NOT_FOUND .getMessage ());
7172 }
7273 if (!MD5Util .encode (password , adminModel .getSalt ()).equals (adminModel .getPassword ())) {
73- return new Result (Err .AUTH_FAILED .getResultCode (), Err .AUTH_FAILED .getMessage ());
74+ return new Result (Code .AUTH_FAILED .getResultCode (), Code .AUTH_FAILED .getMessage ());
7475 }
7576 return new Result (adminModel );
7677 }
@@ -90,13 +91,13 @@ public Result login(@PathVariable("userName") String userName, @PathVariable("pa
9091 public Result add (@ RequestBody AdminModel model ) {
9192 AdminModel adminModel = service .findAdminUserByUserName (model .getUserName ());
9293 if (adminModel != null ) {
93- return new Result (Err .ADMIN_USER_REPEAT .getResultCode (), Err .ADMIN_USER_REPEAT .getMessage ());
94+ return new Result (Code .ADMIN_USER_REPEAT .getResultCode (), Code .ADMIN_USER_REPEAT .getMessage ());
9495 }
9596 String salt = RandomUtil .createSalt ();
9697 model .setSalt (salt );
9798 model .setPassword (MD5Util .encode (model .getPassword (), salt ));
9899 AdminModel saveModel = service .addAdminUser (model );
99- return new Result (saveModel );
100+ return new Result <> (saveModel );
100101 }
101102
102103 /**
@@ -117,9 +118,42 @@ public Result add(@RequestBody AdminModel model) {
117118 public Result findUserById (@ PathVariable ("id" ) Long id ) {
118119 AdminModel adminModel = service .findAdminUserById (id );
119120 if (adminModel == null ) {
120- return new Result (Err .NULL_DATA .getResultCode (), Err .NULL_DATA .getMessage ());
121+ return new Result (Code .NULL_DATA .getResultCode (), Code .NULL_DATA .getMessage ());
121122 }
122- return new Result (adminModel );
123+ return new Result <>(adminModel );
124+ }
125+
126+ /**
127+ * 查找所有(不带分页)
128+ *
129+ * @return result
130+ */
131+ @ Override
132+ public Result <List > findAll () {
133+ return null ;
134+ }
135+
136+ /**
137+ * 带分页
138+ *
139+ * @param start 起始页
140+ * @param pageSize 页码数
141+ * @return result
142+ */
143+ @ Override
144+ public Result <Page > findAll (@ PathVariable int start , @ PathVariable int pageSize ) {
145+ return null ;
146+ }
147+
148+ /**
149+ * 根据id查看模型
150+ *
151+ * @param id id
152+ * @return result
153+ */
154+ @ Override
155+ public Result findById (@ PathVariable Long id ) {
156+ return null ;
123157 }
124158
125159 /**
@@ -140,9 +174,64 @@ public Result findUserById(@PathVariable("id") Long id) {
140174 public Result findByName (@ PathVariable ("userName" ) String userName ) {
141175 AdminModel adminModel = service .findAdminUserByUserName (userName );
142176 if (adminModel == null ) {
143- return new Result (Err .NULL_DATA .getResultCode (), Err .NULL_DATA .getMessage ());
177+ return new Result (Code .NULL_DATA .getResultCode (), Code .NULL_DATA .getMessage ());
144178 }
145- return new Result (adminModel );
179+ return new Result <>(adminModel );
180+ }
181+
182+ /**
183+ * 根据名字删除模型
184+ *
185+ * @param name name
186+ * @return result
187+ */
188+ @ Override
189+ public Result <Boolean > delByName (@ PathVariable String name ) {
190+ return null ;
191+ }
192+
193+ /**
194+ * 根据id删除模型
195+ *
196+ * @param id id
197+ * @return result
198+ */
199+ @ Override
200+ public Result <Boolean > delById (@ PathVariable Long id ) {
201+ return null ;
202+ }
203+
204+ /**
205+ * 添加模型
206+ *
207+ * @param model model
208+ * @return result
209+ */
210+ @ Override
211+ public Result <Boolean > add (@ RequestBody Object model ) {
212+ return null ;
213+ }
214+
215+ /**
216+ * 更新
217+ *
218+ * @param model model
219+ * @return result
220+ */
221+ @ Override
222+ public Result <Boolean > update (@ RequestBody Object model ) {
223+ return null ;
224+ }
225+
226+ /**
227+ * 批量删除
228+ *
229+ * @param ids ids
230+ * @return result
231+ */
232+ @ Override
233+ public Result <Boolean > delByIds (@ PathVariable List ids ) {
234+ return null ;
146235 }
147236
148237 /**
@@ -160,13 +249,13 @@ public Result findByName(@PathVariable("userName") String userName) {
160249 public Result changePassword (@ RequestBody AdminModel model ) throws UserNotFoundException {
161250 AdminModel adminModel = service .findAdminUserByUserName (model .getUserName ());
162251 if (adminModel == null ) {
163- return new Result (Err .NULL_DATA .getResultCode (), Err .NULL_DATA .getMessage ());
252+ return new Result (Code .NULL_DATA .getResultCode (), Code .NULL_DATA .getMessage ());
164253 }
165254 String salt = RandomUtil .createSalt ();
166255 adminModel .setSalt (salt );
167256 adminModel .setPassword (MD5Util .encode (model .getPassword (), salt ));
168257 service .updateAdminUser (adminModel );
169- return new Result (adminModel );
258+ return new Result <> (adminModel );
170259 }
171260
172261
@@ -184,9 +273,9 @@ public Result changePassword(@RequestBody AdminModel model) throws UserNotFoundE
184273 public Result getAll () {
185274 List <AdminModel > pages = service .getAdminUsers ();
186275 if (pages == null || pages .size () <= 0 ) {
187- return new Result (pages );
276+ return new Result <> (pages );
188277 }
189- return new Result (pages );
278+ return new Result <> (pages );
190279 }
191280
192281 /**
@@ -208,10 +297,10 @@ public Result getAll() {
208297 public Result deleteUserById (@ PathVariable ("id" ) Long id ) throws UserNotFoundException {
209298 AdminModel adminModel = service .findAdminUserById (id );
210299 if (adminModel == null ) {
211- return new Result (Err .NULL_DATA .getResultCode (), Err .NULL_DATA .getMessage ());
300+ return new Result (Code .NULL_DATA .getResultCode (), Code .NULL_DATA .getMessage ());
212301 }
213302 service .deleteAdminUserById (id );
214- return new Result (adminModel );
303+ return new Result <> (adminModel );
215304 }
216305
217306 /**
@@ -237,7 +326,7 @@ public Result update(@PathVariable("userName") String userName) throws UserNotFo
237326 }
238327 adminModel .setUserName (userName );
239328 service .updateAdminUser (adminModel );
240- return new Result (adminModel );
329+ return new Result <> (adminModel );
241330 }
242331
243332 /**
@@ -259,10 +348,10 @@ public Result update(@PathVariable("userName") String userName) throws UserNotFo
259348 public Result forbid (@ PathVariable ("id" ) Long id ) throws UserNotFoundException {
260349 AdminModel model = service .findAdminUserById (id );
261350 if (model == null ) {
262- return new Result (Err .NULL_DATA .getResultCode (), Err .NULL_DATA .getMessage ());
351+ return new Result (Code .NULL_DATA .getResultCode (), Code .NULL_DATA .getMessage ());
263352 }
264353 model = service .forbidAdminUserById (id );
265- return new Result (model );
354+ return new Result <> (model );
266355 }
267356}
268357
0 commit comments