diff --git a/src/main/java/com/subsidy/common/Code.java b/src/main/java/com/subsidy/common/Code.java new file mode 100644 index 0000000..91afe9e --- /dev/null +++ b/src/main/java/com/subsidy/common/Code.java @@ -0,0 +1,45 @@ +package com.subsidy.common; + +public enum Code { + + USERNAMENOTFOUND(10001, "用户不存在"), + BADCREDENTIALS(10002,"账户或者密码错误"), + ACCOUNTEXPIRED(10003,"账户过期"), + LOCKEDEXCEPTION(10004, "账户已锁定"), + DISABLEDEXCEPTION(10005,"账户已禁用"), + ACCESSDENIED(10006,"无权限访问"), + AUTHENTICATION(10007,"身份验证异常"), + NOHANDLERFOUND(10008,"找不到相应的视图处理器"), + PARAM_INVALID(10009, "参数不合法"), + TOKEN_EXCEPTION(10010, "Token不合法"), + TOKEN_EXPIRED(10011, "Token已过期"), + OSS_ERROR(10012, "OSS文件上传异常"), + Network_ERROR(90000, "网络请求失败"), + SERVER_INTERNAL_ERROR(99999, "服务器内部错误"), + ; + + private Integer code; + + private String message; + + Code(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/src/main/java/com/subsidy/common/configure/WebConfig.java b/src/main/java/com/subsidy/common/configure/WebConfig.java index ecb8f03..dc0d39f 100644 --- a/src/main/java/com/subsidy/common/configure/WebConfig.java +++ b/src/main/java/com/subsidy/common/configure/WebConfig.java @@ -27,13 +27,15 @@ public class WebConfig implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") // .allowCredentials(true) - .allowedOrigins("*") - .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") - .maxAge(3600); + .allowedOrigins("*") + .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .maxAge(3600); } /** * Swagger + * * @param registry */ @Override @@ -47,6 +49,7 @@ public class WebConfig implements WebMvcConfigurer { /** * 鉴权 + * * @param registry */ @Override @@ -57,5 +60,4 @@ public class WebConfig implements WebMvcConfigurer { } - } \ No newline at end of file diff --git a/src/main/java/com/subsidy/controller/CompanyDictController.java b/src/main/java/com/subsidy/controller/CompanyDictController.java index 61badba..49e7a97 100644 --- a/src/main/java/com/subsidy/controller/CompanyDictController.java +++ b/src/main/java/com/subsidy/controller/CompanyDictController.java @@ -36,7 +36,7 @@ public class CompanyDictController { private CompanyDictService companyDictService; @PostMapping("/administers") - @ApiOperation("查询所有企业 { companyName pageNum pageSize }") + @ApiOperation("查询所有企业 {id companyName pageNum pageSize }") @LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE}) public ResponseVO operators(@RequestBody OperatorsDTO operatorsDTO){ return ResponseData.generateCreatedResponse(0,companyDictService.operators(operatorsDTO)); diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java index 71f8e93..27d591f 100644 --- a/src/main/java/com/subsidy/controller/MemberController.java +++ b/src/main/java/com/subsidy/controller/MemberController.java @@ -108,7 +108,7 @@ public class MemberController { } @PostMapping("getCourseTest") - @ApiOperation("获取课程下的测试情况 {memberId courseId}") + @ApiOperation("获取课程下的测试情况 {memberId 成员id courseId 课程id classId}") public ResponseVO getCourseTest(@RequestBody ContentMemberDTO contentMemberDTO){ return ResponseData.generateCreatedResponse(0,memberService.getCourseTest(contentMemberDTO)); } diff --git a/src/main/java/com/subsidy/controller/SignInRecordController.java b/src/main/java/com/subsidy/controller/SignInRecordController.java index e9bdad9..0ac45fd 100644 --- a/src/main/java/com/subsidy/controller/SignInRecordController.java +++ b/src/main/java/com/subsidy/controller/SignInRecordController.java @@ -43,7 +43,7 @@ public class SignInRecordController { } @PostMapping("signIn") - @ApiOperation("签到 classId :班级id memberId") + @ApiOperation("签到 memberId") public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO){ return ResponseData.generateCreatedResponse(0,signInRecordService.signIn(signInRecordDO)); } @@ -55,5 +55,10 @@ public class SignInRecordController { return ResponseData.generateCreatedResponse(0,signInRecordService.classSignInfo(classSignInfoDTO)); } + @PostMapping("signInStatus") + @ApiOperation("判断学生当天有没有打卡 {memberId 学生id}") + public ResponseVO signInStatus(@RequestBody SignInRecordDO signInRecordDO){ + return ResponseData.generateCreatedResponse(0,signInRecordService.signInStatus(signInRecordDO)); + } } diff --git a/src/main/java/com/subsidy/dto/administer/OperatorsDTO.java b/src/main/java/com/subsidy/dto/administer/OperatorsDTO.java index 597bc22..4e3ecbc 100644 --- a/src/main/java/com/subsidy/dto/administer/OperatorsDTO.java +++ b/src/main/java/com/subsidy/dto/administer/OperatorsDTO.java @@ -15,4 +15,6 @@ public class OperatorsDTO { private String userName; + private Integer id; + } diff --git a/src/main/java/com/subsidy/dto/member/ContentMemberDTO.java b/src/main/java/com/subsidy/dto/member/ContentMemberDTO.java index f616e51..452b39b 100644 --- a/src/main/java/com/subsidy/dto/member/ContentMemberDTO.java +++ b/src/main/java/com/subsidy/dto/member/ContentMemberDTO.java @@ -9,4 +9,6 @@ public class ContentMemberDTO { private Integer courseId; + private Integer classId; + } diff --git a/src/main/java/com/subsidy/mapper/ClassMemberMappingMapper.java b/src/main/java/com/subsidy/mapper/ClassMemberMappingMapper.java index 7a2665d..c979186 100644 --- a/src/main/java/com/subsidy/mapper/ClassMemberMappingMapper.java +++ b/src/main/java/com/subsidy/mapper/ClassMemberMappingMapper.java @@ -1,6 +1,7 @@ package com.subsidy.mapper; import com.subsidy.dto.classDict.GetSpareMembersDTO; +import com.subsidy.model.ClassDictDO; import com.subsidy.model.ClassMemberMappingDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.subsidy.model.MemberDO; @@ -19,5 +20,9 @@ import java.util.List; @Repository public interface ClassMemberMappingMapper extends BaseMapper { + /** + * 获取学生当前有效班级 + */ + List getMemberClass(Long memberId); } diff --git a/src/main/java/com/subsidy/mapper/CompanyDictMapper.java b/src/main/java/com/subsidy/mapper/CompanyDictMapper.java index 7e86199..fea1d20 100644 --- a/src/main/java/com/subsidy/mapper/CompanyDictMapper.java +++ b/src/main/java/com/subsidy/mapper/CompanyDictMapper.java @@ -23,7 +23,7 @@ public interface CompanyDictMapper extends BaseMapper { * * @return */ - IPage operators(IPage page, String companyName, String userName,Integer role); + IPage operators(IPage page, String companyName,Integer id, String userName,Integer role); /** * 通过企业id查找企业的管理员 diff --git a/src/main/java/com/subsidy/model/CourseDictDO.java b/src/main/java/com/subsidy/model/CourseDictDO.java index e1626af..a79f975 100644 --- a/src/main/java/com/subsidy/model/CourseDictDO.java +++ b/src/main/java/com/subsidy/model/CourseDictDO.java @@ -53,9 +53,9 @@ public class CourseDictDO extends BaseModel { */ private String courseSource; - /** - * 习题截止时间 - */ - private LocalDateTime deadline; + ///** + // * 习题截止时间 + // */ + //private LocalDateTime deadline; } diff --git a/src/main/java/com/subsidy/model/SignInRecordDO.java b/src/main/java/com/subsidy/model/SignInRecordDO.java index ed14d50..ce9fd79 100644 --- a/src/main/java/com/subsidy/model/SignInRecordDO.java +++ b/src/main/java/com/subsidy/model/SignInRecordDO.java @@ -29,12 +29,12 @@ public class SignInRecordDO extends BaseModel { /** * 学生id */ - private Integer studentId; + private Long memberId; /** * 班级id */ - private Integer classId; + private Long classId; /** * 签到时间 diff --git a/src/main/java/com/subsidy/service/SignInRecordService.java b/src/main/java/com/subsidy/service/SignInRecordService.java index dd6746b..f285364 100644 --- a/src/main/java/com/subsidy/service/SignInRecordService.java +++ b/src/main/java/com/subsidy/service/SignInRecordService.java @@ -8,6 +8,7 @@ import com.subsidy.model.MemberDO; import com.subsidy.model.SignInRecordDO; import com.baomidou.mybatisplus.extension.service.IService; import com.subsidy.vo.member.GetMemberSignInfoVO; +import com.subsidy.vo.sign.SignInStatusVO; import com.tencentcloudapi.common.Sign; /** @@ -25,4 +26,6 @@ public interface SignInRecordService extends IService { String signIn(SignInRecordDO signInRecordDO); IPage classSignInfo(ClassSignInfoDTO classSignInfoDTO); + + SignInStatusVO signInStatus(SignInRecordDO signInRecordDO); } diff --git a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java index 30ccae7..8f9bc16 100644 --- a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java @@ -79,6 +79,9 @@ public class AdministerServiceImpl extends ServiceImpl operators(OperatorsDTO operatorsDTO) { Page pager = new Page(operatorsDTO.getPageNum(), operatorsDTO.getPageSize()); - return companyDictMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getUserName(), 0); + + //判断该用户的角色 + Integer count = roleAdministerMappingMapper.selectCount(new QueryWrapper() + .lambda() + .eq(RoleAdministerMappingDO::getAdministerId,operatorsDTO.getId()) + .eq(RoleAdministerMappingDO::getRoleId,1)); + + if (count > 0){ + operatorsDTO.setId(null); + } + + return companyDictMapper.operators(pager, operatorsDTO.getCompanyName(),operatorsDTO.getId(), operatorsDTO.getUserName(), 0); } public String addAdminister(AdministerDO administerDO) { @@ -313,7 +327,7 @@ public class AdministerServiceImpl extends ServiceImpl() .lambda() - .eq(SignInRecordDO::getStudentId, classDetailVO.getId()) + .eq(SignInRecordDO::getMemberId, classDetailVO.getId()) .eq(SignInRecordDO::getClassId, classDetailDTO.getId())); classDetailVO.setSignCounts(signCount); @@ -382,7 +396,7 @@ public class AdministerServiceImpl extends ServiceImpl() .lambda() - .eq(SignInRecordDO::getStudentId, classDetailVO.getId()) + .eq(SignInRecordDO::getMemberId, classDetailVO.getId()) .eq(SignInRecordDO::getClassId, classDetailDTO.getId())); classDetailVO.setSignCounts(signCount); @@ -434,7 +448,7 @@ public class AdministerServiceImpl extends ServiceImpl() .lambda() - .eq(SignInRecordDO::getStudentId, classSignVO.getId()) + .eq(SignInRecordDO::getMemberId, classSignVO.getId()) .eq(SignInRecordDO::getClassId, classDetailDTO.getId())); classSignVO.setSignCounts(count); @@ -486,7 +500,7 @@ public class AdministerServiceImpl extends ServiceImpl() .lambda() - .eq(SignInRecordDO::getStudentId, classSignVO.getId()) + .eq(SignInRecordDO::getMemberId, classSignVO.getId()) .eq(SignInRecordDO::getClassId, classDetailDTO.getId())); classSignVO.setSignCounts(count); @@ -589,8 +603,9 @@ public class AdministerServiceImpl extends ServiceImpl operators(OperatorsDTO operatorsDTO) { Page pager = new Page(operatorsDTO.getPageNum(), operatorsDTO.getPageSize()); - return this.baseMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getUserName(),1); + //判断该用户的角色 + Integer count = roleAdministerMappingMapper.selectCount(new QueryWrapper() + .lambda() + .eq(RoleAdministerMappingDO::getAdministerId,operatorsDTO.getId()) + .eq(RoleAdministerMappingDO::getRoleId,1)); + + if (count > 0){ + operatorsDTO.setId(null); + } + + return this.baseMapper.operators(pager, operatorsDTO.getCompanyName(), operatorsDTO.getId(),operatorsDTO.getUserName(),1); } public String addOperator(AddCompanyDTO addCompanyDTO) { diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index ef51d11..4b69b5b 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -95,8 +95,7 @@ public class MemberServiceImpl extends ServiceImpl imple Integer count = this.baseMapper.selectCount(new QueryWrapper() .lambda() - .eq(MemberDO::getTelephone, memberDO.getTelephone()) - .eq(MemberDO::getDepartmentId, memberDO.getDepartmentId())); + .eq(MemberDO::getTelephone, memberDO.getTelephone())); if (count > 0) { throw new HttpException(20002); @@ -361,14 +360,16 @@ public class MemberServiceImpl extends ServiceImpl imple GetCourseTestVO getCourseTestVO = new GetCourseTestVO(); - CourseDictDO courseDictDO = courseDictMapper.selectById(contentMemberDTO.getCourseId()); + ClassDictDO classDictDO = classDictMapper.selectById(contentMemberDTO.getClassId()); + + CourseDictDO courseDictDO = courseDictMapper.selectById(classDictDO.getCourseId()); getCourseTestVO.setCourseId(courseDictDO.getId()); getCourseTestVO.setCourseName(courseDictDO.getCourseName()); - getCourseTestVO.setDeadline(courseDictDO.getDeadline().toString().replace("T"," ")); + getCourseTestVO.setDeadline(classDictDO.getEndDate()); ExerciseDoneResultDO exerciseDoneResultDO = exerciseDoneResultMapper.selectOne(new QueryWrapper() .lambda() - .eq(ExerciseDoneResultDO::getCourseId,contentMemberDTO.getCourseId()) + .eq(ExerciseDoneResultDO::getCourseId,courseDictDO.getId()) .eq(ExerciseDoneResultDO::getMemberId,contentMemberDTO.getMemberId())); if (null != exerciseDoneResultDO){ @@ -379,7 +380,7 @@ public class MemberServiceImpl extends ServiceImpl imple //该课程下有多少习题 Integer count = exerciseDictMapper.selectCount(new QueryWrapper() .lambda() - .eq(ExerciseDictDO::getCourseId,contentMemberDTO.getCourseId())); + .eq(ExerciseDictDO::getCourseId,courseDictDO.getId())); getCourseTestVO.setTotalCount(String.valueOf(count)); } return getCourseTestVO; diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index 5527712..fe8d63e 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -14,9 +14,12 @@ import com.subsidy.util.ConstantUtils; import com.subsidy.util.MathUtil; import com.subsidy.vo.member.GetMemberSignInfoVO; import com.subsidy.vo.sign.ClassSignInfoVO; +import com.subsidy.vo.sign.SignInStatusVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.List; /** @@ -50,30 +53,31 @@ public class SignInRecordServiceImpl extends ServiceImpl() .lambda() - .eq(SignInRecordDO::getStudentId, getMemberSignInfoDTO.getId()) + .eq(SignInRecordDO::getMemberId, getMemberSignInfoDTO.getId()) .orderByDesc(SignInRecordDO::getCreateDate)); } public String signIn(SignInRecordDO signInRecordDO) { /** - * 查看学生打卡记录 - */ - List signInRecordDOS = this.baseMapper.selectList(new QueryWrapper() - .lambda() - .eq(SignInRecordDO::getStudentId, signInRecordDO.getStudentId())); - - /** * 查看学生所有在读班级 */ - - if (signInRecordDOS.size() == 0) { - this.baseMapper.insert(signInRecordDO); - return ConstantUtils.ADD_SUCCESS; - } else { - //不用签到 - return ""; + List classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); + + this.baseMapper.delete(new QueryWrapper() + .lambda() + .eq(SignInRecordDO::getMemberId,signInRecordDO.getMemberId()) + .gt(SignInRecordDO::getSignInDate, LocalDate.now())); + + for (ClassDictDO classDictDO : classDictDOS){ + SignInRecordDO signInRecordDO1 = new SignInRecordDO(); + signInRecordDO1.setClassId(classDictDO.getId()); + signInRecordDO1.setMemberId(signInRecordDO.getMemberId()); + signInRecordDO1.setSignInDate(LocalDateTime.now()); + this.baseMapper.insert(signInRecordDO1); } + + return ConstantUtils.ADD_SUCCESS; } public IPage classSignInfo(ClassSignInfoDTO classSignInfoDTO) { @@ -157,4 +161,31 @@ public class SignInRecordServiceImpl extends ServiceImpl classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); + + for (ClassDictDO classDictDO : classDictDOS){ + Integer count = this.baseMapper.selectCount(new QueryWrapper() + .lambda() + .eq(SignInRecordDO::getClassId,classDictDO.getId()) + .eq(SignInRecordDO::getMemberId,signInRecordDO.getMemberId()) + .gt(SignInRecordDO::getSignInDate,LocalDate.now())); + + if (count == 0 ){ + flag = false; + } + + } + + signInStatusVO.setStatus(flag); + return signInStatusVO; + } + } diff --git a/src/main/java/com/subsidy/vo/administer/LoginVO.java b/src/main/java/com/subsidy/vo/administer/LoginVO.java index 1594562..d97ab86 100644 --- a/src/main/java/com/subsidy/vo/administer/LoginVO.java +++ b/src/main/java/com/subsidy/vo/administer/LoginVO.java @@ -7,4 +7,5 @@ public class LoginVO { private String token; + } diff --git a/src/main/java/com/subsidy/vo/administer/OperatorsVO.java b/src/main/java/com/subsidy/vo/administer/OperatorsVO.java index 33d4086..8b3d2f3 100644 --- a/src/main/java/com/subsidy/vo/administer/OperatorsVO.java +++ b/src/main/java/com/subsidy/vo/administer/OperatorsVO.java @@ -24,4 +24,6 @@ public class OperatorsVO { private String accountName; private Integer companyId; + + private String logo; } diff --git a/src/main/java/com/subsidy/vo/member/MemberStudyPageVO.java b/src/main/java/com/subsidy/vo/member/MemberStudyPageVO.java index 48a87ab..f9730e3 100644 --- a/src/main/java/com/subsidy/vo/member/MemberStudyPageVO.java +++ b/src/main/java/com/subsidy/vo/member/MemberStudyPageVO.java @@ -17,4 +17,5 @@ public class MemberStudyPageVO { private String img; + private String logo; } diff --git a/src/main/java/com/subsidy/vo/sign/SignInStatusVO.java b/src/main/java/com/subsidy/vo/sign/SignInStatusVO.java new file mode 100644 index 0000000..fdb162f --- /dev/null +++ b/src/main/java/com/subsidy/vo/sign/SignInStatusVO.java @@ -0,0 +1,10 @@ +package com.subsidy.vo.sign; + +import lombok.Data; + +@Data +public class SignInStatusVO { + + private Boolean status; + +} diff --git a/src/main/resources/mapper/ClassMemberMappingMapper.xml b/src/main/resources/mapper/ClassMemberMappingMapper.xml index e26d2d7..1d5291b 100644 --- a/src/main/resources/mapper/ClassMemberMappingMapper.xml +++ b/src/main/resources/mapper/ClassMemberMappingMapper.xml @@ -20,4 +20,18 @@ id, member_id, class_id + + diff --git a/src/main/resources/mapper/CompanyDictMapper.xml b/src/main/resources/mapper/CompanyDictMapper.xml index 4c9b6b0..6dc792b 100644 --- a/src/main/resources/mapper/CompanyDictMapper.xml +++ b/src/main/resources/mapper/CompanyDictMapper.xml @@ -30,7 +30,8 @@ t2.short_name, t.account_name, t.img, - t2.company_name + t2.company_name, + t2.logo FROM administer t left join company_dict t2 on t.company_id = t2.id @@ -43,6 +44,9 @@ and t.user_name like concat('%',#{userName} ,'%') + + and t.id = #{id} +