diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxDeviceController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxDeviceController.java new file mode 100644 index 000000000..9727b4333 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxDeviceController.java @@ -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 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(); + } + +} diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxScreenAdController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxScreenAdController.java new file mode 100644 index 000000000..9fd0ffc3f --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxScreenAdController.java @@ -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(); + } + +} diff --git a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java index de815705a..53c341e8b 100644 --- a/mallinkService/src/main/java/com/iformall/common/ErrorCode.java +++ b/mallinkService/src/main/java/com/iformall/common/ErrorCode.java @@ -341,6 +341,17 @@ public enum ErrorCode{ * 微信第三方 */ APP_NOT_AUTH(24000, "app未授权"), + + /** + * 屏广告 + */ + SCREENAD_NOT_FOUND(25000, "屏广告未找到"), + + /** + * IOT设备 + */ + DEVICE_NOT_FOUND(26000, "设备未找到"), + DEVICE_ALREADY_EXIST(26001, "设备已经存在"), ; private int code; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxDevice.java b/mallinkService/src/main/java/com/iformall/domain/po/WxDevice.java index 03ff7f056..b05665b3b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxDevice.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxDevice.java @@ -60,6 +60,14 @@ public class WxDevice implements Serializable { @io.swagger.annotations.ApiModelProperty(value="版本号信息",name="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") private Date createDate; @@ -123,7 +131,23 @@ public class WxDevice implements Serializable { 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; } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxScreenAd.java b/mallinkService/src/main/java/com/iformall/domain/po/WxScreenAd.java index 46e5e6e77..6a75bbe79 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxScreenAd.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxScreenAd.java @@ -64,6 +64,13 @@ public class WxScreenAd implements Serializable { @io.swagger.annotations.ApiModelProperty(value="封面",name="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() { return tenantId; } @@ -112,6 +119,22 @@ public class WxScreenAd implements Serializable { 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 { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxDeviceServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxDeviceServiceImpl.java index 63f2b0b14..e7a1d993c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxDeviceServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxDeviceServiceImpl.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; import com.iformall.common.IdWorker; import com.iformall.domain.po.WxDevice; +import com.iformall.enums.EnumDeviceStatus; import com.iformall.mapper.WxDeviceMapper; import com.iformall.service.WxDeviceService; import org.slf4j.Logger; @@ -12,6 +13,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; @@ -37,8 +39,10 @@ public class WxDeviceServiceImpl implements WxDeviceService { if (record.getId() == null) { final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); + record.setCreateDate(new Date()); wxDeviceMapper.insertSelective(record); } else { + record.setUpdateDate(new Date()); wxDeviceMapper.updateByPrimaryKeySelective(record); } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScreenAdServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScreenAdServiceImpl.java index b6f58b0db..43cdfcab5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScreenAdServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScreenAdServiceImpl.java @@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Date; import java.util.List; @Service @@ -34,11 +35,12 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { @Override public void saveOrUpdate(WxScreenAd record) { if (record.getId() == null) { - //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); record.setId(idWorker.nextId()); + record.setCreateDate(new Date()); wxScreenAdMapper.insertSelective(record); } else { + record.setUpdateDate(new Date()); wxScreenAdMapper.updateByPrimaryKeySelective(record); } } diff --git a/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml b/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml index 079dda52a..9ffd1ab24 100644 --- a/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxDeviceMapper.xml @@ -6,6 +6,8 @@ + + @@ -17,7 +19,7 @@ - `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` @@ -32,7 +34,20 @@ - and `device_id` = #{deviceId} + and `device_id` like concat('%', #{deviceId},'%') + + + + and `version` like concat('%', #{version},'%') + + + + and `location` like concat('%', #{location},'%') + + + + and `name` like concat('%', #{name},'%') +