作者 王兆博

修改我的学校

@@ -3,6 +3,7 @@ package com.example.client.controller; @@ -3,6 +3,7 @@ package com.example.client.controller;
3 import cn.bronet.admin.common.core.domain.AjaxResult; 3 import cn.bronet.admin.common.core.domain.AjaxResult;
4 import com.example.client.domain.bo.CBasicInformationStudentBo; 4 import com.example.client.domain.bo.CBasicInformationStudentBo;
5 import com.example.client.domain.bo.CPersonalInformationBo; 5 import com.example.client.domain.bo.CPersonalInformationBo;
  6 +import com.example.client.domain.bo.MySchoolTypeBO;
6 import com.example.client.service.MineService; 7 import com.example.client.service.MineService;
7 import io.swagger.annotations.Api; 8 import io.swagger.annotations.Api;
8 import io.swagger.annotations.ApiImplicitParam; 9 import io.swagger.annotations.ApiImplicitParam;
@@ -69,12 +70,12 @@ public class MineController { @@ -69,12 +70,12 @@ public class MineController {
69 70
70 } 71 }
71 72
72 - @ApiImplicitParam(name = "type",value = "学校类型",dataType = "Integer",required = true,paramType = "query") 73 +
73 @ApiOperation("我的学校") 74 @ApiOperation("我的学校")
74 @PostMapping("/openmyschool") 75 @PostMapping("/openmyschool")
75 - public AjaxResult openMySchool(){ 76 + public AjaxResult openMySchool(@RequestBody MySchoolTypeBO mySchoolTypeBO){
76 77
77 - return mineService.openMySchool(); 78 + return mineService.openMySchool(mySchoolTypeBO);
78 } 79 }
79 80
80 // TODO: 2021/9/15 81 // TODO: 2021/9/15
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField; @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
5 import com.baomidou.mybatisplus.annotation.TableId; 5 import com.baomidou.mybatisplus.annotation.TableId;
6 import com.baomidou.mybatisplus.annotation.TableName; 6 import com.baomidou.mybatisplus.annotation.TableName;
7 import com.example.client.domain.vo.CTeacherVo; 7 import com.example.client.domain.vo.CTeacherVo;
  8 +import com.example.client.enumeration.SchoolTypeEnumer;
8 import lombok.Data; 9 import lombok.Data;
9 import lombok.NoArgsConstructor; 10 import lombok.NoArgsConstructor;
10 import lombok.experimental.Accessors; 11 import lombok.experimental.Accessors;
@@ -79,6 +80,6 @@ public class CRegisterSchool implements Serializable { @@ -79,6 +80,6 @@ public class CRegisterSchool implements Serializable {
79 /** 80 /**
80 * 学校类型 1-学校 2-培训 3-其他 81 * 学校类型 1-学校 2-培训 3-其他
81 */ 82 */
82 - private Long schoolType; 83 + private SchoolTypeEnumer schoolType;
83 84
84 } 85 }
@@ -2,6 +2,7 @@ package com.example.client.domain.bo; @@ -2,6 +2,7 @@ package com.example.client.domain.bo;
2 2
3 import cn.bronet.admin.common.annotation.Excel; 3 import cn.bronet.admin.common.annotation.Excel;
4 import cn.bronet.admin.common.core.domain.BaseEntity; 4 import cn.bronet.admin.common.core.domain.BaseEntity;
  5 +import com.example.client.enumeration.SchoolTypeEnumer;
