liujc пре 1 месец
родитељ
комит
cf986bf199

+ 12 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherController.java

@@ -210,6 +210,18 @@ public class TeacherController extends BaseController {
     }
 
 
+    @ApiOperation(value = "移除粉丝")
+    @PostMapping(value = "/delFans/{userId}")
+    public HttpResponseResult<Void> delFans(@PathVariable("userId") Long userId) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null || sysUser.getId() == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        teacherService.delFans(userId, sysUser.getId());
+        return succeed();
+    }
+
+
     /**
      * 最近练习
      */

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/StudentStarDao.java

@@ -40,4 +40,6 @@ public interface StudentStarDao extends BaseMapper<StudentStar>{
      * @return
      */
     List<StudentStar> queryByStudentId(Long studentId);
+
+    void delFans(@Param("studentId") Long studentId, @Param("teacherId") Long teacherId);
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/StudentTotalService.java

@@ -45,4 +45,6 @@ public interface StudentTotalService extends IService<StudentTotal>  {
 	StudentTotal getTotalById(Long id);
 
 	void updateTotalCache(StudentTotal studentTotal);
+
+    StudentTotal totalStudentTotalById(Long id);
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TeacherService.java

@@ -211,4 +211,6 @@ public interface TeacherService extends IService<Teacher> {
      * @return String
      */
     String updateUserCustomerService(Long userId);
+
+    void delFans(Long studentId, Long teacherId);
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TeacherTotalService.java

@@ -56,4 +56,6 @@ public interface TeacherTotalService extends IService<TeacherTotal>  {
     TeacherTotal getTotalById(Long userId);
 
 	void updateTotalCache(TeacherTotal teacherTotal);
+
+    TeacherTotal totalTeacherTotalById(Long id);
 }

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentTotalServiceImpl.java

@@ -131,7 +131,8 @@ public class StudentTotalServiceImpl extends ServiceImpl<StudentTotalDao, Studen
     }
 
 
-    private StudentTotal totalStudentTotalById(Long id) {
+    @Override
+    public StudentTotal totalStudentTotalById(Long id) {
         StudentTotal studentTotal = new StudentTotal();
         studentTotal.setUserId(id);
 

+ 14 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -194,6 +194,12 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
     @Autowired
     private VipCardRecordService vipCardRecordService;
 
+    @Autowired
+    private TeacherTotalService teacherTotalService;
+
+    @Autowired
+    private StudentTotalService studentTotalService;
+
     @Override
     public TeacherDao getDao() {
         return baseMapper;
@@ -1617,4 +1623,12 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
 
         return imCustomerServiceId;
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delFans(Long studentId, Long teacherId) {
+        studentStarDao.delFans(studentId,teacherId);
+        teacherTotalService.totalTeacherTotalById(teacherId);
+        studentTotalService.totalStudentTotalById(studentId);
+    }
 }

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherTotalServiceImpl.java

@@ -215,7 +215,8 @@ public class TeacherTotalServiceImpl extends ServiceImpl<TeacherTotalDao, Teache
         }
     }
 
-    private TeacherTotal totalTeacherTotalById(Long id) {
+    @Override
+    public TeacherTotal totalTeacherTotalById(Long id) {
         TeacherTotal teacherTotal = new TeacherTotal();
         teacherTotal.setUserId(id);
         //查询粉丝数

+ 4 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/StudentStarMapper.xml

@@ -49,4 +49,8 @@
 	<select id="queryByStudentId" resultMap="BaseResultMap">
 		select * from student_star ss where ss.student_id_ = #{studentId}
 	</select>
+
+	<delete id="delFans">
+        delete from student_star where student_id_ = #{studentId} and teacher_id_ = #{teacherId}
+    </delete>
 </mapper>