上传apk优化
This commit is contained in:
parent
2459915ed9
commit
45c5a2b45a
|
|
@ -122,8 +122,7 @@ public class DoubleScreenMachineController extends BaseController {
|
||||||
@ApiOperation(value = "上传APK")
|
@ApiOperation(value = "上传APK")
|
||||||
@PostMapping({"/uploadApk"})
|
@PostMapping({"/uploadApk"})
|
||||||
public AjaxResult uploadApk(@RequestBody @Valid ApkDTO dto) {
|
public AjaxResult uploadApk(@RequestBody @Valid ApkDTO dto) {
|
||||||
this.screenMachineService.uploadApk(dto);
|
return this.screenMachineService.uploadApk(dto);
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import com.bonus.canteen.core.device.dto.ApkDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
import com.bonus.canteen.core.device.dto.DeviceDTO;
|
||||||
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
|
@ -51,5 +52,5 @@ public interface IDoubleScreenMachineService {
|
||||||
*/
|
*/
|
||||||
void updateTimeBySn(String sn);
|
void updateTimeBySn(String sn);
|
||||||
|
|
||||||
void uploadApk(@Valid ApkDTO dto);
|
AjaxResult uploadApk(@Valid ApkDTO dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.bonus.canteen.core.device.dto.DeviceSearchDTO;
|
||||||
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
import com.bonus.canteen.core.device.vo.DeviceFullInfoVO;
|
||||||
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
import com.bonus.canteen.core.user.domain.DeviceMqPersonalUpdateMessageDTO;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.houqin.constant.GlobalConstants;
|
import com.bonus.common.houqin.constant.GlobalConstants;
|
||||||
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
import com.bonus.common.houqin.mq.constant.LeMqConstant;
|
||||||
import com.bonus.common.houqin.utils.id.Id;
|
import com.bonus.common.houqin.utils.id.Id;
|
||||||
|
|
@ -171,16 +172,22 @@ public class DoubleScreenMachineServiceImpl implements IDoubleScreenMachineServi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uploadApk(ApkDTO dto) {
|
public AjaxResult uploadApk(ApkDTO dto) {
|
||||||
try {
|
try {
|
||||||
ApkDTO apkDTO = mapper.getApkByType(dto.getType(), dto.getVersion());
|
ApkDTO apkDTO = mapper.getApkByType(dto.getType(), dto.getVersion());
|
||||||
if (apkDTO != null) {
|
if (apkDTO != null) {
|
||||||
|
//检查最新的一条版本是否相同
|
||||||
|
ApkDTO lastBean = mapper.getApkByType(dto.getType(), null);
|
||||||
|
if (lastBean != null && !lastBean.getVersion().equals(dto.getVersion())){
|
||||||
|
return AjaxResult.error("该版本已存在");
|
||||||
|
}
|
||||||
mapper.updateApk(dto);
|
mapper.updateApk(dto);
|
||||||
} else {
|
} else {
|
||||||
mapper.insertApk(dto);
|
mapper.insertApk(dto);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ServiceException("操作失败");
|
return AjaxResult.error("操作失败");
|
||||||
}
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -181,7 +181,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="getApkByType" resultType="com.bonus.canteen.core.device.dto.ApkDTO">
|
<select id="getApkByType" resultType="com.bonus.canteen.core.device.dto.ApkDTO">
|
||||||
select * from app_version where type = #{type} and version = #{version}
|
select *
|
||||||
|
from app_version
|
||||||
|
where 1 = 1
|
||||||
|
<if test="version != null and version != ''">
|
||||||
|
and version = #{version}
|
||||||
|
</if>
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
and type = #{type}
|
||||||
|
order by version desc
|
||||||
|
limit 1
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertDeviceRecipe">
|
<insert id="insertDeviceRecipe">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue