Parcourir la source

1、个人风采视频封面
2、设备号绑定

zouxuan il y a 2 ans
Parent
commit
1286e87c29

+ 16 - 39
cooleshow-auth/auth-server/src/main/java/com/yonge/cooleshow/auth/service/impl/SysUserDeviceServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import com.yonge.cooleshow.auth.dal.dao.SysConfigDao;
 import com.yonge.toolset.mybatis.service.impl.BaseServiceImpl;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +22,8 @@ public class SysUserDeviceServiceImpl extends BaseServiceImpl<Long, SysUserDevic
 	
 	@Autowired
 	private SysUserDeviceDao sysUserDeviceDao;
+	@Autowired
+	private SysConfigDao sysConfigDao;
 
 	@Override
 	public BaseDAO<Long, SysUserDevice> getDAO() {
@@ -39,48 +42,23 @@ public class SysUserDeviceServiceImpl extends BaseServiceImpl<Long, SysUserDevic
 
 	@Override
 	public boolean bindDevice(String clientId, Long userId, String deviceNum) {
+		String configValue = sysConfigDao.findConfigValue("user_device_login_num");
+		if(StringUtils.isEmpty(configValue)){
+			return true;
+		}
+		// 检查学生是否绑定了多个设备号
+		List<SysUserDevice> studentDeviceList = queryByUserId(clientId, userId);
 
-		if (StringUtils.equals(clientId, "STUDENT")) {
-			// 检查学生是否绑定了多个设备号
-			List<SysUserDevice> studentDeviceList = queryByUserId(clientId, userId);
-
-			if (studentDeviceList == null) {
-				studentDeviceList = new ArrayList<SysUserDevice>();
-			}
-
-			List<String> deviceList = studentDeviceList.stream().map(t -> t.getDeviceNum()).collect(Collectors.toList());
-
-			if (!deviceList.contains(deviceNum)) {
-				if (deviceList.size() >= 5) {
-					throw new BadCredentialsException("登录失败,当前账号绑定设备过多");
-				}
-
-				SysUserDevice sysUserDevice = new SysUserDevice();
-				sysUserDevice.setUserId(userId);
-				sysUserDevice.setDeviceNum(deviceNum);
-				sysUserDevice.setBindTime(new Date());
-				sysUserDevice.setClientId(clientId);
-				sysUserDeviceDao.insert(sysUserDevice);
-			}
-		} else {
-			// 查询设备号是否已存在
-			List<SysUserDevice> sysUserDeviceList = sysUserDeviceDao.queryByDeviceNum(null, deviceNum);
-
-			if (sysUserDeviceList == null) {
-				sysUserDeviceList = new ArrayList<SysUserDevice>();
-			}
-
-			sysUserDeviceList = sysUserDeviceList.stream().filter(sud -> !StringUtils.equals(sud.getClientId(), "STUDENT")).collect(Collectors.toList());
-
-			if (sysUserDeviceList != null && sysUserDeviceList.size() > 0) {
-				if (sysUserDeviceList.stream().filter(sud -> sud.getUserId().equals(userId)).count() > 0) {
+		if (studentDeviceList == null) {
+			studentDeviceList = new ArrayList<SysUserDevice>();
+		}
 
-					return true;
-				}
+		List<String> deviceList = studentDeviceList.stream().map(t -> t.getDeviceNum()).collect(Collectors.toList());
 
-				throw new BadCredentialsException("当前设备已绑定账号,请更换设备");
+		if (!deviceList.contains(deviceNum)) {
+			if (deviceList.size() >= Integer.parseInt(configValue)) {
+				throw new BadCredentialsException("登录失败:该账号已达到设备绑定数量上限");
 			}
-
 			SysUserDevice sysUserDevice = new SysUserDevice();
 			sysUserDevice.setUserId(userId);
 			sysUserDevice.setDeviceNum(deviceNum);
@@ -88,7 +66,6 @@ public class SysUserDeviceServiceImpl extends BaseServiceImpl<Long, SysUserDevic
 			sysUserDevice.setClientId(clientId);
 			sysUserDeviceDao.insert(sysUserDevice);
 		}
-
 		return true;
 	}
 

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/TeacherStyleVideo.java

@@ -26,6 +26,9 @@ public class TeacherStyleVideo implements Serializable {
     @ApiModelProperty("老师编号 ")
     @TableField(value = "user_id_")
     private Long userId;
+    @ApiModelProperty("视频封面")
+    @TableField(value = "cover_")
+    private String cover;
     @ApiModelProperty("视频地址 ")
     @TableField(value = "video_url_")
     private String videoUrl;
@@ -59,6 +62,14 @@ public class TeacherStyleVideo implements Serializable {
     @TableField(value = "del_flag_")
     private Boolean delFlag = false;
 
+    public String getCover() {
+        return cover;
+    }
+
+    public void setCover(String cover) {
+        this.cover = cover;
+    }
+
     public Long getId() {
         return id;
     }

+ 2 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherStyleVideoMapper.xml

@@ -5,6 +5,7 @@
 		<result column="id_" property="id" />
 		<result column="user_id_" property="userId" />
 		<result column="video_url_" property="videoUrl" />
+		<result column="cover_" property="cover" />
 		<result column="describe_" property="describe" />
 		<result column="browse_" property="browse" />
 		<result column="audit_version_" property="auditVersion" />
@@ -21,6 +22,7 @@
 		t.id_ as id
         , t.user_id_ as userId
         , t.video_url_ as videoUrl
+        , t.cover_ as cover
         , t.describe_ as `describe`
         , t.browse_ as browse
         , t.audit_version_ as auditVersion