5 import io.swagger.annotations.ApiModel; 6 import io.swagger.annotations.ApiModel;
6 import io.swagger.annotations.ApiModelProperty; 7 import io.swagger.annotations.ApiModelProperty;
7 import lombok.Data; 8 import lombok.Data;
@@ -67,7 +68,7 @@ public class CRegisterSchoolBo extends BaseEntity { @@ -67,7 +68,7 @@ public class CRegisterSchoolBo extends BaseEntity {
67 * 学校类型 1-学校 2-培训 3-其他 68 * 学校类型 1-学校 2-培训 3-其他
68 */ 69 */
69 @ApiModelProperty("学校类型 1-学校 2-培训 3-其他") 70 @ApiModelProperty("学校类型 1-学校 2-培训 3-其他")
70 - private Long schoolType; 71 + private SchoolTypeEnumer schoolType;
71 72
72 73
73 /** 74 /**
  1 +package com.example.client.domain.bo;
  2 +
  3 +import com.example.client.enumeration.SchoolTypeEnumer;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +import java.io.Serializable;
  8 +
  9 +/**
  10 + * Created with IDEA
  11 + * author:WangZhaoBo
  12 + * Date:2021/9/17
  13 + * Time:10:13
  14 + */
  15 +@Data
  16 +public class MySchoolTypeBO implements Serializable {
  17 + /**
  18 + * 学校类型 1-学校 2-培训 3-其他
  19 + */
  20 + @ApiModelProperty("学校类型 1-(OTHER-学校) 2(TRAIN-培训) 3(SCHOOL-其他)")
  21 + private SchoolTypeEnumer schoolType;
  22 +}
1 package com.example.client.domain.vo; 1 package com.example.client.domain.vo;
2 2
3 import cn.bronet.admin.common.annotation.Excel; 3 import cn.bronet.admin.common.annotation.Excel;
  4 +import com.example.client.enumeration.SchoolTypeEnumer;
4 import io.swagger.annotations.ApiModel; 5 import io.swagger.annotations.ApiModel;
5 import io.swagger.annotations.ApiModelProperty; 6 import io.swagger.annotations.ApiModelProperty;
6 import lombok.Data; 7 import lombok.Data;
@@ -73,7 +74,7 @@ public class CRegisterSchoolVo { @@ -73,7 +74,7 @@ public class CRegisterSchoolVo {
73 */ 74 */
74 @Excel(name = "学校类型 1-学校 2-培训 3-其他") 75 @Excel(name = "学校类型 1-学校 2-培训 3-其他")
75 @ApiModelProperty("学校类型 1-学校 2-培训 3-其他") 76 @ApiModelProperty("学校类型 1-学校 2-培训 3-其他")
76 - private Long schoolType; 77 + private SchoolTypeEnumer schoolType;
77 78
78 /** 79 /**
79 * 学校的老师 80 * 学校的老师
  1 +package com.example.client.enumeration;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.EnumValue;
  4 +import com.baomidou.mybatisplus.annotation.IEnum;
  5 +import com.fasterxml.jackson.annotation.JsonCreator;
  6 +import com.fasterxml.jackson.annotation.JsonValue;
  7 +
  8 +/**
  9 + * Created with IDEA
  10 + * author:WangZhaoBo
  11 + * Date:2021/9/17
  12 + * Time:9:57
  13 + */
  14 +public enum SchoolTypeEnumer implements IEnum<Integer> {
  15 +
  16 + /**
  17 + * 其他
  18 + */
  19 +
  20 + OTHER(3,"其他"),
  21 + /**
  22 + * 培训
  23 + */
  24 + TRAIN(2,"培训"),
  25 + /**
  26 + * 学校
  27 + */
  28 + SCHOOL(1,"学校") ;
  29 +
  30 +
  31 + private String descp;
  32 +
  33 + @EnumValue
  34 + private int code;
  35 +
  36 + SchoolTypeEnumer(int code, String descp) {
  37 + this.code = code;
  38 + this.descp = descp;
  39 + }
  40 +
  41 +
  42 + @JsonCreator
  43 + public static SchoolTypeEnumer getItem(int code) {
  44 + for (SchoolTypeEnumer item : values()) {
  45 + if (item.getCode() == code) {
  46 + return item;
  47 + }
  48 + }
  49 + return null;
  50 + }
  51 +
  52 +
  53 + @JsonValue
  54 + public Integer getCode() {
  55 + return code;
  56 + }
  57 +
  58 + @Override
  59 + public Integer getValue() {
  60 + return code;
  61 + }
  62 +}
@@ -3,6 +3,7 @@ package com.example.client.service; @@ -3,6 +3,7 @@ package com.example.client.service;
3 import cn.bronet.admin.common.core.domain.AjaxResult; 3 import cn.bronet.admin.common.core.domain.AjaxResult;
4 import com.example.client.domain.bo.CBasicInformationStudentBo; 4 import com.example.client.domain.bo.CBasicInformationStudentBo;
5 import com.example.client.domain.bo.CPersonalInformationBo; 5 import com.example.client.domain.bo.CPersonalInformationBo;
  6 +import com.example.client.domain.bo.MySchoolTypeBO;
6 7
7 /** 8 /**
8 * Created with IDEA 9 * Created with IDEA
@@ -77,7 +78,7 @@ public interface MineService { @@ -77,7 +78,7 @@ public interface MineService {
77 * @param 78 * @param
78 * @return 79 * @return
79 */ 80 */
80 - AjaxResult openMySchool(); 81 + AjaxResult openMySchool(MySchoolTypeBO mySchoolTypeBO);
81 82
82 /** 83 /**
83 * 我的班级 84 * 我的班级
@@ -8,6 +8,7 @@ import com.example.client.domain.bo.CActivityBo; @@ -8,6 +8,7 @@ import com.example.client.domain.bo.CActivityBo;
8 import com.example.client.domain.vo.*; 8 import com.example.client.domain.vo.*;
9 import com.example.client.domin.UserContext; 9 import com.example.client.domin.UserContext;
10 import com.example.client.enumeration.Identity; 10 import com.example.client.enumeration.Identity;
  11 +import com.example.client.enumeration.SchoolTypeEnumer;
11 import com.example.client.mapper.*; 12 import com.example.client.mapper.*;
12 import com.example.client.service.ActivityService; 13 import com.example.client.service.ActivityService;
13 import io.swagger.annotations.ApiImplicitParam; 14 import io.swagger.annotations.ApiImplicitParam;
@@ -104,7 +105,7 @@ public class ActivityServiceImpl extends ServicePlusImpl<CActivityMapper,CActivi @@ -104,7 +105,7 @@ public class ActivityServiceImpl extends ServicePlusImpl<CActivityMapper,CActivi
104 105
105 //从数据库中取出所有的学校 106 //从数据库中取出所有的学校
106 LambdaQueryWrapper<CRegisterSchool> rsWrapper = new LambdaQueryWrapper<>(); 107 LambdaQueryWrapper<CRegisterSchool> rsWrapper = new LambdaQueryWrapper<>();
107 - rsWrapper.eq(CRegisterSchool::getSchoolType,1); 108 + rsWrapper.eq(CRegisterSchool::getSchoolType, SchoolTypeEnumer.SCHOOL);
108 List<CRegisterSchool> registerSchoolList = rsMapper.selectList(rsWrapper); 109 List<CRegisterSchool> registerSchoolList = rsMapper.selectList(rsWrapper);
109 log.info("<<<<<<registerSchoolList::"+registerSchoolList); 110 log.info("<<<<<<registerSchoolList::"+registerSchoolList);
110 111
@@ -18,6 +18,7 @@ import com.example.client.domain.bo.MyAuthentication; @@ -18,6 +18,7 @@ import com.example.client.domain.bo.MyAuthentication;
18 import com.example.client.domain.vo.CUserVo; 18 import com.example.client.domain.vo.CUserVo;
19 import com.example.client.domin.UserContext; 19 import com.example.client.domin.UserContext;
20 import com.example.client.enumeration.Identity; 20 import com.example.client.enumeration.Identity;
  21 +import com.example.client.enumeration.SchoolTypeEnumer;
21 import com.example.client.mapper.*; 22 import com.example.client.mapper.*;
22 import com.example.client.service.FamilyService; 23 import com.example.client.service.FamilyService;
23 import com.example.client.service.UserService; 24 import com.example.client.service.UserService;
@@ -183,7 +184,7 @@ public class CUserServiceImpl extends ServicePlusImpl<CUserMapper, CUser, CUserV @@ -183,7 +184,7 @@ public class CUserServiceImpl extends ServicePlusImpl<CUserMapper, CUser, CUserV
183 //判断是否是学校 184 //判断是否是学校
184 CRegisterSchool cRegisterSchool = cRegisterSchoolMapper.selectById(myAuthentication.getSchoolId()); 185 CRegisterSchool cRegisterSchool = cRegisterSchoolMapper.selectById(myAuthentication.getSchoolId());
185 //学校类型 1-学校 2-培训 3-其他 186 //学校类型 1-学校 2-培训 3-其他
186 - if(cRegisterSchool.getSchoolType() ==1 ) { 187 + if(cRegisterSchool.getSchoolType().equals(SchoolTypeEnumer.OTHER) ) {
187 cUser.setSchoolCurrent(myAuthentication.getSchoolId()); 188 cUser.setSchoolCurrent(myAuthentication.getSchoolId());
188 getBaseMapper().updateById(cUser); 189 getBaseMapper().updateById(cUser);
189 } 190 }
@@ -7,6 +7,7 @@ import com.example.client.domain.*; @@ -7,6 +7,7 @@ import com.example.client.domain.*;
7 import com.example.client.domain.bo.CBasicInformationStudentBo; 7 import com.example.client.domain.bo.CBasicInformationStudentBo;
8 import com.example.client.domain.bo.CPersonalInformationBo; 8 import com.example.client.domain.bo.CPersonalInformationBo;
9 import com.example.client.domain.bo.CRelationshipStudentSgcBo; 9 import com.example.client.domain.bo.CRelationshipStudentSgcBo;
  10 +import com.example.client.domain.bo.MySchoolTypeBO;
10 import com.example.client.domain.vo.*; 11 import com.example.client.domain.vo.*;
11 import com.example.client.domin.UserContext; 12 import com.example.client.domin.UserContext;
12 import com.example.client.enumeration.Identity; 13 import com.example.client.enumeration.Identity;
@@ -657,7 +658,7 @@ public class MineServiceImpl implements MineService { @@ -657,7 +658,7 @@ public class MineServiceImpl implements MineService {
657 * @return 658 * @return
658 */ 659 */
659 @Override 660 @Override
660 - public AjaxResult openMySchool() { 661 + public AjaxResult openMySchool(MySchoolTypeBO mySchoolTypeBO) {
661 662
662 //根据登录人Id查询用户信息 663 //根据登录人Id查询用户信息
663 Long uId = UserContext.currentUserId(); 664 Long uId = UserContext.currentUserId();
@@ -669,13 +670,13 @@ public class MineServiceImpl implements MineService { @@ -669,13 +670,13 @@ public class MineServiceImpl implements MineService {
669 if(userId ==null){ 670 if(userId ==null){
670 return AjaxResult.error("你还没有绑定孩子"); 671 return AjaxResult.error("你还没有绑定孩子");
671 } 672 }
672 - return getMySchool(userId); 673 + return getMySchool(userId ,mySchoolTypeBO );
673 674
674 675
675 } 676 }
676 //学生 677 //学生
677 if(cUser.getIdentityType().equals(Identity.STUDENT)){ 678 if(cUser.getIdentityType().equals(Identity.STUDENT)){
678 - return getMySchool(uId); 679 + return getMySchool(uId,mySchoolTypeBO);
679 } 680 }
680 //老师的 681 //老师的
681 if(cUser.getIdentityType().equals(Identity.TEACHWE)){ 682 if(cUser.getIdentityType().equals(Identity.TEACHWE)){
@@ -716,12 +717,14 @@ public class MineServiceImpl implements MineService { @@ -716,12 +717,14 @@ public class MineServiceImpl implements MineService {
716 * @param userId 717 * @param userId
717 * @return 718 * @return
718 */ 719 */
719 - private AjaxResult getMySchool(Long userId) { 720 + private AjaxResult getMySchool(Long userId ,MySchoolTypeBO mySchoolTypeBO) {
720 CRelationshipStudentSgcBo cRelationshipStudentSgcBo = new CRelationshipStudentSgcBo(); 721 CRelationshipStudentSgcBo cRelationshipStudentSgcBo = new CRelationshipStudentSgcBo();
721 - System.out.println(userId);  
722 722
  723 + cRelationshipStudentSgcBo.setGardeType(mySchoolTypeBO.getSchoolType().getCode());
723 cRelationshipStudentSgcBo.setUserId(userId); 724 cRelationshipStudentSgcBo.setUserId(userId);
724 List<MySchoolVo> school = cRegisterSchoolMapper.getSchool(cRelationshipStudentSgcBo); 725 List<MySchoolVo> school = cRegisterSchoolMapper.getSchool(cRelationshipStudentSgcBo);
  726 +
  727 +
725 return AjaxResult.success(school); 728 return AjaxResult.success(school);
726 } 729 }
727 } 730 }
@@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
25 r.user_id = #{userId} 25 r.user_id = #{userId}
26 26
27 <if test="gardeType != null"> 27 <if test="gardeType != null">
28 - and r.garde_type = #{gardeType} 28 + and s.school_type = #{gardeType}
29 </if> 29 </if>
30 30
31 </where> 31 </where>