• 基于springboot健身管理系统微信小程序源码


    摘 要

    现如今人们在努力工作和改善生活的同时,也开始关心起自己是否拥有一个健康的体魄,因此去健身房锻炼的人越来越多。面对不断激增的用户数量,飞羽健身房还是以传统人工操作的方式管理用户,执行效率很低故开发基于微信小程序的飞羽健身管理系统,可帮助健身房经营者从繁杂的事务中解脱出来,以致于可以精确、便利、直观地获取信息。

    为了解决上面的问题,对现有的一些健身房的管理系统的执行效率进行调查和询问,进而分析其目的和意义;利用互联网查询和分析时下比较热门和实用的软件开发工具和数据库,在此基础上提出了使用Java语言技术、基于Springboot+MyBatis框架和采用MySQL数据库、使用微信开发者工具完成飞羽健身小程序的开发方案;最后,在对飞羽健身系统进行总体需求分析、系统功能设计、数据库表设计和数据关系模型设计等工作,实现了基于微信小程序的飞羽健身管理系统。小程序学员端主要有首页、查看课程、添加到购物车等功能、教练端主要有课程管理、查看近期课程和创建课程等功能,后台主要有用户管理、课程管理、请假管理等功能。

    该系统可以高效地管理健身学员用户信息和教练信息以及相关数据,解决了人手操作时的工作量大的问题,而且提高工作效率,使得飞羽健身房的管理者能集中精力于经营方面的内容。

    关键词:健身  微信小程序  SpringBoot  MySQL 

    【java毕业设计】基于微信小程序前端springboot的健身管理系统源码和论文

     

     

     

    1. package cn.com.itcast.sport.controller;
    2. import cn.com.itcast.sport.entry.*;
    3. import cn.com.itcast.sport.service.ApiService;
    4. import com.alibaba.fastjson.JSON;
    5. import com.github.pagehelper.Page;
    6. import com.github.pagehelper.PageHelper;
    7. import com.github.pagehelper.PageInfo;
    8. import io.swagger.annotations.ApiOperation;
    9. import org.apache.ibatis.annotations.Param;
    10. import org.springframework.beans.factory.annotation.Autowired;
    11. import org.springframework.stereotype.Controller;
    12. import org.springframework.web.bind.annotation.RequestMapping;
    13. import org.springframework.web.bind.annotation.RequestParam;
    14. import org.springframework.web.bind.annotation.ResponseBody;
    15. import java.math.BigDecimal;
    16. import java.text.ParseException;
    17. import java.text.SimpleDateFormat;
    18. import java.util.*;
    19. import java.util.stream.Collectors;
    20. @Controller
    21. @RequestMapping("/api")
    22. public class ApiController {
    23. @Autowired
    24. private ApiService apiService;
    25. public static String DATA_HM = "yyyy-MM-dd HH:mm";
    26. public static String DATA_DAY = "yyyy-MM-dd";
    27. public Date changeData(String date,String dataType) {
    28. if(dataType.equals(DATA_HM) ){
    29. date = date+":00";
    30. dataType = dataType+":ss";
    31. }
    32. SimpleDateFormat dateFormat = new SimpleDateFormat(dataType);
    33. Date parse = null;
    34. try {
    35. parse = dateFormat.parse(date);
    36. } catch (ParseException e) {
    37. e.printStackTrace();
    38. }
    39. return parse;
    40. }
    41. @RequestMapping(path = "/login")
    42. @ApiOperation("登录校验账号密码")
    43. @ResponseBody
    44. public Result login(@Param("userName") String userName, @Param("password") String password){
    45. return apiService.checkLogin(userName,password);
    46. }
    47. @RequestMapping(path = "/getPic")
    48. @ApiOperation("获取轮播图")
    49. @ResponseBody
    50. public Result getPic(){
    51. List pic = new ArrayList<>();
    52. pic.add("https://qq2118119173.oss-cn-beijing.aliyuncs.com/pics/logo1.jpg");
    53. pic.add("https://qq2118119173.oss-cn-beijing.aliyuncs.com/pics/logo2.jpg");
    54. pic.add("https://qq2118119173.oss-cn-beijing.aliyuncs.com/pics/logo3.jpg");
    55. return Result.success(pic);
    56. }
    57. @RequestMapping(path = "/course/queryCourses")
    58. @ApiOperation("查询全部课程,带参数则返回相应条件的数据,不带则返回全部")
    59. @ResponseBody
    60. public String queryCourses(@Param("courseName") String courseName, @Param("typeCode")String typeCode,
    61. @RequestParam(required=false,defaultValue="1") int page,
    62. @RequestParam(required=false,defaultValue="10") int limit){
    63. PageHelper.startPage(page, limit);
    64. List courseMains = apiService.queryCourses(courseName, typeCode);
    65. //用PageInfo对结果进行包装,传入连续显示的页数
    66. PageInfo pageInfo = new PageInfo(courseMains,limit);
    67. Map map = new HashMap();
    68. map.put("code","200");
    69. map.put("msg", "操作成功!");
    70. map.put("maxPage",pageInfo.getPages());
    71. map.put("data",pageInfo.getList());
    72. String json= JSON.toJSONString(map);
    73. //将map转换为json格式
    74. return json;
    75. }
    76. @RequestMapping(path = "/course/queryTeacherCourses")
    77. @ApiOperation("查询教练个人的课程,必须带userCode参数")
    78. @ResponseBody
    79. public String queryTeacherCourses(@Param("courseName") String courseName, @Param("typeCode")String typeCode,
    80. @Param("userCode")String userCode,
    81. @RequestParam(required=false,defaultValue="1") int page,
    82. @RequestParam(required=false,defaultValue="10") int limit){
    83. PageHelper.startPage(page, limit);
    84. List courseMains = apiService.queryTeacherCourses(courseName, typeCode,userCode);
    85. //用PageInfo对结果进行包装,传入连续显示的页数
    86. PageInfo pageInfo = new PageInfo(courseMains,limit);
    87. Map map = new HashMap();
    88. map.put("code","200");
    89. map.put("msg", "操作成功!");
    90. map.put("maxPage",pageInfo.getPages());
    91. map.put("data",pageInfo.getList());
    92. String json= JSON.toJSONString(map);
    93. //将map转换为json格式
    94. return json;
    95. }
    96. @RequestMapping(path = "/course/queryRecommendedCourses")
    97. @ApiOperation("查询推荐课程,带参数则返回相应条件的数据,不带则返回全部")
    98. @ResponseBody
    99. public Result queryRecommendedCourses(@Param("courseName") String courseName){
    100. List courseMains = apiService.queryRecommendedCourses(courseName);
    101. return Result.success(courseMains);
    102. }
    103. @RequestMapping(path = "/course/queryCourse")
    104. @ApiOperation("查看具体课程,必须带参数courseCode")
    105. @ResponseBody
    106. public Result queryCourse(@Param("userCode") String userCode,@Param("courseCode") String courseCode){
    107. CourseMain courseMain = apiService.queryCourse(userCode,courseCode);
    108. return Result.success(courseMain);
    109. }
    110. @RequestMapping(path = "/course/addCourse")
    111. @ApiOperation("添加课程,必须带参数")
    112. @ResponseBody
    113. public Result addCourse(@Param("courseName") String courseName, @Param("coursePic") String coursePic,
    114. @Param("courseVideo") String courseVideo,@Param("courseDesc") String courseDesc, @Param("coursePrice") BigDecimal coursePrice,
    115. @Param("startTime") String startTime, @Param("endTime") String endTime,
    116. @Param("coueseTypeName") String coueseTypeName, @Param("courseTypeCode") String courseTypeCode,
    117. @Param("userCode") String userCode, @Param("userName") String userName){
    118. CourseMain courseMain = new CourseMain();
    119. courseMain.setCourseName(courseName);
    120. courseMain.setCoursePic(coursePic);
    121. courseMain.setCourseVideo(courseVideo);
    122. courseMain.setCourseDesc(courseDesc);
    123. courseMain.setCoursePrice(coursePrice);
    124. courseMain.setCourseName(courseName);
    125. if(startTime !=null){
    126. courseMain.setStartTime(changeData(startTime, DATA_DAY));
    127. }
    128. if(endTime !=null){
    129. courseMain.setEndTime(changeData(endTime, DATA_DAY));
    130. }
    131. courseMain.setCoueseTypeName(coueseTypeName);
    132. courseMain.setCourseTypeCode(courseTypeCode);
    133. courseMain.setUserCode(userCode);
    134. courseMain.setUserName(userName);
    135. int addCourse = apiService.addCourse(courseMain);
    136. if(addCourse == -1){
    137. return Result.error(new CodeMsg(500,"插入失败"));
    138. }
    139. return Result.success("操作成功!");
    140. }
    141. @RequestMapping(path = "/course/editCourse")
    142. @ApiOperation("修改课程,必须带courseCode,只修改参数不为空的,状态status:'0未开课,1正在开课,2结束,3下架(教练离职)")
    143. @ResponseBody
    144. public Result editCourse(@Param("courseName") String courseName, @Param("courseCode") String courseCode,
    145. @Param("coursePic") String coursePic,@Param("courseVideo") String courseVideo,
    146. @Param("coursePrice") BigDecimal coursePrice,
    147. @Param("startTime") String startTime, @Param("endTime") String endTime,
    148. @Param("coueseTypeName") String coueseTypeName, @Param("courseTypeCode") String courseTypeCode,
    149. @Param("status") String status,
    150. @Param("userCode") String userCode, @Param("userName") String userName){
    151. CourseMain courseMain = new CourseMain();
    152. if(startTime !=null && !"''".equals(startTime)){
    153. courseMain.setStartTime(changeData(startTime, DATA_DAY));
    154. }
    155. if(endTime !=null&& !"''".equals(endTime)){
    156. courseMain.setEndTime(changeData(endTime, DATA_DAY));
    157. }
    158. courseMain.setCourseName(courseName);
    159. courseMain.setCourseCode(courseCode);
    160. courseMain.setCoursePic(coursePic);
    161. courseMain.setCourseVideo(courseVideo);
    162. courseMain.setCoursePrice(coursePrice);
    163. courseMain.setStatus(status);
    164. courseMain.setCoueseTypeName(coueseTypeName);
    165. courseMain.setCourseTypeCode(courseTypeCode);
    166. courseMain.setUserCode(userCode);
    167. courseMain.setUserName(userName);
    168. int editCourse = apiService.editCourse(courseMain);
    169. if(editCourse == -1){
    170. return Result.error(new CodeMsg(500,"更新失败"));
    171. }
    172. return Result.success("操作成功!");
    173. }
    174. @RequestMapping(path = "/course/openOrEndCourse")
    175. @ApiOperation("教练课程开课或下课,必须带courseCode和状态status:'0未开课,1正在开课,2结束,3下架(教练离职) ")
    176. @ResponseBody
    177. public Result openOrEndCourse( @Param("courseCode") String courseCode,@Param("status") String status){
    178. int editCourse = apiService.openOrEndCourse(courseCode,status);
    179. if(editCourse == -1){
    180. return Result.error(new CodeMsg(500,"操作失败"));
    181. }
    182. return Result.success("操作成功!");
    183. }
    184. @RequestMapping(path = "/course/applyEnd")
    185. @ApiOperation("教练课程申请下架,必须带courseCode")
    186. @ResponseBody
    187. public Result applyEnd( @Param("courseCode") String courseCode){
    188. int editCourse = apiService.applyEnd(courseCode);
    189. if(editCourse == -1){
    190. return Result.error(new CodeMsg(500,"操作失败"));
    191. }
    192. return Result.success("操作成功!");
    193. }
    194. @RequestMapping(path = "/course/courseCommend")
    195. @ApiOperation("学生课程评价,必须带用户userCode,课程courseCode,评价courseComment")
    196. @ResponseBody
    197. public Result courseCommend( @Param("userCode") String userCode,
    198. @Param("courseCode") String courseCode,
    199. @Param("courseComment") String courseComment){
    200. int commend = apiService.courseCommend(userCode, courseCode, courseComment);
    201. if(commend == -1){
    202. return Result.error(new CodeMsg(500,"参数不能为空"));
    203. }else if(commend == -0){
    204. return Result.error(new CodeMsg(500,"该学生没有此课程,不能评价!"));
    205. }
    206. return Result.success("操作成功!");
    207. }
    208. @RequestMapping(path = "/course/addClickNum")
    209. @ApiOperation("添加点击人数,必须带参数")
    210. @ResponseBody
    211. public Result addClickNum(@Param("courseCode") String courseCode){
    212. int clickNum = apiService.addClickNum(courseCode);
    213. if(clickNum == -1){
    214. return Result.error(new CodeMsg(500,"操作失败"));
    215. }
    216. return Result.success("操作成功");
    217. }
    218. @RequestMapping(path = "/course/queryCourseTypes")
    219. @ApiOperation("查看课程分类")
    220. @ResponseBody
    221. public Result queryCourseTypes(){
    222. List courseTypes = apiService.queryCourseTypes();
    223. return Result.success(courseTypes);
    224. }
    225. @RequestMapping(path = "/course/queryCourseTypeByCode")
    226. @ApiOperation("查看某一课程分类信息,必须带参数")
    227. @ResponseBody
    228. public Result queryCourseTypeByCode(@Param("typeCode") String typeCode){
    229. CourseType courseType = apiService.queryCourseTypeByCode(typeCode);
    230. return Result.success(courseType);
    231. }
    232. @RequestMapping(path = "/course/queryPackages")
    233. @ApiOperation("查询课程全部小节,必须带参数")
    234. @ResponseBody
    235. public Result queryPackages(@Param("courseCode") String courseCode){
    236. List coursePackages = apiService.queryPackages(courseCode);
    237. return Result.success(coursePackages);
    238. }
    239. @RequestMapping(path = "/course/queryNearPackages")
    240. @ApiOperation("查询教练近期课程小节,必须带参数")
    241. @ResponseBody
    242. public String queryNearPackages(@Param("userCode") String userCode,@RequestParam(required=false,defaultValue="1") int page,
    243. @RequestParam(required=false,defaultValue="10") int limit){
    244. Page page1 = PageHelper.startPage(page, limit);
    245. List coursePackages = apiService.queryNearPackages(userCode);
    246. PageInfo pageInfo = new PageInfo(coursePackages,limit);
    247. pageInfo.setPages(page1.getPages());//总页数
    248. pageInfo.setTotal(page1.getTotal());//总条数
    249. Map map = new HashMap();
    250. map.put("code","200");
    251. map.put("msg", "操作成功!");
    252. map.put("maxPage",pageInfo.getPages());
    253. map.put("data",pageInfo.getList());
    254. String json= JSON.toJSONString(map);
    255. //将map转换为json格式
    256. return json;
    257. }
    258. @RequestMapping(path = "/course/queryPackage")
    259. @ApiOperation("查询具体小节的信息,必须带参数")
    260. @ResponseBody
    261. public Result queryPackage(@Param("packageCode") String packageCode){
    262. CoursePackage coursePackage = apiService.queryPackage(packageCode);
    263. return Result.success(coursePackage);
    264. }
    265. @RequestMapping(path = "/course/addPackage")
    266. @ApiOperation("添加小节,必须带参数")
    267. @ResponseBody
    268. public Result addPackage(@Param("packageNum") String packageNum,@Param("packageName") String packageName,
    269. @Param("timeLong") String timeLong,@Param("startTime") String startTime,
    270. @Param("endTime") String endTime, @Param("courseCode") String courseCode){
    271. CoursePackage coursePackage = new CoursePackage();
    272. coursePackage.setPackageName(packageName);
    273. coursePackage.setPackageNum(packageNum);
    274. coursePackage.setTimeLong(timeLong);
    275. coursePackage.setCourseCode(courseCode);
    276. if(startTime !=null){
    277. coursePackage.setStartTime(changeData(startTime, DATA_HM));
    278. }
    279. if(endTime !=null){
    280. coursePackage.setEndTime(changeData(endTime, DATA_HM));
    281. }
    282. int i = apiService.addPackage(coursePackage);
    283. if(i == -1){
    284. return Result.error(new CodeMsg(500,"操作失败"));
    285. }
    286. return Result.success("操作成功");
    287. }
    288. @RequestMapping(path = "/course/editPackage")
    289. @ApiOperation("修改小节,必须带packageCode参数,其他参数带则修改")
    290. @ResponseBody
    291. public Result editPackage(@Param("packageNum") String packageNum,@Param("packageName") String packageName,
    292. @Param("timeLong") String timeLong,@Param("startTime") String startTime,
    293. @Param("endTime") String endTime, @Param("courseCode") String courseCode,
    294. @Param("packageCode") String packageCode,@Param("status") String status){
    295. CoursePackage coursePackage = new CoursePackage();
    296. coursePackage.setPackageName(packageName);
    297. coursePackage.setPackageNum(packageNum);
    298. coursePackage.setTimeLong(timeLong);
    299. if(startTime !=null && !"''".equals(startTime)){
    300. coursePackage.setStartTime(changeData(startTime, DATA_HM));
    301. }
    302. if(endTime !=null && !"''".equals(endTime)){
    303. coursePackage.setEndTime(changeData(endTime, DATA_HM));
    304. }
    305. coursePackage.setCourseCode(courseCode);
    306. coursePackage.setStatus(status);
    307. int i = apiService.editPackage(coursePackage);
    308. if(i == -1){
    309. return Result.error(new CodeMsg(500,"操作失败"));
    310. }
    311. return Result.success("操作成功");
    312. }
    313. //detail
    314. @RequestMapping(path = "/course/openOrEndPackage")
    315. @ApiOperation("教练小节开课或下课,必须带packageCode和状态status:'0未解锁,1正在进行已解锁,2已完成")
    316. @ResponseBody
    317. public Result openOrEndPackage( @Param("packageCode") String packageCode,@Param("status") String status){
    318. int editPackage = apiService.openOrEndPackage(packageCode,status);
    319. if(editPackage == -1){
    320. return Result.error(new CodeMsg(500,"操作失败"));
    321. }
    322. return Result.success("操作成功!");
    323. }
    324. @RequestMapping(path = "/course/delPackage")
    325. @ApiOperation("教练删除小节,必须带packageCode")
    326. @ResponseBody
    327. public Result delPackage( @Param("packageCode") String packageCode){
    328. int delPackage = apiService.delPackage(packageCode);
    329. if(delPackage == -1){
    330. return Result.error(new CodeMsg(500,"操作失败"));
    331. }
    332. return Result.success("操作成功!");
    333. }
    334. @RequestMapping(path = "/course/queryShopChart")
    335. @ApiOperation("查看购物车,必须带参数")
    336. @ResponseBody
    337. public String queryShopChart(@Param("userCode") String userCode,
    338. @RequestParam(required=false,defaultValue="1") int page,
    339. @RequestParam(required=false,defaultValue="10") int limit){
    340. PageHelper.startPage(page, limit);
    341. List shopCarts = apiService.queryShopChart(userCode);
    342. PageInfo pageInfo = new PageInfo(shopCarts,limit);
    343. Map map = new HashMap();
    344. map.put("code","200");
    345. map.put("msg", "操作成功!");
    346. map.put("maxPage",pageInfo.getPages());
    347. map.put("data",pageInfo.getList());
    348. String json= JSON.toJSONString(map);
    349. //将map转换为json格式
    350. return json;
    351. }
    352. @RequestMapping(path = "/course/addShopChart")
    353. @ApiOperation("添加购物车,必须带参数")
    354. @ResponseBody
    355. public Result addShopChart(@Param("userCode") String userCode,@Param("courseName") String courseName,
    356. @Param("courseCode") String courseCode){
    357. ShopCart shopCart = new ShopCart();
    358. shopCart.setCourseName(courseName);
    359. shopCart.setCourseCode(courseCode);
    360. shopCart.setUserCode(userCode);
    361. int i = apiService.addShopChart(shopCart);
    362. if(i == -1){
    363. return Result.error(new CodeMsg(500,"操作失败"));
    364. }
    365. return Result.success("操作成功");
    366. }
    367. @RequestMapping(path = "/course/editShopChart")
    368. @ApiOperation("批量删除购物车,必须带数组ids")
    369. @ResponseBody
    370. public Result delShopChart(Integer[] ids){
    371. int i = apiService.delShopChart(ids);
    372. if(i == -1){
    373. return Result.error(new CodeMsg(500,"操作失败"));
    374. }
    375. return Result.success("操作成功");
    376. }
    377. @RequestMapping(path = "/course/createOrderByShopChartIds")
    378. @ApiOperation("通过购物车创建订单,必须带购物车的数组ids")
    379. @ResponseBody
    380. public Result createOrderByShopChartIds(Integer[] ids){
    381. Map order = apiService.createOrderByShopChartIds(ids);
    382. if(order == null || order.size() == 0){
    383. return Result.error(new CodeMsg(500,"操作失败"));
    384. }
    385. return Result.success(order);
    386. }
    387. @RequestMapping(path = "/course/payOrder")
    388. @ApiOperation("支付或者取消订单,必须带参数orderCode和status,其中状态:-1,已取消,0未付款,1已付款,")
    389. @ResponseBody
    390. public Result payOrder(String orderCode,String status){
    391. int i = apiService.payOrder(orderCode, status);
    392. if(i == -1){
    393. return Result.error(new CodeMsg(500,"操作失败"));
    394. }
    395. return Result.success("操作成功!");
    396. }
    397. @RequestMapping(path = "/course/queryShopOrders")
    398. @ApiOperation("查看个人所有订单,必须带参数userCode")
    399. @ResponseBody
    400. public String queryShopOrders(String userCode,
    401. @RequestParam(required=false,defaultValue="1") int page,
    402. @RequestParam(required=false,defaultValue="10") int limit){
    403. Page page1 = PageHelper.startPage(page, limit);
    404. List> maps = apiService.queryShopOrders(userCode);
    405. PageInfo pageInfo = new PageInfo(maps,limit);
    406. pageInfo.setPages(page1.getPages());//总页数
    407. pageInfo.setTotal(page1.getTotal());//总条数
    408. Map map = new HashMap();
    409. map.put("code","200");
    410. map.put("msg", "操作成功!");
    411. map.put("maxPage",pageInfo.getPages());
    412. map.put("data",pageInfo.getList());
    413. String json= JSON.toJSONString(map);
    414. //将map转换为json格式
    415. return json;
    416. }
    417. @RequestMapping(path = "/course/queryUserCourse")
    418. @ApiOperation("查看学员个人课程,必须带参数userCode")
    419. @ResponseBody
    420. public String queryUserCourse(String userCode,
    421. @RequestParam(required=false,defaultValue="1") int page,
    422. @RequestParam(required=false,defaultValue="10") int limit){
    423. PageHelper.startPage(page, limit);
    424. List courseMains = apiService.queryUserCourse(userCode);
    425. PageInfo pageInfo = new PageInfo(courseMains,limit);
    426. Map map = new HashMap();
    427. map.put("code","200");
    428. map.put("msg", "操作成功!");
    429. map.put("maxPage",pageInfo.getPages());
    430. map.put("data",pageInfo.getList());
    431. String json= JSON.toJSONString(map);
    432. //将map转换为json格式
    433. return json;
    434. }
    435. @RequestMapping(path = "/course/putCard")
    436. @ApiOperation("学员小节打卡,必须带参数packageCode和userCode")
    437. @ResponseBody
    438. public Result putCard(String packageCode,String userCode){
    439. int i = apiService.putCard(packageCode, userCode);
    440. if(i == -1){
    441. return Result.error(new CodeMsg(500,"操作失败"));
    442. }
    443. return Result.success("操作成功!");
    444. }
    445. @RequestMapping(path = "/course/queryUserInfo")
    446. @ApiOperation("查看个人信息,必须带参数userCode")
    447. @ResponseBody
    448. public Result queryUserInfo(String userCode){
    449. User user = apiService.queryUserInfo(userCode);
    450. if(user == null){
    451. return Result.error(new CodeMsg(500,"个人信息为空!"));
    452. }
    453. return Result.success(user);
    454. }
    455. @RequestMapping(path = "/course/querySalarys")
    456. @ApiOperation("查看个人工资,必须带参数userCode")
    457. @ResponseBody
    458. public Result querySalarys(String userCode){
    459. List salaryMonths = apiService.querySalarys(userCode);
    460. return Result.success(salaryMonths);
    461. }
    462. @RequestMapping(path = "/course/queryLeaveMains")
    463. @ApiOperation("查看教练请假列表,必须带参数")
    464. @ResponseBody
    465. public String queryLeaveMains(String userCode,
    466. @RequestParam(required=false,defaultValue="1") int page,
    467. @RequestParam(required=false,defaultValue="10") int limit){
    468. PageHelper.startPage(page, limit);
    469. List leaveMains = apiService.queryLeaveMains(userCode);
    470. PageInfo pageInfo = new PageInfo(leaveMains,limit);
    471. Map map = new HashMap();
    472. map.put("code","200");
    473. map.put("msg", "操作成功!");
    474. map.put("maxPage",pageInfo.getPages());
    475. map.put("data",pageInfo.getList());
    476. String json= JSON.toJSONString(map);
    477. //将map转换为json格式
    478. return json;
    479. }
    480. @RequestMapping(path = "/course/addLeaveMain")
    481. @ApiOperation("教练请假,必须带参数")
    482. @ResponseBody
    483. public Result addLeaveMain(String packageCode,String packageAdjustStartTime,String packageAdjustEndTime,
    484. String startUserName,String startUserCode){
    485. LeaveMain leaveMain = new LeaveMain();
    486. if(packageAdjustStartTime !=null){
    487. leaveMain.setPackageAdjustStartTime(changeData(packageAdjustStartTime, DATA_HM));
    488. }
    489. if(packageAdjustEndTime !=null){
    490. leaveMain.setPackageAdjustEndTime(changeData(packageAdjustEndTime, DATA_HM));
    491. }
    492. leaveMain.setPackageCode(packageCode);
    493. leaveMain.setStartUserName(startUserName);
    494. leaveMain.setStartUserCode(startUserCode);
    495. int i = apiService.addLeaveMain(leaveMain);
    496. if(i == -1){
    497. return Result.error(new CodeMsg(500,"操作失败,参数异常!"));
    498. }else if(i == -2){
    499. return Result.error(new CodeMsg(500,"课程已开始,不能请假!"));
    500. }
    501. return Result.success("操作成功!");
    502. }
    503. @RequestMapping(path = "/course/cancelLeaveMain")
    504. @ApiOperation("教练撤销请假,必须带小节的code参数")
    505. @ResponseBody
    506. public Result cancelLeaveMain(String packageCode){
    507. int i = apiService.cancelLeaveMain(packageCode);
    508. if(i == -1){
    509. return Result.error(new CodeMsg(500,"操作失败"));
    510. }
    511. return Result.success("操作成功!");
    512. }
    513. @RequestMapping(path = "/course/querySiteMsgs")
    514. @ApiOperation("查询站内消息,必须带接收人code参数")
    515. @ResponseBody
    516. public String querySiteMsgs(String acceptCode,
    517. @RequestParam(required=false,defaultValue="1") int page,
    518. @RequestParam(required=false,defaultValue="10") int limit){
    519. PageHelper.startPage(page, limit);
    520. List siteMsgs = apiService.querySiteMsgs(acceptCode);
    521. PageInfo pageInfo = new PageInfo(siteMsgs,limit);
    522. Map map = new HashMap();
    523. map.put("code","200");
    524. map.put("msg", "操作成功!");
    525. map.put("maxPage",pageInfo.getPages());
    526. map.put("data",pageInfo.getList());
    527. String json= JSON.toJSONString(map);
    528. //将map转换为json格式
    529. return json;
    530. }
    531. @RequestMapping(path = "/course/querySiteMsgNum")
    532. @ApiOperation("查询站内消息数量,必须带接收人code参数")
    533. @ResponseBody
    534. public Result querySiteMsgNum(String acceptCode){
    535. List siteMsgs = apiService.querySiteMsgs(acceptCode);
    536. int msgNum = 0;
    537. if(siteMsgs!=null &&siteMsgs.size() > 0){
    538. List collect = siteMsgs.stream().filter(siteMsg -> siteMsg.getIsRead() != null && "0".equals(siteMsg.getIsRead())).collect(Collectors.toList());
    539. msgNum = collect == null ? 0: collect.size();
    540. }
    541. Map map = new HashMap();
    542. map.put("msgNum",msgNum);
    543. return Result.success(map);
    544. }
    545. @RequestMapping(path = "/course/readSiteMsg")
    546. @ApiOperation("站内消息变为已读,必须带消息id")
    547. @ResponseBody
    548. public Result readSiteMsg(Integer id){
    549. int i = apiService.readSiteMsg(id);
    550. if(i == -1){
    551. return Result.error(new CodeMsg(500,"操作失败"));
    552. }
    553. return Result.success("操作成功!");
    554. }
    555. }
    556.  

      1. package cn.com.itcast.sport.controller;
      2. import cn.com.itcast.sport.entry.*;
      3. import cn.com.itcast.sport.service.UserService;
      4. import com.alibaba.fastjson.JSON;
      5. import com.github.pagehelper.PageHelper;
      6. import com.github.pagehelper.PageInfo;
      7. import org.springframework.beans.factory.annotation.Autowired;
      8. import org.springframework.stereotype.Controller;
      9. import org.springframework.ui.Model;
      10. import org.springframework.web.bind.annotation.RequestMapping;
      11. import org.springframework.web.bind.annotation.RequestParam;
      12. import org.springframework.web.bind.annotation.ResponseBody;
      13. import javax.servlet.http.HttpSession;
      14. import java.util.HashMap;
      15. import java.util.List;
      16. import java.util.Map;
      17. @Controller
      18. public class UserController {
      19. @Autowired
      20. private UserService userService;
      21. /*学员管理*/
      22. @RequestMapping("/student/init")
      23. public String studentInit() {
      24. return "web/user-manage/studentManage";
      25. }
      26. @RequestMapping("/student/findAll")
      27. @ResponseBody
      28. public String studentManage(String name, @RequestParam(required=false,defaultValue="1") int page,
      29. @RequestParam(required=false,defaultValue="10") int limit) {
      30. //分页初始化
      31. PageHelper.startPage(page, limit);
      32. List<User> users = userService.findUsers(name,"0");
      33. //用PageInfo对结果进行包装,传入连续显示的页数
      34. PageInfo pageInfo = new PageInfo(users,limit);
      35. Map<String,Object> map = new HashMap<String, Object>();
      36. map.put("code","0");
      37. map.put("msg", "");
      38. map.put("count",pageInfo.getTotal());
      39. map.put("data",pageInfo.getList());
      40. String json= JSON.toJSONString(map);
      41. //将map转换为json格式
      42. // return JsonConversion.writeMapJSON(map);
      43. return json;
      44. }
      45. /*教师管理*/
      46. @RequestMapping("/teacher/init")
      47. public String teacherInit() {
      48. return "web/user-manage/teacherManage";
      49. }
      50. @RequestMapping("/teacher/findAll")
      51. @ResponseBody
      52. public String teacherManage(String name, @RequestParam(required=false,defaultValue="1") int page,
      53. @RequestParam(required=false,defaultValue="10") int limit) {
      54. PageHelper.startPage(page, limit);
      55. List<User> users = userService.findUsers(name,"1");
      56. //用PageInfo对结果进行包装,传入连续显示的页数
      57. PageInfo pageInfo = new PageInfo(users,limit);
      58. String msg = null;
      59. Map<String,Object> map = new HashMap<String, Object>();
      60. map.put("code","0");
      61. map.put("msg", msg);
      62. map.put("count",pageInfo.getTotal());
      63. map.put("data",pageInfo.getList());
      64. String json= JSON.toJSONString(map);
      65. //将map转换为json格式
      66. // return JsonConversion.writeMapJSON(map);
      67. return json;
      68. }
      69. /*添加教练,学员*/
      70. @RequestMapping("/user/addInit")
      71. public String userAddInit(Model model ,String type) {
      72. model.addAttribute("type",type);
      73. return "web/user-manage/addUser";
      74. }
      75. @RequestMapping("/user/addUser")
      76. @ResponseBody
      77. public Result addUser(User user){
      78. CodeMsg codeMsg = userService.addUser(user);
      79. Result<CodeMsg> success = Result.success(codeMsg);
      80. return success;
      81. }
      82. @RequestMapping("/user/editInit")
      83. public String
      84. userEditInit(Model model ,Integer id){
      85. User user = userService.findUserById(id);
      86. model.addAttribute("user",user);
      87. return "web/user-manage/editUser";
      88. }
      89. @RequestMapping("/user/editUser")
      90. @ResponseBody
      91. public Result editUser(User user){
      92. CodeMsg codeMsg = userService.editUser(user);
      93. Result<CodeMsg> success = Result.success(codeMsg);
      94. return success;
      95. }
      96. /*账号管理*/
      97. @RequestMapping("/account/init")
      98. public String accountInit(Model model, HttpSession httpSession) {
      99. return "web/user-manage/accountManage";
      100. }
      101. @RequestMapping("/account/findAll")
      102. @ResponseBody
      103. public String accountManage(String userName, @RequestParam(required=false,defaultValue="1") int page,
      104. @RequestParam(required=false,defaultValue="10") int limit) {
      105. PageHelper.startPage(page, limit);
      106. List<UserAndAccountAndRole> allUserInfo = userService.findAllUserInfo(userName);
      107. //用PageInfo对结果进行包装,传入连续显示的页数
      108. PageInfo pageInfo = new PageInfo(allUserInfo,limit);
      109. Map<String,Object> map = new HashMap<String, Object>();
      110. map.put("code","0");
      111. map.put("msg", "");
      112. map.put("count",pageInfo.getTotal());
      113. map.put("data",pageInfo.getList());
      114. String json= JSON.toJSONString(map);
      115. //将map转换为json格式
      116. // return JsonConversion.writeMapJSON(map);
      117. return json;
      118. }
      119. /*添加账号*/
      120. @RequestMapping("/account/addInit")
      121. public String accountAddInit(Model model) {
      122. List<User> users = userService.findHasNoAccountUsers();
      123. List<Role> roles = userService.findRoles(null);
      124. List<Account> accounts = userService.findAccounts(null);
      125. model.addAttribute("users",users);
      126. model.addAttribute("roles",roles);
      127. return "web/user-manage/addAccount";
      128. }
      129. @RequestMapping("/account/addAccount")
      130. @ResponseBody
      131. public Result addAccount(Account account){
      132. CodeMsg codeMsg = userService.addAccounts(account);
      133. Result<CodeMsg> success = Result.success(codeMsg);
      134. return success;
      135. }
      136. /*修改账号*/
      137. @RequestMapping("/account/editInit")
      138. public String accountEditInit(Model model,Integer id) {
      139. Account account = userService.findAccountById(id);
      140. List<Role> roles = userService.findRoles(null);
      141. model.addAttribute("account",account);
      142. model.addAttribute("roles",roles);
      143. return "web/user-manage/editAccount";
      144. }
      145. @RequestMapping("/account/editAccount")
      146. @ResponseBody
      147. public Result editAccount(Account account){
      148. CodeMsg codeMsg = userService.editAccount(account);
      149. Result<CodeMsg> success = Result.success(codeMsg);
      150. return success;
      151. }
      152. @RequestMapping("/role/findAll")
      153. @ResponseBody
      154. public String roleManage(String roleName, @RequestParam(required=false,defaultValue="1") int page,
      155. @RequestParam(required=false,defaultValue="10") int limit) {
      156. PageHelper.startPage(page, limit);
      157. List<Role> roles = userService.findRoles(roleName);
      158. //用PageInfo对结果进行包装,传入连续显示的页数
      159. PageInfo pageInfo = new PageInfo(roles,limit);
      160. Map<String,Object> map = new HashMap<String, Object>();
      161. map.put("code","0");
      162. map.put("msg", "");
      163. map.put("count",pageInfo.getTotal());
      164. map.put("data",pageInfo.getList());
      165. String json= JSON.toJSONString(map);
      166. //将map转换为json格式
      167. // return JsonConversion.writeMapJSON(map);
      168. return json;
      169. }
      170. /*添加账号*/
      171. @RequestMapping("/role/addInit")
      172. public String roleAddInit(Model model) {
      173. return "web/user-manage/addRole";
      174. }
      175. @RequestMapping("/role/addRole")
      176. @ResponseBody
      177. public Result addRole(Role role){
      178. CodeMsg codeMsg = userService.addRole(role);
      179. Result<CodeMsg> success = Result.success(codeMsg);
      180. return success;
      181. }
      182. @RequestMapping("/role/editInit")
      183. public String editRoleInit(Model model,Integer id){
      184. Role role = userService.findRoleById(id);
      185. model.addAttribute("role",role);
      186. return "web/user-manage/editRole";
      187. }
      188. @RequestMapping("/role/editRole")
      189. @ResponseBody
      190. public Result editRole(Role role){
      191. CodeMsg codeMsg = userService.editRole(role);
      192. Result<CodeMsg> success = Result.success(codeMsg);
      193. return success;
      194. }
      195. /*更改密码页面*/
      196. @RequestMapping("/editAccountPwd")
      197. public String editAccountPwd(Model model, HttpSession httpSession){
      198. Account account = userService.findUserInfo(httpSession);
      199. model.addAttribute("account",account);
      200. return "web/login/editAccountPwd";
      201. }
      202. /*更改密码*/
      203. @RequestMapping("/submitAccountPwd")
      204. @ResponseBody
      205. public Result submitAccountPwd(EditAccountPwd editAccount){
      206. CodeMsg codeMsg = userService.editAccountPwd(editAccount);
      207. Result<CodeMsg> success = Result.success(codeMsg);
      208. return success;
      209. }
      210. }

    557. 相关阅读:
      Java开发多年写过的BUG都在这了!!!(2022.8更新)
      Qt中的信号和槽详解
      django添加数据库字段进行数据迁移
      Unity UGUI的PointerEventData的介绍及使用
      [java刷算法]牛客—剑指offer链表有环的入口、反转链表、合并排序链表
      驱动开发:内核无痕隐藏自身分析
      ThinkCentre台式机windows重装为linux找不到硬盘
      搭建自己的pypi服务器
      Kotlin源码编译报错,提示@UnsupportedAppUsage和@SystemApi声明的Java函数无法调用
      【Linux】Linux+Nginx部署项目(负载均衡&动静分离)
    558. 原文地址:https://blog.csdn.net/weixin_46437112/article/details/127952472