作者 王兆博

我的学校

... ... @@ -70,13 +70,11 @@ public class MineController {
}
@ApiImplicitParam(name = "type",value = "学校类型",dataType = "Integer",required = true,paramType = "query")
@ApiOperation("打开我的学校")
@ApiOperation("我的学校")
@PostMapping("/openmyschool")
public AjaxResult openMySchool(Integer type){
public AjaxResult openMySchool(){
log.info("<<<接收的参数<<<::"+type);
return mineService.openMySchool(type);
return mineService.openMySchool();
}
// TODO: 2021/9/15
... ...
... ... @@ -3,6 +3,10 @@ package com.example.client.mapper;
import cn.bronet.admin.common.core.mybatisplus.core.BaseMapperPlus;
import com.example.client.domain.CRegisterSchool;
import com.example.client.domain.bo.CRelationshipStudentSgcBo;
import com.example.client.domain.vo.MySchoolVo;
import java.util.List;
/**
* 学校身份信息Mapper接口
... ... @@ -11,5 +15,17 @@ import com.example.client.domain.CRegisterSchool;
* @date 2021-09-09
*/
public interface CRegisterSchoolMapper extends BaseMapperPlus<CRegisterSchool> {
/**
* 学校获取我的学校
* @param bo
* @return
*/
List<MySchoolVo> getSchool(CRelationshipStudentSgcBo bo);
/**
* 老师获取我的学校
* @param bo
* @return
*/
List<MySchoolVo> getSchoolByTeacher(CRelationshipStudentSgcBo bo);
}
... ...
... ... @@ -10,10 +10,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
* Date:2021/9/16
* Time:18:36
*/
@Configuration
//@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/upLoadFiles/**").addResourceLocations("file:D:\\Lampo\\img\\");
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
}
}
... ...
... ... @@ -22,14 +22,14 @@ public class ResourcesConfig implements WebMvcConfigurer {
private RepeatSubmitInterceptor repeatSubmitInterceptor;
*/
/**
/* *//**
* 自定义拦截规则
*/
*//*
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
registry.addResourceHandler("/upLoadFiles/**").addResourceLocations("D:/Lampo/img/");
}
}*/
/**
* 跨域配置
... ...
... ... @@ -74,8 +74,8 @@ public interface MineService {
/**
* 打开我的学校
* @param type
* @param
* @return
*/
AjaxResult openMySchool(Integer type);
AjaxResult openMySchool();
}
... ...
... ... @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.client.domain.*;
import com.example.client.domain.bo.CBasicInformationStudentBo;
import com.example.client.domain.bo.CPersonalInformationBo;
import com.example.client.domain.bo.CRelationshipStudentSgcBo;
import com.example.client.domain.vo.*;
import com.example.client.domin.UserContext;
import com.example.client.mapper.*;
... ... @@ -62,6 +63,9 @@ public class MineServiceImpl implements MineService {
@Autowired
private CRelationshipStudentSgcMapper cRelationshipStudentSgcMapper;
@Autowired
private CRegisterSchoolMapper cRegisterSchoolMapper;
/**
* 打开我的
... ... @@ -646,33 +650,50 @@ public class MineServiceImpl implements MineService {
/**
* 打开我的学校
* @param type
* @param
* @return
*/
@Override
public AjaxResult openMySchool(Integer type) {
public AjaxResult openMySchool() {
//根据登录人Id查询用户信息
Long uId = UserContext.currentUserId();
CUser cUser = cUserMapper.selectById(uId);
//判断 等于3 身份为家长
if (cUser.getIdentityType()==3){
if (cUser.getIdentityType() == 3) {
Long userId = cUser.getAtPresent();
if(userId ==null){
return AjaxResult.error("你还没有绑定孩子");
}
return getMySchool(userId);
//通过当前绑定的学生Id查询
List<MySchoolVo> schoolVos = cRelationshipStudentSgcMapper.getSchool(cUser.getAtPresent(), type);
return AjaxResult.success(schoolVos);
//不等于
}else {
//根据登录人的ID查询
List<MySchoolVo> schoolVos = cRelationshipStudentSgcMapper.getSchool(uId, type);
return AjaxResult.success(schoolVos);
}
//学生
if(cUser.getIdentityType() == 2){
return getMySchool(uId);
}
//老师的
if(cUser.getIdentityType() == 1){
CRelationshipStudentSgcBo cRelationshipStudentSgcBo = new CRelationshipStudentSgcBo();
cRelationshipStudentSgcBo.setUserId(uId);
return AjaxResult.success(cRegisterSchoolMapper.getSchoolByTeacher(cRelationshipStudentSgcBo)) ;
}
return AjaxResult.error("身份不对") ;
}
/**
* 学生查看我的学校
* @param userId
* @return
*/
private AjaxResult getMySchool(Long userId) {
CRelationshipStudentSgcBo cRelationshipStudentSgcBo = new CRelationshipStudentSgcBo();
cRelationshipStudentSgcBo.setUserId(userId);
List<MySchoolVo> school = cRegisterSchoolMapper.getSchool(cRelationshipStudentSgcBo);
return AjaxResult.success(school);
}
}
... ...
... ... @@ -18,4 +18,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<select id="getSchool" parameterType="com.example.client.domain.bo.CRelationshipStudentSgcBo" resultType="com.example.client.domain.vo.MySchoolVo">
SELECT r.start_date,r.end_date,s.school_name FROM c_relationship_student_sgc r
LEFT JOIN c_register_school s on r.school_id = r.school_id
<where>
r.user_id = #{userId}
<if test="gardeType != null">
and r.garde_type = #{gardeType}
</if>
</where>
</select>
<select id="getSchoolByTeacher" parameterType="com.example.client.domain.bo.CRelationshipStudentSgcBo" resultType="com.example.client.domain.vo.MySchoolVo">
SELECT s.school_name FROM c_teacher t
LEFT JOIN c_grade g on t.grade_id = g.id
LEFT JOIN c_register_school s on s.school_id = g.school_id
<where>
t.user_id = #{userId}
<if test="gardeType != null">
and r.garde_type = #{gardeType}
</if>
</where>
</select>
</mapper>
... ...