| @@ -0,0 +1,94 @@ | |||||
| package com.iformall.controller; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxDevice; | |||||
| import com.iformall.enums.EnumDeviceOnlineStatus; | |||||
| import com.iformall.enums.EnumDeviceStatus; | |||||
| import com.iformall.service.WxDeviceService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxDevice") | |||||
| @Api(description="IOT设备") | |||||
| public class WxDeviceController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxDeviceService wxDeviceService; | |||||
| @ApiOperation("设备列表") | |||||
| @GetMapping("list") | |||||
| @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) { | |||||
| wxDeviceService.listAsPage(wxDevice, pageNum,pageSize); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("添加设备") | |||||
| @PostMapping("add") | |||||
| public Result add(@RequestBody WxDevice wxDevice) { | |||||
| WxDevice record = new WxDevice(); | |||||
| record.setDeviceId(wxDevice.getDeviceId()); | |||||
| record.setStatus(EnumDeviceStatus.VALID.getCode()); | |||||
| List<WxDevice> list = wxDeviceService.findList(record); | |||||
| if (list.size() > 0) | |||||
| return new ResultData(ErrorCode.DEVICE_ALREADY_EXIST); | |||||
| wxDevice.setStatus(EnumDeviceStatus.INIT.getCode()); | |||||
| wxDevice.setOnlineStatus(EnumDeviceOnlineStatus.OFFLINE.getCode()); | |||||
| wxDeviceService.saveOrUpdate(wxDevice); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("更新设备") | |||||
| @PostMapping("update") | |||||
| public Result update(@RequestBody WxDevice wxDevice) { | |||||
| if (wxDevice == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| if (wxDevice.getId() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| wxDeviceService.saveOrUpdate(wxDevice); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("设备详情") | |||||
| @GetMapping("detail") | |||||
| public Result detail(Long id) { | |||||
| if (id == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| WxDevice wxDevice = wxDeviceService.getById(id); | |||||
| if (wxDevice == null) | |||||
| return new ResultData(ErrorCode.SCREENAD_NOT_FOUND); | |||||
| return new ResultData(wxDevice); | |||||
| } | |||||
| @ApiOperation("删除设备") | |||||
| @PostMapping("delete") | |||||
| public Result delete(Long id) { | |||||
| if (id == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| WxDevice wxDevice = new WxDevice(); | |||||
| wxDevice.setId(id); | |||||
| wxDevice.setStatus(EnumDeviceStatus.INVALID.getCode()); | |||||
| wxDeviceService.saveOrUpdate(wxDevice); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,103 @@ | |||||
| package com.iformall.controller; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.WxCampaign; | |||||
| import com.iformall.domain.po.WxScreenAd; | |||||
| import com.iformall.enums.EnumScoreType; | |||||
| import com.iformall.enums.EnumScreenAdStatus; | |||||
| import com.iformall.enums.EnumScreenAdType; | |||||
| import com.iformall.service.WxCampaignService; | |||||
| import com.iformall.service.WxCouponChannelService; | |||||
| import com.iformall.service.WxScreenAdService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("wxScreenAd") | |||||
| @Api(description="问券调查") | |||||
| public class WxScreenAdController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxScreenAdService wxScreenAdService; | |||||
| @Autowired | |||||
| private WxCampaignService wxCampaignService; | |||||
| @Autowired | |||||
| private WxCouponChannelService wxCouponChannelService; | |||||
| @ApiOperation("添加广告") | |||||
| @GetMapping("list") | |||||
| @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) { | |||||
| wxScreenAdService.listAsPage(wxScreenAd,pageNum,pageSize); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("添加广告") | |||||
| @PostMapping("add") | |||||
| public Result add(@RequestBody WxScreenAd wxScreenAd) { | |||||
| wxScreenAd.setStatus(EnumScreenAdStatus.VALID.getCode()); | |||||
| wxScreenAdService.saveOrUpdate(wxScreenAd); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("更新广告") | |||||
| @PostMapping("update") | |||||
| public Result update(@RequestBody WxScreenAd wxScreenAd) { | |||||
| if (wxScreenAd == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| if (wxScreenAd.getId() == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| wxScreenAdService.saveOrUpdate(wxScreenAd); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("广告详情") | |||||
| @GetMapping("detail") | |||||
| public Result detail(Long id) { | |||||
| if (id == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| WxScreenAd wxScreenAd = wxScreenAdService.getById(id); | |||||
| if (wxScreenAd == null) | |||||
| return new ResultData(ErrorCode.SCREENAD_NOT_FOUND); | |||||
| Object target = null; | |||||
| if (wxScreenAd.getType().equals(EnumScreenAdType.COUPON.getCode())) | |||||
| target = wxCouponChannelService.findDetailVo(wxScreenAd.getTargetId()); | |||||
| if (wxScreenAd.getType().equals(EnumScreenAdType.COUPON.getCode())) | |||||
| target = wxCampaignService.getById(wxScreenAd.getTargetId()); | |||||
| wxScreenAd.setTarget(target); | |||||
| return new ResultData(wxScreenAd); | |||||
| } | |||||
| @ApiOperation("删除广告") | |||||
| @PostMapping("delete") | |||||
| public Result delete(Long id) { | |||||
| if (id == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||||
| WxScreenAd wxScreenAd = new WxScreenAd(); | |||||
| wxScreenAd.setId(id); | |||||
| wxScreenAd.setStatus(EnumScreenAdStatus.INVALID.getCode()); | |||||
| wxScreenAdService.saveOrUpdate(wxScreenAd); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -341,6 +341,17 @@ public enum ErrorCode{ | |||||
| * 微信第三方 | * 微信第三方 | ||||
| */ | */ | ||||
| APP_NOT_AUTH(24000, "app未授权"), | APP_NOT_AUTH(24000, "app未授权"), | ||||
| /** | |||||
| * 屏广告 | |||||
| */ | |||||
| SCREENAD_NOT_FOUND(25000, "屏广告未找到"), | |||||
| /** | |||||
| * IOT设备 | |||||
| */ | |||||
| DEVICE_NOT_FOUND(26000, "设备未找到"), | |||||
| DEVICE_ALREADY_EXIST(26001, "设备已经存在"), | |||||
| ; | ; | ||||
| private int code; | private int code; | ||||
| @@ -60,6 +60,14 @@ public class WxDevice implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="版本号信息",name="version") | @io.swagger.annotations.ApiModelProperty(value="版本号信息",name="version") | ||||
| private String version; | private String version; | ||||
| /**设备名**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="设备名",name="name") | |||||
| private String name; | |||||
| /**设备位置**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="设备位置",name="location") | |||||
| private String location; | |||||
| /**创建时间**/ | /**创建时间**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @@ -123,7 +131,23 @@ public class WxDevice implements Serializable { | |||||
| this.version = version; | this.version = version; | ||||
| } | } | ||||
| public Date getCreateDate() { | |||||
| public String getName() { | |||||
| return name; | |||||
| } | |||||
| public void setName(String name) { | |||||
| this.name = name; | |||||
| } | |||||
| public String getLocation() { | |||||
| return location; | |||||
| } | |||||
| public void setLocation(String location) { | |||||
| this.location = location; | |||||
| } | |||||
| public Date getCreateDate() { | |||||
| return createDate; | return createDate; | ||||
| } | } | ||||
| @@ -64,6 +64,13 @@ public class WxScreenAd implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="封面",name="coverImg") | @io.swagger.annotations.ApiModelProperty(value="封面",name="coverImg") | ||||
| private String coverImg; | private String coverImg; | ||||
| /**广告目标ID: couponChannelId or campaignId**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="广告目标ID",name="targetId") | |||||
| private Long targetId; | |||||
| @Transient | |||||
| protected Object target; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -112,6 +119,22 @@ public class WxScreenAd implements Serializable { | |||||
| this.coverImg = coverImg; | this.coverImg = coverImg; | ||||
| } | } | ||||
| public Object getTarget() { | |||||
| return target; | |||||
| } | |||||
| public void setTarget(Object target) { | |||||
| this.target = target; | |||||
| } | |||||
| public Long getTargetId() { | |||||
| return targetId; | |||||
| } | |||||
| public void setTargetId(Long targetId) { | |||||
| this.targetId = targetId; | |||||
| } | |||||
| public static enum Field | public static enum Field | ||||
| { | { | ||||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | ||||
| @@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.po.WxDevice; | import com.iformall.domain.po.WxDevice; | ||||
| import com.iformall.enums.EnumDeviceStatus; | |||||
| import com.iformall.mapper.WxDeviceMapper; | import com.iformall.mapper.WxDeviceMapper; | ||||
| import com.iformall.service.WxDeviceService; | import com.iformall.service.WxDeviceService; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| @@ -37,8 +39,10 @@ public class WxDeviceServiceImpl implements WxDeviceService { | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreateDate(new Date()); | |||||
| wxDeviceMapper.insertSelective(record); | wxDeviceMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| record.setUpdateDate(new Date()); | |||||
| wxDeviceMapper.updateByPrimaryKeySelective(record); | wxDeviceMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| } | } | ||||
| @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| @Service | @Service | ||||
| @@ -34,11 +35,12 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxScreenAd record) { | public void saveOrUpdate(WxScreenAd record) { | ||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreateDate(new Date()); | |||||
| wxScreenAdMapper.insertSelective(record); | wxScreenAdMapper.insertSelective(record); | ||||
| } else { | } else { | ||||
| record.setUpdateDate(new Date()); | |||||
| wxScreenAdMapper.updateByPrimaryKeySelective(record); | wxScreenAdMapper.updateByPrimaryKeySelective(record); | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,6 +6,8 @@ | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | ||||
| <result column="device_id" jdbcType="VARCHAR" property="deviceId"/> | <result column="device_id" jdbcType="VARCHAR" property="deviceId"/> | ||||
| <result column="version" jdbcType="VARCHAR" property="version"/> | <result column="version" jdbcType="VARCHAR" property="version"/> | ||||
| <result column="location" jdbcType="VARCHAR" property="location"/> | |||||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | <result column="type" jdbcType="INTEGER" property="type"/> | ||||
| <result column="status" jdbcType="INTEGER" property="status"/> | <result column="status" jdbcType="INTEGER" property="status"/> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | ||||
| @@ -17,7 +19,7 @@ | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`, `tenant_id`, `device_id`, `type`, `status`, `version`, `create_date`, `update_date`, `online_status`, `first_hb_time`, `last_hb_time`, `hb_cmd` | |||||
| `id`, `tenant_id`, `device_id`, `type`, `status`, `location`, `name`, `version`, `create_date`, `update_date`, `online_status`, `first_hb_time`, `last_hb_time`, `hb_cmd` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -32,7 +34,20 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != deviceId "> | <if test=" null != deviceId "> | ||||
| and `device_id` = #{deviceId} | |||||
| and `device_id` like concat('%', #{deviceId},'%') | |||||
| </if> | |||||
| <if test=" null != version "> | |||||
| and `version` like concat('%', #{version},'%') | |||||
| </if> | |||||
| <if test=" null != location "> | |||||
| and `location` like concat('%', #{location},'%') | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and `name` like concat('%', #{name},'%') | |||||
| </if> | </if> | ||||
| <if test=" null != type "> | <if test=" null != type "> | ||||