|
@ -38,35 +38,37 @@ public class AdvrtisementService extends BaseJpaService<AdvertisementPuttingAdmi
|
|
|
MediicineDeviceDao deviceDao;
|
|
|
//按照分页查询
|
|
|
|
|
|
public List<AdvertisementPuttingAdminDO>findAllAdvertisement(int page, int size){
|
|
|
public List<AdvertisementPuttingAdminDO> findAllAdvertisement(int page, int size) {
|
|
|
return advertisementPuttingAdminDAO.findAdvertisementPuttingAdminUtilsByUpdateTime(page, size);
|
|
|
}
|
|
|
|
|
|
//可投放的广告
|
|
|
public List<AdvertisementPuttingAdminDO> findAdvertisementList(int page, int size){
|
|
|
public List<AdvertisementPuttingAdminDO> findAdvertisementList(int page, int size) {
|
|
|
return advertisementPuttingAdminDAO.findAdvertisementPuttingAdminUtilsByDelStatusAndLaunchStatusAndForbiddenStatus(page, size);
|
|
|
}
|
|
|
|
|
|
//根据title模糊分页查询
|
|
|
//所有广告
|
|
|
public List<AdvertisementPuttingAdminDO>titleLike(String title, int page, int size){
|
|
|
public List<AdvertisementPuttingAdminDO> titleLike(String title, int page, int size) {
|
|
|
return advertisementPuttingAdminDAO.findAdvertisementSByLike(title, page, size);
|
|
|
}
|
|
|
|
|
|
//可投放的广告
|
|
|
public List<AdvertisementPuttingAdminDO>titleLikeAndCan(String title, int page, int size){
|
|
|
public List<AdvertisementPuttingAdminDO> titleLikeAndCan(String title, int page, int size) {
|
|
|
return advertisementPuttingAdminDAO.findAdvertisementsCanByLike(title, page, size);
|
|
|
}
|
|
|
|
|
|
//删除
|
|
|
@Transactional
|
|
|
public String updateDelStatus(String id){
|
|
|
if (advertisementExist(id)==null){
|
|
|
public String updateDelStatus(String id) {
|
|
|
if (advertisementExist(id) == null) {
|
|
|
return "广告不存在!";
|
|
|
}
|
|
|
if (advertisementExist(id).getDel()==0) {
|
|
|
if (advertisementExist(id).getDel() == 0) {
|
|
|
advertisementPuttingAdminDAO.delete(id);
|
|
|
launchDAO.deleteByAdvId(id);
|
|
|
return "删除成功";
|
|
|
}else {
|
|
|
} else {
|
|
|
advertisementPuttingAdminDAO.delete(id);
|
|
|
return "广告恢复成功";
|
|
|
}
|
|
@ -74,11 +76,11 @@ public class AdvrtisementService extends BaseJpaService<AdvertisementPuttingAdmi
|
|
|
}
|
|
|
|
|
|
//投放
|
|
|
public String updateLaunchStatus(String advIds, String devIds){
|
|
|
public String updateLaunchStatus(String advIds, String devIds) {
|
|
|
List<AdvertisementLaunchDO> list = new ArrayList<>();
|
|
|
AdvertisementLaunchDO launchDO;
|
|
|
String[] strings=advIds.split(",");
|
|
|
if (devIds!=null) {
|
|
|
String[] strings = advIds.split(",");
|
|
|
if (devIds != null) {
|
|
|
String[] str = devIds.split(",");
|
|
|
for (int i = 0; i < strings.length; i++) {
|
|
|
if (advertisementExist(strings[i]) == null) {
|
|
@ -94,28 +96,28 @@ public class AdvrtisementService extends BaseJpaService<AdvertisementPuttingAdmi
|
|
|
launchDO = new AdvertisementLaunchDO();
|
|
|
launchDO.setAdvId(strings[i]);
|
|
|
launchDO.setDevId(str[j]);
|
|
|
Iterable <AdvertisementLaunchDO> iterable=launchDAO.findByAdvIdAndDevId(strings[i],str[j]);
|
|
|
List<AdvertisementLaunchDO> list1=IterableUtils.toList(iterable);
|
|
|
if (list1==null||list1.size()==0) {
|
|
|
Iterable<AdvertisementLaunchDO> iterable = launchDAO.findByAdvIdAndDevId(strings[i], str[j]);
|
|
|
List<AdvertisementLaunchDO> list1 = IterableUtils.toList(iterable);
|
|
|
if (list1 == null || list1.size() == 0) {
|
|
|
list.add(launchDO);
|
|
|
}
|
|
|
}
|
|
|
advertisementPuttingAdminDAO.updateLaunStatusTo1(strings[i]);
|
|
|
}
|
|
|
for (int i = 0; i <list.size() ; i++) {
|
|
|
for (int j = 1; j <list.size() ; j++) {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
for (int j = 1; j < list.size(); j++) {
|
|
|
if (list.get(i).getAdvId().equals(list.get(j).getAdvId())
|
|
|
&& list.get(i).getDevId().equals(list.get(j).getDevId())){
|
|
|
&& list.get(i).getDevId().equals(list.get(j).getDevId())) {
|
|
|
list.remove(list.get(j));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
launchDAO.save(list);
|
|
|
}else {
|
|
|
} else {
|
|
|
Iterable<Mediicinedevice> iterable = deviceDao.findAll();
|
|
|
List<Mediicinedevice> mediicinedevices=IterableUtils.toList(iterable);
|
|
|
for (int i = 0; i <mediicinedevices.size() ; i++) {
|
|
|
for (int j = 0; j <strings.length ; j++) {
|
|
|
List<Mediicinedevice> mediicinedevices = IterableUtils.toList(iterable);
|
|
|
for (int i = 0; i < mediicinedevices.size(); i++) {
|
|
|
for (int j = 0; j < strings.length; j++) {
|
|
|
launchDO = new AdvertisementLaunchDO();
|
|
|
launchDO.setDevId(mediicinedevices.get(i).getId());
|
|
|
launchDO.setAdvId(strings[j]);
|
|
@ -129,19 +131,19 @@ public class AdvrtisementService extends BaseJpaService<AdvertisementPuttingAdmi
|
|
|
|
|
|
//禁用
|
|
|
@Transactional
|
|
|
public String updateForbiddenStatus(String id){
|
|
|
if (advertisementExist(id)==null){
|
|
|
public String updateForbiddenStatus(String id) {
|
|
|
if (advertisementExist(id) == null) {
|
|
|
return "广告不存在";
|
|
|
}
|
|
|
if (advertisementExist(id).getDel()==1){
|
|
|
if (advertisementExist(id).getDel() == 1) {
|
|
|
return "广告已删除";
|
|
|
}
|
|
|
if (advertisementExist(id).getForbidden()==0) {
|
|
|
// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
if (advertisementExist(id).getForbidden() == 0) {
|
|
|
// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
advertisementPuttingAdminDAO.updateForbiddenStatusTo1(id);
|
|
|
launchDAO.deleteByAdvId(id);
|
|
|
return "广告已禁用";
|
|
|
}else {
|
|
|
} else {
|
|
|
advertisementPuttingAdminDAO.updateForbiddenStatus(id);
|
|
|
return "广告已解禁";
|
|
|
}
|
|
@ -153,108 +155,108 @@ public class AdvrtisementService extends BaseJpaService<AdvertisementPuttingAdmi
|
|
|
// }
|
|
|
|
|
|
|
|
|
private AdvertisementPuttingAdminDO advertisementExist(String id){
|
|
|
AdvertisementPuttingAdminDO advertisementPuttingAdminDO=advertisementPuttingAdminDAO.findAdvertisementPuttingAdminDOById(id);
|
|
|
if (advertisementPuttingAdminDO==null){
|
|
|
private AdvertisementPuttingAdminDO advertisementExist(String id) {
|
|
|
AdvertisementPuttingAdminDO advertisementPuttingAdminDO = advertisementPuttingAdminDAO.findAdvertisementPuttingAdminDOById(id);
|
|
|
if (advertisementPuttingAdminDO == null) {
|
|
|
return null;
|
|
|
}
|
|
|
return advertisementPuttingAdminDO;
|
|
|
}
|
|
|
|
|
|
public JSONObject getOneAdvInfo(String id) throws Exception{
|
|
|
public JSONObject getOneAdvInfo(String id) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
if(StringUtils.isEmpty(id)){
|
|
|
result.put("msg","parameter id is null ");
|
|
|
if (StringUtils.isEmpty(id)) {
|
|
|
result.put("msg", "parameter id is null ");
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
AdvertisementPuttingAdminDO adminDO = advertisementPuttingAdminDAO.findOne(id);
|
|
|
if(null == adminDO){
|
|
|
result.put("msg","广告不存在:" + id);
|
|
|
if (null == adminDO) {
|
|
|
result.put("msg", "广告不存在:" + id);
|
|
|
result.put("response", ConstantUtils.FAIL);
|
|
|
return result;
|
|
|
}
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("categoryCode",adminDO.getCategoryCode());
|
|
|
jsonObject.put("categoryName",adminDO.getCategoryName());
|
|
|
jsonObject.put("id",id);
|
|
|
jsonObject.put("url",adminDO.getUrl());
|
|
|
jsonObject.put("del",adminDO.getDel());
|
|
|
jsonObject.put("launch",adminDO.getLaunch());
|
|
|
jsonObject.put("forbidden",adminDO.getForbidden());
|
|
|
jsonObject.put("title",adminDO.getTitle());
|
|
|
jsonObject.put("createTime",DateUtil.dateToStrLong(adminDO.getCreateTime()));
|
|
|
jsonObject.put("createUser",adminDO.getCreateUser());
|
|
|
jsonObject.put("updateTime",DateUtil.dateToStrLong(adminDO.getUpdateTime()));
|
|
|
jsonObject.put("updateUser",adminDO.getUpdateUser());
|
|
|
jsonObject.put("publishLocation",adminDO.getPublishLocation());
|
|
|
jsonObject.put("categoryCode", adminDO.getCategoryCode());
|
|
|
jsonObject.put("categoryName", adminDO.getCategoryName());
|
|
|
jsonObject.put("id", id);
|
|
|
jsonObject.put("url", adminDO.getUrl());
|
|
|
jsonObject.put("del", adminDO.getDel());
|
|
|
jsonObject.put("launch", adminDO.getLaunch());
|
|
|
jsonObject.put("forbidden", adminDO.getForbidden());
|
|
|
jsonObject.put("title", adminDO.getTitle());
|
|
|
jsonObject.put("createTime", DateUtil.dateToStrLong(adminDO.getCreateTime()));
|
|
|
jsonObject.put("createUser", adminDO.getCreateUser());
|
|
|
jsonObject.put("updateTime", DateUtil.dateToStrLong(adminDO.getUpdateTime()));
|
|
|
jsonObject.put("updateUser", adminDO.getUpdateUser());
|
|
|
jsonObject.put("publishLocation", adminDO.getPublishLocation());
|
|
|
if (adminDO.getPublishLocation() != null) {
|
|
|
if ("0".equals(adminDO.getPublishLocation())) {
|
|
|
jsonObject.put("publishLocationName","广告位");
|
|
|
jsonObject.put("publishLocationName", "广告位");
|
|
|
} else if ("1".equals(adminDO.getPublishLocation())) {
|
|
|
jsonObject.put("publishLocationName","banner位");
|
|
|
jsonObject.put("publishLocationName", "banner位");
|
|
|
} else if ("2".equals(adminDO.getPublishLocation())) {
|
|
|
jsonObject.put("publishLocationName","动态列表");
|
|
|
jsonObject.put("publishLocationName", "动态列表");
|
|
|
}
|
|
|
}
|
|
|
jsonObject.put("launchDevice",adminDO.getLaunchDevice());
|
|
|
jsonObject.put("sort",adminDO.getSort());
|
|
|
jsonObject.put("linkUrl",adminDO.getLinkUrl());
|
|
|
jsonObject.put("content",adminDO.getContent());
|
|
|
jsonObject.put("launchDevice", adminDO.getLaunchDevice());
|
|
|
jsonObject.put("sort", adminDO.getSort());
|
|
|
jsonObject.put("linkUrl", adminDO.getLinkUrl());
|
|
|
jsonObject.put("content", adminDO.getContent());
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
result.put("msg","查询单条明细成功");
|
|
|
result.put("obj",jsonObject);
|
|
|
result.put("msg", "查询单条明细成功");
|
|
|
result.put("obj", jsonObject);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public AdvertisementPuttingAdminDO saveAdv(String jsonData) throws Exception{
|
|
|
AdvertisementPuttingAdminDO advertisementPuttingAdminDO= EntityUtils.jsonToEntity(jsonData, AdvertisementPuttingAdminDO.class);
|
|
|
if (!StringUtils.isNotBlank(advertisementPuttingAdminDO.getId())){
|
|
|
advertisementPuttingAdminDO.setId(UUID.randomUUID().toString().replace("-",""));
|
|
|
public AdvertisementPuttingAdminDO saveAdv(String jsonData) throws Exception {
|
|
|
AdvertisementPuttingAdminDO advertisementPuttingAdminDO = EntityUtils.jsonToEntity(jsonData, AdvertisementPuttingAdminDO.class);
|
|
|
if (!StringUtils.isNotBlank(advertisementPuttingAdminDO.getId())) {
|
|
|
advertisementPuttingAdminDO.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
advertisementPuttingAdminDO.setCreateTime(new Date());
|
|
|
advertisementPuttingAdminDO.setDel(0);
|
|
|
advertisementPuttingAdminDO.setForbidden(0);
|
|
|
advertisementPuttingAdminDO.setLaunch(0);
|
|
|
UserDO userDO=userDao.findById(advertisementPuttingAdminDO.getCreateUser());
|
|
|
if (userDO!=null){
|
|
|
UserDO userDO = userDao.findById(advertisementPuttingAdminDO.getCreateUser());
|
|
|
if (userDO != null) {
|
|
|
advertisementPuttingAdminDO.setCategoryName(userDO.getName());
|
|
|
advertisementPuttingAdminDO.setUpdateUserName(userDO.getName());
|
|
|
}
|
|
|
if (advertisementPuttingAdminDO.getCategoryCode()==1){
|
|
|
if (advertisementPuttingAdminDO.getCategoryCode() == 1) {
|
|
|
advertisementPuttingAdminDO.setCategoryCode(1);
|
|
|
advertisementPuttingAdminDO.setCategoryName("视频");
|
|
|
}else if (advertisementPuttingAdminDO.getCategoryCode()==2){
|
|
|
} else if (advertisementPuttingAdminDO.getCategoryCode() == 2) {
|
|
|
advertisementPuttingAdminDO.setCategoryCode(2);
|
|
|
advertisementPuttingAdminDO.setCategoryName("图片");
|
|
|
}
|
|
|
advertisementPuttingAdminDO=advertisementPuttingAdminDAO.save(advertisementPuttingAdminDO);
|
|
|
advertisementPuttingAdminDO = advertisementPuttingAdminDAO.save(advertisementPuttingAdminDO);
|
|
|
return advertisementPuttingAdminDO;
|
|
|
}else {
|
|
|
AdvertisementPuttingAdminDO one=advertisementPuttingAdminDAO.findOne(advertisementPuttingAdminDO.getId());
|
|
|
} else {
|
|
|
AdvertisementPuttingAdminDO one = advertisementPuttingAdminDAO.findOne(advertisementPuttingAdminDO.getId());
|
|
|
one.setTitle(advertisementPuttingAdminDO.getTitle());
|
|
|
one.setUrl(advertisementPuttingAdminDO.getUrl());
|
|
|
one.setUpdateTime(new Date());
|
|
|
one.setCategoryCode(advertisementPuttingAdminDO.getCategoryCode());
|
|
|
one.setCategoryName(advertisementPuttingAdminDO.getCategoryCode()==1?"视频":"图片");
|
|
|
one.setCategoryName(advertisementPuttingAdminDO.getCategoryCode() == 1 ? "视频" : "图片");
|
|
|
if (!"0".equals(advertisementPuttingAdminDO.getPublishLocation())) {
|
|
|
one.setLinkUrl(advertisementPuttingAdminDO.getLinkUrl());
|
|
|
one.setContent(advertisementPuttingAdminDO.getContent());
|
|
|
}
|
|
|
advertisementPuttingAdminDAO.save(one);
|
|
|
return one;
|
|
|
return one;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public String unLaunch(String advIds) {
|
|
|
String[] str=advIds.split(",");
|
|
|
for (int i = 0; i <str.length ; i++) {
|
|
|
String[] str = advIds.split(",");
|
|
|
for (int i = 0; i < str.length; i++) {
|
|
|
launchDAO.deleteByAdvId(str[i]);
|
|
|
}
|
|
|
return "已取消投放";
|
|
|
}
|
|
|
|
|
|
public JSONObject getAdvrtisementByPage(String title, Integer publishLocation, Integer categoryCode, Integer launchDevice, String sorts, int page, int size) throws Exception {
|
|
|
public JSONObject getAdvrtisementByPage(String title, Integer publishLocation, Integer categoryCode, Integer launchDevice, Boolean isShow, String sorts, int page, int size) throws Exception {
|
|
|
JSONObject result = new JSONObject();
|
|
|
String countSql = "select count(a.id)";
|
|
|
String sql = "SELECT " +
|
|
@ -278,41 +280,42 @@ public class AdvrtisementService extends BaseJpaService<AdvertisementPuttingAdmi
|
|
|
"a.update_user as updateUser, " +
|
|
|
"a.update_user_name as updateUserName, " +
|
|
|
"a.play_id as playId ";
|
|
|
String from = "FROM " +
|
|
|
String from = "FROM " +
|
|
|
"advertisement_putting_admin AS a " +
|
|
|
"WHERE 1=1 AND a.forbidden = 0";
|
|
|
if (!StringUtils.isEmpty(title)){
|
|
|
"WHERE 1=1";
|
|
|
from += isShow ? "" : " AND a.forbidden = 0";
|
|
|
if (!StringUtils.isEmpty(title)) {
|
|
|
from += " and a.title LIKE '%" + title + "%'";
|
|
|
}
|
|
|
if (publishLocation!=null){
|
|
|
from+=" and a.publish_location = " + publishLocation;
|
|
|
if (publishLocation != null) {
|
|
|
from += " and a.publish_location = " + publishLocation;
|
|
|
}
|
|
|
if (categoryCode!=null){
|
|
|
from+=" and a.category_code = "+categoryCode;
|
|
|
if (categoryCode != null) {
|
|
|
from += " and a.category_code = " + categoryCode;
|
|
|
}
|
|
|
if (launchDevice!=null){
|
|
|
from+=" and a.launch_device = " + launchDevice;
|
|
|
if (launchDevice != null) {
|
|
|
from += " and a.launch_device = " + launchDevice;
|
|
|
}
|
|
|
String orderBy = " ORDER BY a.sort,a.create_time limit "+(page-1)*size+","+size;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+from+orderBy);
|
|
|
String orderBy = " ORDER BY a.sort,a.create_time limit " + (page - 1) * size + "," + size;
|
|
|
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql + from + orderBy);
|
|
|
for (Map<String, Object> stringObjectMap : list) {
|
|
|
String publishLocationCode = stringObjectMap.get("publishLocation").toString();
|
|
|
if (publishLocationCode != null) {
|
|
|
if ("0".equals(publishLocationCode)) {
|
|
|
stringObjectMap.put("publishLocationName","广告位");
|
|
|
stringObjectMap.put("publishLocationName", "广告位");
|
|
|
} else if ("1".equals(publishLocationCode)) {
|
|
|
stringObjectMap.put("publishLocationName","banner位");
|
|
|
stringObjectMap.put("publishLocationName", "banner位");
|
|
|
} else if ("2".equals(publishLocationCode)) {
|
|
|
stringObjectMap.put("publishLocationName","动态列表");
|
|
|
stringObjectMap.put("publishLocationName", "动态列表");
|
|
|
}
|
|
|
}
|
|
|
Date createTime = (Date) stringObjectMap.get("createTime");
|
|
|
stringObjectMap.put("createTime",DateUtil.dateToStrLong(createTime));
|
|
|
stringObjectMap.put("createTime", DateUtil.dateToStrLong(createTime));
|
|
|
Date updateTime = (Date) stringObjectMap.get("updateTime");
|
|
|
stringObjectMap.put("updateTime",DateUtil.dateToStrLong(updateTime));
|
|
|
stringObjectMap.put("updateTime", DateUtil.dateToStrLong(updateTime));
|
|
|
}
|
|
|
Long count = jdbcTemplate.queryForObject(countSql+from,Long.class);
|
|
|
result.put("count",count);
|
|
|
Long count = jdbcTemplate.queryForObject(countSql + from, Long.class);
|
|
|
result.put("count", count);
|
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
|
return result;
|
|
|
}
|