浏览代码

Merge remote-tracking branch 'origin/master'

Joburgess 5 年之前
父节点
当前提交
fd5264660c

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/AppVersionInfoDao.java

@@ -8,4 +8,10 @@ import com.ym.mec.common.dal.BaseDAO;
 public interface AppVersionInfoDao extends BaseDAO<Integer, AppVersionInfo> {
 
 	List<AppVersionInfo> queryNewestByPlatform(String platform);
+
+	/**
+	 * 修改所有的为历史
+	 * @param platform
+	 */
+	void batchUpdateStatus(String platform);
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/AppVersionInfoService.java

@@ -8,4 +8,8 @@ import com.ym.mec.common.service.BaseService;
 public interface AppVersionInfoService extends BaseService<Integer, AppVersionInfo> {
 
 	List<AppVersionInfo> queryNewestByPlatform(String platform);
+
+	void add(AppVersionInfo appVersionInfo);
+
+	void updateVersion(AppVersionInfo appVersionInfo);
 }

+ 30 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/AppVersionInfoServiceImpl.java

@@ -1,7 +1,10 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.Date;
 import java.util.List;
 
+import com.ym.mec.common.exception.BizException;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -10,6 +13,7 @@ import com.ym.mec.biz.dal.entity.AppVersionInfo;
 import com.ym.mec.biz.service.AppVersionInfoService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
 
 @Service
 public class AppVersionInfoServiceImpl extends BaseServiceImpl<Integer, AppVersionInfo>  implements AppVersionInfoService {
@@ -26,5 +30,30 @@ public class AppVersionInfoServiceImpl extends BaseServiceImpl<Integer, AppVersi
 	public List<AppVersionInfo> queryNewestByPlatform(String platform) {
 		return appVersionInfoDao.queryNewestByPlatform(platform);
 	}
-	
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void add(AppVersionInfo appVersionInfo) {
+		if(StringUtils.isEmpty(appVersionInfo.getPlatform())){
+			throw new BizException("参数校验异常");
+		}
+		if (StringUtils.equals(appVersionInfo.getStatus(), "newest")) {
+			//修改其他的为历史版本
+			appVersionInfoDao.batchUpdateStatus(appVersionInfo.getPlatform());
+		}
+		appVersionInfoDao.insert(appVersionInfo);
+	}
+
+	@Override
+	public void updateVersion(AppVersionInfo appVersionInfo) {
+		if(StringUtils.isEmpty(appVersionInfo.getPlatform())){
+			throw new BizException("参数校验异常");
+		}
+		if (StringUtils.equals(appVersionInfo.getStatus(), "newest")) {
+			appVersionInfoDao.batchUpdateStatus(appVersionInfo.getPlatform());
+		}
+		appVersionInfo.setUpdateTime(new Date());
+		appVersionInfoDao.update(appVersionInfo);
+	}
+
 }

+ 22 - 10
mec-biz/src/main/resources/config/mybatis/AppVersionInfoMapper.xml

@@ -9,7 +9,6 @@
 		<result column="platform_" property="platform" />
 		<result column="version_" property="version" />
 		<result column="status_" property="status" />
-		<result column="is_force_update_" property="isForceUpdate" />
 		<result column="description_" property="description" />
 		<result column="download_url_" property="downloadUrl" />
 		<result column="operator_id_" property="operatorId" />
@@ -30,7 +29,12 @@
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="AppVersionInfo">
 		SELECT * FROM app_version_info
-		ORDER BY id_
+		<where>
+			<if test="search != null and search != ''">
+				platform_ LIKE CONCAT('%',#{search},'%')
+			</if>
+		</where>
+		ORDER BY status_ DESC
 	</select>
 
 	<!-- 向数据库增加一条记录 -->
@@ -40,7 +44,7 @@
 			AS ID FROM DUAL </selectKey> -->
 		INSERT INTO app_version_info
 		(id_,platform_,version_,status_,is_force_update_,description_,download_url_,operator_id_,update_time_,create_time_)
-		VALUES(#{id},#{platform},#{version},#{status},#{isForceUpdate},#{description},#{downloadUrl},#{operatorId},#{updateTime},#{createTime})
+		VALUES(#{id},#{platform},#{version},#{status},#{isForceUpdate},#{description},#{downloadUrl},#{operatorId},NOW(),NOW())
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->
@@ -59,9 +63,6 @@
 			<if test="platform != null">
 				platform_ = #{platform},
 			</if>
-			<if test="id != null">
-				id_ = #{id},
-			</if>
 			<if test="updateTime != null">
 				update_time_ = #{updateTime},
 			</if>
@@ -74,12 +75,12 @@
 			<if test="isForceUpdate != null">
 				is_force_update_ = #{isForceUpdate},
 			</if>
-			<if test="createTime != null">
-				create_time_ = #{createTime},
-			</if>
 		</set>
 		WHERE id_ = #{id}
 	</update>
+	<update id="batchUpdateStatus">
+		UPDATE app_version_info SET status_ = 'history',update_time_ = NOW() WHERE platform_ = #{platform} AND status_ = 'newest'
+	</update>
 
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete">
@@ -88,12 +89,23 @@
 
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="AppVersionInfo" parameterType="map">
-		SELECT * FROM app_version_info ORDER BY id_ DESC
+		SELECT * FROM app_version_info
+		<where>
+			<if test="search != null and search != ''">
+				platform_ LIKE CONCAT('%',#{search},'%')
+			</if>
+		</where>
+		ORDER BY status_ DESC
 		<include refid="global.limit" />
 	</select>
 
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM app_version_info
+		<where>
+			<if test="search != null and search != ''">
+				platform_ LIKE CONCAT('%',#{search},'%')
+			</if>
+		</where>
 	</select>
 </mapper>

+ 7 - 7
mec-im/src/main/java/com/ym/service/Impl/RoomServiceImpl.java

@@ -107,7 +107,7 @@ public class RoomServiceImpl implements RoomService {
         }catch (Exception e){
             e.printStackTrace();
         }
-        roomId = "S" + roomId;
+        roomId = "DAYA" + roomId;
         String display = "";
         Date curTime = DateTimeUtils.currentUTC();
         List<Room> roomList = roomDao.findByRid(roomId);
@@ -248,12 +248,12 @@ public class RoomServiceImpl implements RoomService {
         SysUser user = sysUserFeignService.queryUserInfo();
         String userId = user.getId().toString();
         Teacher teacher = teacherDao.get(user.getId());
-        CourseSchedule courseSchedule = courseScheduleDao.get(Long.parseLong(roomId.substring(1)));
+        CourseSchedule courseSchedule = courseScheduleDao.get(Long.parseLong(roomId.substring(4)));
         try {
             if(teacher != null && teacher.getId().equals(courseSchedule.getActualTeacherId())){
-                teacherAttendanceService.addTeacherAttendanceRecord(Integer.parseInt(roomId.substring(1)),user.getId(), SignStatusEnum.SIGN_OUT,true);
+                teacherAttendanceService.addTeacherAttendanceRecord(Integer.parseInt(roomId.substring(4)),user.getId(), SignStatusEnum.SIGN_OUT,true);
             }else {
-                studentAttendanceService.addStudentAttendanceRecord(Integer.parseInt(roomId.substring(1)),user.getId(), StudentAttendanceStatusEnum.NORMAL,SignStatusEnum.SIGN_OUT);
+                studentAttendanceService.addStudentAttendanceRecord(Integer.parseInt(roomId.substring(4)),user.getId(), StudentAttendanceStatusEnum.NORMAL,SignStatusEnum.SIGN_OUT);
             }
         }catch (Exception e){
             e.printStackTrace();
@@ -1136,12 +1136,12 @@ public class RoomServiceImpl implements RoomService {
 //            SysUser sysUser = sysUserFeignService.queryUserById(Integer.parseInt(userId));
             SysUser sysUser = teacherDao.getUser(Integer.parseInt(userId));
             Teacher teacher = teacherDao.get(sysUser.getId());
-            CourseSchedule courseSchedule = courseScheduleDao.get(Long.parseLong(roomId.substring(1)));
+            CourseSchedule courseSchedule = courseScheduleDao.get(Long.parseLong(roomId.substring(4)));
             try {
                 if(teacher != null && teacher.getId().equals(courseSchedule.getActualTeacherId())){
-                    teacherAttendanceService.addTeacherAttendanceRecord(Integer.parseInt(roomId.substring(1)),Integer.parseInt(userId), SignStatusEnum.SIGN_OUT,true);
+                    teacherAttendanceService.addTeacherAttendanceRecord(Integer.parseInt(roomId.substring(4)),Integer.parseInt(userId), SignStatusEnum.SIGN_OUT,true);
                 }else {
-                    studentAttendanceService.addStudentAttendanceRecord(Integer.parseInt(roomId.substring(1)),Integer.parseInt(userId), StudentAttendanceStatusEnum.NORMAL,SignStatusEnum.SIGN_OUT);
+                    studentAttendanceService.addStudentAttendanceRecord(Integer.parseInt(roomId.substring(4)),Integer.parseInt(userId), StudentAttendanceStatusEnum.NORMAL,SignStatusEnum.SIGN_OUT);
                 }
             }catch (Exception e){
                 e.printStackTrace();

+ 2 - 2
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/eseal/provider/TsignPlugin.java

@@ -57,14 +57,14 @@ public class TsignPlugin implements ESealPlugin, InitializingBean, DisposableBea
 		projectconfig.setProjectSecret(projectSecret);
 		projectconfig.setItsmApiUrl(apisUrl);
 		Result result = ServiceClientManager.registClient(projectconfig, null, null);
-		if (result.getErrCode() != 0) {
+		/*if (result.getErrCode() != 0) {
 			throw new ThirdpartyException("e签宝客户端注册失败:{}", result.getMsg());
 		}
 
 		serviceClient = ServiceClientManager.get(projectId);
 		if (serviceClient == null) {
 			throw new ThirdpartyException("获取e签宝客户端失败");
-		}
+		}*/
 	}
 
 	@Override

+ 4 - 19
mec-web/src/main/java/com/ym/mec/web/controller/AppVersionInfoController.java

@@ -52,7 +52,6 @@ public class AppVersionInfoController extends BaseController {
 	@GetMapping(value = "/query")
 	@PreAuthorize("@pcs.hasPermissions('appVersionInfo/query')")
 	public Object query(Integer id) {
-
 		return succeed(appVersionInfoService.get(id));
 	}
 
@@ -60,30 +59,16 @@ public class AppVersionInfoController extends BaseController {
 	@PostMapping(value = "/add", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 	@PreAuthorize("@pcs.hasPermissions('appVersionInfo/add')")
 	public Object add(AppVersionInfo appVersionInfo) {
-		Date date = new Date();
-		appVersionInfo.setCreateTime(date);
-		if (StringUtils.equals(appVersionInfo.getStatus(), "newest")) {
-			List<AppVersionInfo> list = appVersionInfoService.queryNewestByPlatform(appVersionInfo.getPlatform());
-			if (list.size() > 0) {
-				return failed("一个平台只能有一个最新状态的记录");
-			}
-		}
-		return succeed(appVersionInfoService.insert(appVersionInfo));
+		appVersionInfoService.add(appVersionInfo);
+		return succeed();
 	}
 
 	@ApiOperation("更新")
 	@PostMapping(value = "/update", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
 	@PreAuthorize("@pcs.hasPermissions('appVersionInfo/update')")
 	public Object update(AppVersionInfo appVersionInfo) {
-		Date date = new Date();
-		appVersionInfo.setUpdateTime(date);
-		if (StringUtils.equals(appVersionInfo.getStatus(), "newest")) {
-			List<AppVersionInfo> list = appVersionInfoService.queryNewestByPlatform(appVersionInfo.getPlatform());
-			if (list.size() > 0) {
-				return failed("一个平台只能有一个最新状态的记录");
-			}
-		}
-		return succeed(appVersionInfoService.update(appVersionInfo));
+		appVersionInfoService.updateVersion(appVersionInfo);
+		return succeed();
 	}
 
 }