| @@ -34,14 +34,15 @@ public class WxDeviceController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public Result list(@RequestBody WxDevice wxDevice, Integer pageNum, Integer pageSize) { | |||
| public Result list(@ModelAttribute WxDevice wxDevice, Integer pageNum, Integer pageSize) { | |||
| wxDevice.setTenantId(getTenantId()); | |||
| wxDevice.setStatus(EnumDeviceStatus.VALID.getCode()); | |||
| return new ResultData(wxDeviceService.listAsPage(wxDevice, pageNum,pageSize)); | |||
| } | |||
| @ApiOperation("添加设备") | |||
| @PostMapping("add") | |||
| public Result add(@RequestBody WxDevice wxDevice) { | |||
| public Result add(@ModelAttribute WxDevice wxDevice) { | |||
| WxDevice record = new WxDevice(); | |||
| record.setDeviceId(wxDevice.getDeviceId()); | |||
| @@ -49,7 +50,7 @@ public class WxDeviceController extends BaseController { | |||
| List<WxDevice> list = wxDeviceService.findList(record); | |||
| if (list.size() > 0) | |||
| return new ResultData(ErrorCode.DEVICE_ALREADY_EXIST); | |||
| wxDevice.setStatus(EnumDeviceStatus.INIT.getCode()); | |||
| wxDevice.setStatus(EnumDeviceStatus.VALID.getCode()); | |||
| wxDevice.setOnlineStatus(EnumDeviceOnlineStatus.OFFLINE.getCode()); | |||
| wxDevice.setTenantId(getTenantId()); | |||
| wxDeviceService.saveOrUpdate(wxDevice); | |||
| @@ -58,7 +59,7 @@ public class WxDeviceController extends BaseController { | |||
| @ApiOperation("更新设备") | |||
| @PostMapping("update") | |||
| public Result update(@RequestBody WxDevice wxDevice) { | |||
| public Result update(@ModelAttribute WxDevice wxDevice) { | |||
| if (wxDevice == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxDevice.getId() == null) | |||
| @@ -51,7 +51,7 @@ public class WxDeviceScreenAdController extends BaseController { | |||
| wxDevice.setDeviceId(deviceId); | |||
| wxDevice.setStatus(EnumScreenAdStatus.VALID.getCode()); | |||
| List<WxDevice> list = wxDeviceService.findList(wxDevice); | |||
| if (list.size() < 0) | |||
| if (list.size() <= 0) | |||
| return null; | |||
| else | |||
| return list.get(0); | |||
| @@ -45,14 +45,15 @@ public class WxScreenAdController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public Result list(@RequestBody WxScreenAd wxScreenAd, Integer pageNum, Integer pageSize) { | |||
| public Result list(@ModelAttribute WxScreenAd wxScreenAd, Integer pageNum, Integer pageSize) { | |||
| wxScreenAd.setTenantId(getTenantId()); | |||
| wxScreenAd.setStatus(EnumScreenAdStatus.VALID.getCode()); | |||
| return new ResultData(wxScreenAdService.listAsPage(wxScreenAd,pageNum,pageSize)); | |||
| } | |||
| @ApiOperation("添加广告") | |||
| @PostMapping("add") | |||
| public Result add(@RequestBody WxScreenAd wxScreenAd) { | |||
| public Result add(@ModelAttribute WxScreenAd wxScreenAd) { | |||
| wxScreenAd.setStatus(EnumScreenAdStatus.VALID.getCode()); | |||
| wxScreenAd.setTenantId(getTenantId()); | |||
| wxScreenAdService.saveOrUpdate(wxScreenAd); | |||
| @@ -61,7 +62,7 @@ public class WxScreenAdController extends BaseController { | |||
| @ApiOperation("更新广告") | |||
| @PostMapping("update") | |||
| public Result update(@RequestBody WxScreenAd wxScreenAd) { | |||
| public Result update(@ModelAttribute WxScreenAd wxScreenAd) { | |||
| if (wxScreenAd == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (wxScreenAd.getId() == null) | |||
| @@ -5,9 +5,8 @@ package com.iformall.enums; | |||
| */ | |||
| public enum EnumDeviceStatus { | |||
| INIT(0, "初始化"), | |||
| VALID(1, "有效"), | |||
| INVALID(2, "无效"); | |||
| VALID(0, "有效"), | |||
| INVALID(1, "无效"); | |||
| public static EnumDeviceStatus getEnum(Integer code) { | |||
| for (EnumDeviceStatus value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| @@ -40,6 +40,7 @@ public class WxDeviceServiceImpl implements WxDeviceService { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| wxDeviceMapper.insertSelective(record); | |||
| } else { | |||
| record.setUpdateDate(new Date()); | |||
| @@ -54,6 +54,7 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| setQrcode(record); | |||
| wxScreenAdMapper.insertSelective(record); | |||
| @@ -92,42 +93,46 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||
| private static String wxacodeunlimit = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="; | |||
| private static int QRCODE_WIDTH = 300; | |||
| private static String QRCODE_PAGE_COUPON = "pages/coupon/detail/index"; | |||
| private static String QRCODE_PAGE_CAMPGIN = "pages/bannerdetail/index"; | |||
| private static String QRCODE_PAGE_HOME = "pages/index/index"; | |||
| private static boolean QRCODE_AUTO_COLOR = false; | |||
| //private static int QRCODE_LINCOLOR =; | |||
| private static boolean QRCODE_IS_HYALINE = false; | |||
| //private static int QRCODE_LINCOLOR =; | |||
| private static String QRCODE_JUMP_CMD_HOME = "JH"; | |||
| private static String QRCODE_JUMP_CMD_COUPON = "JC"; | |||
| private static String QRCODE_JUMP_CMD_CAMPGIN = "JB"; | |||
| private byte[] getQrcode(Long id, int type, WxAppinfo appInfo) throws Exception { | |||
| String accessToken = appInfo.getAccessToken(); | |||
| HttpHeaders headers = new HttpHeaders(); | |||
| headers.setContentType(MediaType.APPLICATION_JSON); | |||
| Map<String,Object> map = new HashMap<>(); | |||
| map.put("scene", id.toString()); | |||
| if (EnumScreenAdType.COUPON.getCode().equals(type)) | |||
| map.put("page", QRCODE_PAGE_COUPON); | |||
| map.put("scene", QRCODE_JUMP_CMD_COUPON+":"+id.toString()); | |||
| else if (EnumScreenAdType.CAMPAIGN.getCode().equals(type)) | |||
| map.put("page", QRCODE_PAGE_CAMPGIN); | |||
| map.put("scene", QRCODE_JUMP_CMD_CAMPGIN+":"+id.toString()); | |||
| else | |||
| map.put("page", QRCODE_PAGE_HOME); | |||
| map.put("scene", QRCODE_JUMP_CMD_HOME+":"+"0"); | |||
| map.put("page", QRCODE_PAGE_HOME); | |||
| map.put("width", QRCODE_WIDTH); | |||
| map.put("auto_color", QRCODE_AUTO_COLOR); | |||
| //map.put("line_color", ); | |||
| map.put("is_hyaline", QRCODE_IS_HYALINE); | |||
| //map.put("line_color", ); | |||
| HttpEntity<Map<String,Object>> entity = new HttpEntity<Map<String,Object>>(map, headers); | |||
| String reqUrl =wxacodeunlimit+accessToken; | |||
| RestTemplate restTemplate = new RestTemplate(); | |||
| ResponseEntity<byte[]> responseEntity = restTemplate.postForEntity(reqUrl, entity, byte[].class); | |||
| byte[] result = null; | |||
| if(responseEntity.hasBody()) { | |||
| return responseEntity.getBody(); | |||
| result = responseEntity.getBody(); | |||
| } | |||
| if (result[0]==0xff){ //image | |||
| return result; | |||
| } else { | |||
| logger.error( "QRCODE get error:" + result.toString()); | |||
| return null; | |||
| } | |||
| } | |||
| @@ -25,7 +25,7 @@ | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`name`,`group`,`country`,`province`,`city`,`addr`, | |||
| `total_area`,`operating_area`,`park_area`,`park_place_number`,`service_phone`, | |||
| `img_url`,`img_url_h`, `weap_note`, `img_weapp_qrcode`, `img_wemp_qrcode` | |||
| `img_url`,`img_url_h`, `weap_note`, `img_qrcode_weapp`, `img_qrcode_wemp` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -88,10 +88,10 @@ | |||
| and `img_ur_h` = #{imgUrlH} | |||
| </if> | |||
| <if test=" null != imgWeappQrcode "> | |||
| <if test=" null != imgQrcodeWeapp "> | |||
| and `img_qrcode_weapp` = #{imgQrcodeWeapp} | |||
| </if> | |||
| <if test=" null != imgWempQrcode "> | |||
| <if test=" null != imgQrcodeWemp "> | |||
| and `img_qrcode_wemp` = #{imgQrcodeWemp} | |||
| </if> | |||