|
@ -2,28 +2,27 @@ package com.yihu.jw.base.endpoint.adv;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.base.service.a3service.MedicinedeviceService;
|
|
|
import com.yihu.jw.base.service.advrtisement.AdvertisementLaunchService;
|
|
|
import com.yihu.jw.base.service.advrtisement.AdvrtisementService;
|
|
|
import com.yihu.jw.base.util.ConstantUtils;
|
|
|
import com.yihu.jw.entity.a1entity.Mediicinedevice;
|
|
|
import com.yihu.jw.entity.adv.AdvertisementLaunchDO;
|
|
|
import com.yihu.jw.entity.adv.AdvertisementPuttingAdminDO;
|
|
|
import com.yihu.jw.restmodel.advertisement.AdvertisementPuttingAdminVO;
|
|
|
import com.yihu.jw.restmodel.web.Envelop;
|
|
|
import com.yihu.jw.restmodel.web.ListEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.ObjEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.PageEnvelop;
|
|
|
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
|
|
|
import com.yihu.jw.rm.adv.AdvsementMapping;
|
|
|
|
|
|
import com.yihu.jw.rm.base.BaseRequestMapping;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
|
import org.apache.commons.collections4.IterableUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.List;
|
|
|
|
|
@ -34,7 +33,10 @@ import java.util.List;
|
|
|
public class AdvertisementPuttingAdminEndPoint extends EnvelopRestEndpoint {
|
|
|
@Autowired
|
|
|
AdvrtisementService advrtisementService;
|
|
|
|
|
|
@Autowired
|
|
|
AdvertisementLaunchService launchService;
|
|
|
@Autowired
|
|
|
MedicinedeviceService medicinedeviceService;
|
|
|
|
|
|
@GetMapping(value = AdvsementMapping.AdvsementReusetMapping.DELADVERTISEMENT)
|
|
|
@ApiOperation(value = "删除广告")
|
|
@ -42,37 +44,48 @@ public class AdvertisementPuttingAdminEndPoint extends EnvelopRestEndpoint {
|
|
|
if (id==null||"".equals(id)){
|
|
|
return "请确认该广告是否存在!";
|
|
|
}
|
|
|
System.out.println(id);
|
|
|
String str=advrtisementService.updateDelStatus(id);
|
|
|
System.out.println(str);
|
|
|
return str;
|
|
|
|
|
|
}
|
|
|
// @GetMapping(value = "/single")
|
|
|
// @ApiOperation(value = "获取单条广告信息")
|
|
|
// public Envelop doctorHosplist(
|
|
|
// @ApiParam(name = "id", value = "广告id")
|
|
|
// @RequestParam(value = "id", required = true) String doctorId) throws Exception {
|
|
|
// JSONObject jsonObject = advrtisementService.getOneDoctorInfo(doctorId);
|
|
|
// if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
|
|
|
// return failed(jsonObject.getString("msg"));
|
|
|
// }
|
|
|
// return success(jsonObject.getJSONObject("msg"));
|
|
|
// }
|
|
|
@GetMapping(value = "/single")
|
|
|
@ApiOperation(value = "获取单条广告信息")
|
|
|
public Envelop single(
|
|
|
@ApiParam(name = "id", value = "广告id")
|
|
|
@RequestParam(value = "id", required = true) String id) throws Exception {
|
|
|
JSONObject jsonObject = advrtisementService.getOneAdvInfo(id);
|
|
|
if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
|
|
|
return failed(jsonObject.getString("msg"));
|
|
|
}
|
|
|
return success(jsonObject.getString("msg"),200,jsonObject.getJSONObject("obj"));
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = AdvsementMapping.AdvsementReusetMapping.LAUNCHADVERTISEMENT )
|
|
|
@ApiOperation(value = "投放广告")
|
|
|
public String launchAdvertisement(@RequestParam String id){
|
|
|
if (id==null||"".equals(id)){
|
|
|
return "请确认该广告是否存在!";
|
|
|
public Envelop launchAdvertisement(@ApiParam(name = "advIds",value = "广告id,多个中间用,隔开")
|
|
|
@RequestParam(value = "advIds",required = true) String advIds,
|
|
|
@ApiParam(name = "devIds",value = "设备id,多个中间用,隔开,所有设备不传",required = true)
|
|
|
@RequestParam(value = "ids",required = false)String devIds){
|
|
|
if (StringUtils.isBlank(advIds)){
|
|
|
return failed("请确认该广告是否存在!");
|
|
|
}
|
|
|
return success(advrtisementService.updateLaunchStatus(advIds,devIds));
|
|
|
}
|
|
|
@GetMapping(value = "/unlaunch")
|
|
|
@ApiOperation(value = "取消投放广告")
|
|
|
public Envelop unLaunch(@ApiParam(name = "advIds",value = "广告id,多个中间用,隔开")
|
|
|
@RequestParam(value = "advIds",required = true)String advIds){
|
|
|
if (StringUtils.isBlank(advIds)){
|
|
|
return failed("请确认该广告是否存在!");
|
|
|
}
|
|
|
return advrtisementService.updateLaunchStatus(id);
|
|
|
return success(advrtisementService.unLaunch(advIds));
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = AdvsementMapping.AdvsementReusetMapping.FORBIDDENADVERTISEMENT)
|
|
|
@ApiOperation(value = "禁用广告")
|
|
|
public String forbiddenAdverisement(@RequestParam String id){
|
|
|
public String forbiddenAdvertisement(@RequestParam String id){
|
|
|
if (id==null||"".equals(id)){
|
|
|
return "请确认广告是否存在";
|
|
|
}
|
|
@ -80,30 +93,20 @@ public class AdvertisementPuttingAdminEndPoint extends EnvelopRestEndpoint {
|
|
|
}
|
|
|
|
|
|
@PostMapping(value = AdvsementMapping.AdvsementReusetMapping.SENDADVERTISEMENT)
|
|
|
@ApiOperation(value = "新增广告")
|
|
|
public ObjEnvelop<AdvertisementPuttingAdminVO> sendAdvertisement(
|
|
|
@ApiParam(name = "json_data", value = "Json数据", required = true)
|
|
|
@RequestBody String jsonData) throws Exception {
|
|
|
AdvertisementPuttingAdminDO adminDO=toEntity(jsonData,AdvertisementPuttingAdminDO.class);
|
|
|
advrtisementService.save(adminDO);
|
|
|
return success(adminDO,AdvertisementPuttingAdminVO.class);
|
|
|
@ApiOperation(value = "新增/更新广告")
|
|
|
public Envelop sendAdvertisement(
|
|
|
@ApiParam(name = "jsonData", value = "Json数据", required = true)
|
|
|
@RequestParam String jsonData) throws Exception {
|
|
|
try {
|
|
|
AdvertisementPuttingAdminDO adminDO=advrtisementService.saveAdv(jsonData);
|
|
|
return success("操作成功",adminDO);
|
|
|
} catch (Exception e) {
|
|
|
return failedException(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = AdvsementMapping.AdvsementReusetMapping.UPDATE,consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@ApiOperation(value = "更新广告")
|
|
|
public ObjEnvelop<AdvertisementPuttingAdminVO> update(
|
|
|
@ApiParam(name = "json_data",value = "json数据",required = true)
|
|
|
@RequestBody String jsonData) throws IOException {
|
|
|
AdvertisementPuttingAdminDO adminDO=toEntity(jsonData,AdvertisementPuttingAdminDO.class);
|
|
|
if (null == adminDO.getId()||"".equals(adminDO.getId())) {
|
|
|
return failed("ID不能为空", ObjEnvelop.class);
|
|
|
}
|
|
|
adminDO=advrtisementService.save(adminDO);
|
|
|
return success(adminDO,AdvertisementPuttingAdminVO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = AdvsementMapping.AdvsementReusetMapping.SEL)
|
|
|
@ApiOperation(value = "获取分页")
|
|
|
public PageEnvelop<AdvertisementPuttingAdminVO> page (
|
|
@ -121,34 +124,11 @@ public class AdvertisementPuttingAdminEndPoint extends EnvelopRestEndpoint {
|
|
|
int count = (int)advrtisementService.getCount(filters);
|
|
|
return success(list, count, page, size, AdvertisementPuttingAdminVO.class);
|
|
|
}
|
|
|
// public List<AdvertisementPuttingAdminDO>findLike(
|
|
|
// @ApiParam(name = "title",value = "模糊查询",required = false)
|
|
|
// @RequestParam(value = "title",required = false) String title,
|
|
|
// @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
|
|
|
// @RequestParam(value = "page") int page,
|
|
|
// @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
// @RequestParam(value = "size") int size){
|
|
|
// if (title==null){
|
|
|
// return advrtisementService.findAllAdvertisement((page-1)*size,size);
|
|
|
// }
|
|
|
// return advrtisementService.titleLike(title,(page-1)*size,size);
|
|
|
// }
|
|
|
|
|
|
|
|
|
@GetMapping(value = AdvsementMapping.AdvsementReusetMapping.SELECTLike)
|
|
|
@ApiOperation(value = "获取列表")
|
|
|
// public List<AdvertisementPuttingAdminDO>findLikeCan(
|
|
|
// @ApiParam(name = "title",value = "模糊查询",required = false,defaultValue = "")
|
|
|
// @RequestParam(value = "title",required = false) String title,
|
|
|
// @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
|
|
|
// @RequestParam(value = "page") int page,
|
|
|
// @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
// @RequestParam(value = "size") int size) {
|
|
|
// if (title==null){
|
|
|
// return advrtisementService.findAdvertisementList((page-1)*size,size);
|
|
|
// }
|
|
|
// return advrtisementService.titleLikeAndCan(title,(page-1)*size,size);
|
|
|
// }
|
|
|
public ListEnvelop<AdvertisementPuttingAdminVO> page(
|
|
|
public ListEnvelop<AdvertisementPuttingAdminDO> page(
|
|
|
@ApiParam(name = "fields",value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields",required = false)String fields,
|
|
|
@ApiParam(name = "filters",value = "过滤器,为空检索所有条件")
|
|
@ -156,15 +136,90 @@ public class AdvertisementPuttingAdminEndPoint extends EnvelopRestEndpoint {
|
|
|
@ApiParam(name = "sorts",value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts",required = false)String sorts) throws ParseException {
|
|
|
List<AdvertisementPuttingAdminDO>list=advrtisementService.search(fields,filters,sorts);
|
|
|
return success(list,AdvertisementPuttingAdminVO.class);
|
|
|
return success(list, AdvertisementPuttingAdminDO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/all")
|
|
|
@ApiOperation(value = "获取全部投放信息")
|
|
|
public ListEnvelop<AdvertisementLaunchDO> all(
|
|
|
@ApiParam(name = "fields",value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields",required = false)String fields,
|
|
|
@ApiParam(name = "filters",value = "过滤器,为空检索所有条件")
|
|
|
@RequestParam(name = "filters",required = false)String filters,
|
|
|
@ApiParam(name = "sorts",value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts",required = false)String sorts) throws ParseException{
|
|
|
List<AdvertisementLaunchDO> list=launchService.search(fields, filters, sorts);
|
|
|
return success(list,AdvertisementLaunchDO.class);
|
|
|
}
|
|
|
|
|
|
// @GetMapping(value = "/play")
|
|
|
// @ApiOperation(value = "播放设置")
|
|
|
// public String updatePlay(@ApiParam(value = "play_id")
|
|
|
// @RequestParam(value = "play_id") int playId){
|
|
|
// advrtisementService.updatePlay(playId);
|
|
|
// return "设置成功";
|
|
|
// }
|
|
|
|
|
|
@GetMapping(value = "/allpage")
|
|
|
@ApiOperation(value = "分页查询广告投放设备信息")
|
|
|
public PageEnvelop<AdvertisementLaunchDO> allPage (
|
|
|
@ApiParam(name = "fields", value = "返回的字段,为空返回全部字段")
|
|
|
@RequestParam(value = "fields", required = false) String fields,
|
|
|
@ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
|
|
|
@RequestParam(value = "filters", required = false) String filters,
|
|
|
@ApiParam(name = "sorts", value = "排序,规则参见说明文档")
|
|
|
@RequestParam(value = "sorts", required = false) String sorts,
|
|
|
@ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
|
|
|
@RequestParam(value = "page") int page,
|
|
|
@ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
|
|
|
@RequestParam(value = "size") int size) throws Exception {
|
|
|
List<AdvertisementLaunchDO> list = launchService.search(fields, filters, sorts, page, size);
|
|
|
int count = (int)launchService.getCount(filters);
|
|
|
return success(list, count, page, size, AdvertisementLaunchDO.class);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/one")
|
|
|
@ApiOperation(value = "单条广告投放到的全部设备")
|
|
|
public ListEnvelop<AdvertisementLaunchDO> one(
|
|
|
@ApiParam(name = "advId",value = "广告id")
|
|
|
@RequestParam(value = "advId",required = true)String advId){
|
|
|
List<AdvertisementLaunchDO> list=launchService.one(advId);
|
|
|
if (list==null||list.size()==0){
|
|
|
return failedListEnvelopException(new Exception("请查看广告ID是否正确"));
|
|
|
}
|
|
|
return success("获取单条广告投放设备成功",list);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/open/info")
|
|
|
@ApiOperation(value = "获取单个设备上的所有广告")
|
|
|
public ListEnvelop<AdvertisementLaunchDO>solo(
|
|
|
@ApiParam(name = "machineCode",value = "设备编码")
|
|
|
@RequestParam(value = "machineCode",required = true)String machineCode){
|
|
|
return success(launchService.solo(machineCode));
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/info")
|
|
|
@ApiOperation(value = "获取单个设备上的所有广告明细")
|
|
|
public Envelop info(
|
|
|
@ApiParam(name = "devId",value = "设备id")
|
|
|
@RequestParam(value = "devId",required = true)String devId){
|
|
|
List<AdvertisementPuttingAdminDO>list=launchService.info(devId);
|
|
|
if (list==null||list.size()==0){
|
|
|
return failed("该设备没有广告或者该设备id不存在");
|
|
|
}
|
|
|
return success("获取单个设备上所有广告明细成功",list);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/devinfo")
|
|
|
@ApiOperation(value = "获取单条广告投放的所有设备明细")
|
|
|
public Envelop devInfo(@ApiParam(name = "advId",value = "广告id")
|
|
|
@RequestParam(value = "advId",required = true)String advId) {
|
|
|
List<AdvertisementLaunchDO> list = launchService.one(advId);
|
|
|
if (list==null||list.size()==0){
|
|
|
return failed("该广告未投放或者广告id错误");
|
|
|
}
|
|
|
List<Mediicinedevice> mediicinedeviceList=launchService.devInfo(advId);
|
|
|
return success("获取单条广告所有投放设备明细成功",mediicinedeviceList);
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "selectdev")
|
|
|
@ApiOperation(value = "投放广告可选择的设备")
|
|
|
public ListEnvelop<Mediicinedevice> selectDev(){
|
|
|
Iterable<Mediicinedevice> iterable=medicinedeviceService.findAll();
|
|
|
List<Mediicinedevice> list= IterableUtils.toList(iterable);
|
|
|
return success("所有设备获取成功",list);
|
|
|
}
|
|
|
}
|