123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /*
- *
- * ApkInfoController
- *
- */
- package com.szwl.controller;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.szwl.model.bo.JsonMessage;
- import com.szwl.model.entity.TApkInfo;
- import com.szwl.model.entity.TEquipment;
- import com.szwl.model.utils.PushUtils;
- import com.szwl.service.TApkInfoService;
- import com.szwl.service.TEquipmentService;
- import org.apache.commons.lang.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * Controller - apk信息
- */
- @Controller("appApkInfoController")
- @RequestMapping("api/appApkInfo")
- public class ApkInfoController {
- @Autowired
- TApkInfoService tApkInfoService;
- @Autowired
- TEquipmentService equipmentService;
- /**
- * 获得最新的更新数据
- *
- * @param model 型号
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/apkinfo.htm", produces = "text/html;charset=utf-8")
- public String getApkInfo(String model) {
- if (StringUtils.isEmpty(model)) {
- // return JsonMessage.error("没有版本数据");
- return "没有版本数据";
- }
- LambdaQueryWrapper<TApkInfo> query = Wrappers.lambdaQuery();
- query.eq(TApkInfo::getModel,model);
- query.orderByDesc(TApkInfo::getVersion);
- List<TApkInfo> list = tApkInfoService.list(query);
- TApkInfo info = list.get(0);
- if (info != null) {
- // return JsonMessage.success(JSONObject.toJSONString(info));
- return JSONObject.toJSONString(info);
- }
- // return JsonMessage.error("没有版本数据");
- return "没有版本数据";
- }
- /**
- * 获得最新的更新数据
- *
- * @param model 型号
- * @return
- */
- @ResponseBody
- @RequestMapping(value = "/getApkinfoList.htm", produces = "text/html;charset=utf-8")
- public String getApkInfoList(String model) {
- if (StringUtils.isEmpty(model)) {
- // return JsonMessage.error("没有版本数据");
- return "没有版本数据";
- }
- LambdaQueryWrapper<TApkInfo> query = Wrappers.lambdaQuery();
- query.eq(TApkInfo::getModel,model);
- query.orderByDesc(TApkInfo::getVersion);
- List<TApkInfo> list = tApkInfoService.list(query);
- if (list.size()>0) {
- return JSONObject.toJSONString(list);
- }
- return "没有版本数据";
- }
- /**
- * 系统自动更新
- *
- * @param clientId
- * @return
- */
- @RequestMapping(value = "/updateApk", method = RequestMethod.GET, produces = "text/html;charset=utf-8")
- @ResponseBody
- public String separate(String clientId,String url) {
- LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
- query.eq(TEquipment::getClientId,clientId);
- List<TEquipment> list = equipmentService.list(query);
- TEquipment equipment = list.get(0);
- if (equipment == null) {
- return "该设备不存在";
- }
- equipmentService.sentMessage(clientId, PushUtils.buildJson("updateApk", url).toString());
- return "推送成功";
- }
- }
|