Commit 9189e722 by weijiguang

添加错误日志

parent bff74782
......@@ -13,6 +13,8 @@ import java.util.List;
* @date 2022-04-28
*/
public interface SysBannerMapper {
SysBanner getBannerById(Long bannerId);
List<SysBanner> selectBanner(BannerListPo banner);
Long createBanner(SysBanner banner);
......
package com.soss.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.soss.common.exception.ServiceException;
import com.soss.common.utils.StringUtils;
import com.soss.system.domain.Shop;
......@@ -7,6 +8,8 @@ import com.soss.system.domain.SysBanner;
import com.soss.system.domain.po.BannerListPo;
import com.soss.system.domain.po.BannerPo;
import com.soss.system.domain.vo.BannerVo;
import com.soss.system.domain.vo.PushBean;
import com.soss.system.jiguang.JiGuangPushService;
import com.soss.system.mapper.ShopMapper;
import com.soss.system.mapper.SysBannerMapper;
import com.soss.system.service.ISysBannerService;
......@@ -38,6 +41,8 @@ public class SysBannerServiceImpl implements ISysBannerService {
private ShopMapper shopMapper;
@Autowired
private AreaUtil areaUtil;
@Autowired
private JiGuangPushService jiGuangPushService;
@Override
public List<SysBanner> selectBanner(BannerListPo banner) {
......@@ -70,6 +75,14 @@ public class SysBannerServiceImpl implements ISysBannerService {
banner.setUpdatedAt(new Date());
banner.setState(0);
long i = sysBannerMapper.createBanner(banner);
try {
if (banner.getType() == 2) {
pushBannerChanged();
}
} catch (Exception e) {
e.printStackTrace();
}
return banner.getId();
}
......@@ -99,11 +112,27 @@ public class SysBannerServiceImpl implements ISysBannerService {
}
banner.setUpdatedAt(new Date());
long i = sysBannerMapper.updateBanner(banner);
try {
if (banner.getType() == 2) {
pushBannerChanged();
}
} catch (Exception e) {
e.printStackTrace();
}
return i > 0 ? true : false;
}
private void pushBannerChanged() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("action", "BANNER_CHANGED");
jsonObject.put("timestamp", System.currentTimeMillis());
PushBean pushBean = new PushBean();
pushBean.setMessageCount(jsonObject);
jiGuangPushService.pushAll(pushBean);
}
private SysBanner copyBanner(BannerPo bannerPo) {
SysBanner banner = new SysBanner();
banner.setId(bannerPo.getId());
......@@ -218,12 +247,29 @@ public class SysBannerServiceImpl implements ISysBannerService {
}
long i = sysBannerMapper.updateState(banner);
try {
SysBanner sysBanner = sysBannerMapper.getBannerById(bannerId);
if (sysBanner.getType() == 2) {
pushBannerChanged();
}
} catch (Exception e) {
e.printStackTrace();
}
return i > 0 ? true : false;
}
@Override
public Boolean delete(Long bannerId) {
long i = sysBannerMapper.delete(bannerId);
try {
SysBanner sysBanner = sysBannerMapper.getBannerById(bannerId);
if (sysBanner.getType() == 2) {
pushBannerChanged();
}
} catch (Exception e) {
e.printStackTrace();
}
return i > 0 ? true : false;
}
......
......@@ -19,6 +19,10 @@
<result property="updatedAt" column="updated_at"/>
</resultMap>
<select id="getBannerById" resultMap="BannerResult" >
select * from sys_banner where id = #{bannerId}
</select>
<select id="selectBanner" resultMap="BannerResult" parameterType="BannerListPo">
select * from sys_banner
<where>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment