|
@@ -1,22 +1,76 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.Teacher;
|
|
|
+import com.yonge.cooleshow.biz.dal.entity.TeacherAuthEntryRecord;
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
+import com.yonge.cooleshow.biz.dal.support.Condition;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.TeacherAuthMusicianRecord;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.TeacherAuthMusicianRecordDao;
|
|
|
import com.yonge.cooleshow.biz.dal.service.TeacherAuthMusicianRecordService;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
@Service
|
|
|
public class TeacherAuthMusicianRecordServiceImpl extends ServiceImpl<TeacherAuthMusicianRecordDao, TeacherAuthMusicianRecord> implements TeacherAuthMusicianRecordService {
|
|
|
+ @Autowired
|
|
|
+ private TeacherService teacherService;
|
|
|
+ @Autowired
|
|
|
+ private TeacherDao teacherDao;
|
|
|
|
|
|
/**
|
|
|
* 分页查询
|
|
|
*/
|
|
|
- @Override
|
|
|
- public IPage<TeacherAuthMusicianRecord> selectPage(IPage<TeacherAuthMusicianRecord> page, TeacherAuthMusicianRecord teacherAuthMusicianRecord){
|
|
|
+ @Override
|
|
|
+ public IPage<TeacherAuthMusicianRecord> selectPage(IPage<TeacherAuthMusicianRecord> page, TeacherAuthMusicianRecord teacherAuthMusicianRecord) {
|
|
|
return page.setRecords(baseMapper.selectPage(page, teacherAuthMusicianRecord));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Integer getMusicianAuthStatus(Long id) {
|
|
|
+ Teacher teacher = teacherService.getById(id);
|
|
|
+ return teacher.getMusicianAuthStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResponseResult<Boolean> doApply(Long id) {
|
|
|
+ //判断用户是否已经提交申请
|
|
|
+ if (hasApply(id)) {
|
|
|
+ return HttpResponseResult.failed("已经提交过申请");
|
|
|
+ }
|
|
|
+
|
|
|
+ TeacherAuthMusicianRecord record = new TeacherAuthMusicianRecord();
|
|
|
+ record.setUserId(id);
|
|
|
+ record.setTeacherAuthStatus(AuthStatusEnum.DOING.getCode());
|
|
|
+
|
|
|
+ Teacher teacher = new Teacher();
|
|
|
+ teacher.setUserId(id);
|
|
|
+ teacher.setMusicianAuthStatus(AuthStatusEnum.DOING.getCode());
|
|
|
+ teacherDao.updateById(teacher);
|
|
|
+
|
|
|
+ return HttpResponseResult.status(baseMapper.insert(record) > 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 判断用户是否已经提交申请
|
|
|
+ * @author liweifan
|
|
|
+ * @param: userId
|
|
|
+ * @updateTime 2022/3/21 11:37
|
|
|
+ * @return: java.lang.Boolean
|
|
|
+ */
|
|
|
+ private boolean hasApply(Long userId) {
|
|
|
+ TeacherAuthMusicianRecord teacherAuthMusicianRecord = baseMapper.selectOne(Wrappers.<TeacherAuthMusicianRecord>query().lambda()
|
|
|
+ .eq(TeacherAuthMusicianRecord::getUserId, userId)
|
|
|
+ .eq(TeacherAuthMusicianRecord::getTeacherAuthStatus, 1));
|
|
|
+ return teacherAuthMusicianRecord != null;
|
|
|
+ }
|
|
|
+
|
|
|
}
|