修改一些bug
This commit is contained in:
@ -9,12 +9,14 @@
|
||||
package co.yixiang.modules.wechat.rest;
|
||||
import java.util.Arrays;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
import co.yixiang.modules.wechat.service.WxMaLiveGoodsService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import co.yixiang.logging.aop.log.Log;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatLiveGoods;
|
||||
import co.yixiang.modules.wechat.service.YxWechatLiveGoodsService;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsQueryCriteria;
|
||||
import co.yixiang.modules.wechat.service.dto.YxWechatLiveGoodsDto;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -37,7 +39,7 @@ public class YxWechatLiveGoodsController {
|
||||
|
||||
private final YxWechatLiveGoodsService yxWechatLiveGoodsService;
|
||||
private final IGenerator generator;
|
||||
|
||||
private final WxMaLiveGoodsService wxMaLiveGoodsService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@ -68,7 +70,7 @@ public class YxWechatLiveGoodsController {
|
||||
@ApiOperation("修改yxWechatLiveGoods")
|
||||
@PreAuthorize("@el.check('admin','yxWechatLiveGoods:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody YxWechatLiveGoods resources){
|
||||
yxWechatLiveGoodsService.updateById(resources);
|
||||
yxWechatLiveGoodsService.updategoods(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ -78,7 +80,7 @@ public class YxWechatLiveGoodsController {
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||
Arrays.asList(ids).forEach(id->{
|
||||
yxWechatLiveGoodsService.removeById(id);
|
||||
yxWechatLiveGoodsService.removegoods(id);
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
@ -49,4 +49,8 @@ public interface YxWechatLiveGoodsService extends BaseService<YxWechatLiveGoods
|
||||
boolean saveGoods(YxWechatLiveGoods resources);
|
||||
|
||||
boolean synchroWxOlLive(List<Integer> goodsIds);
|
||||
|
||||
void removegoods(Long id);
|
||||
|
||||
void updategoods(YxWechatLiveGoods resources);
|
||||
}
|
||||
|
@ -20,11 +20,15 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@Data
|
||||
public class YxWechatLiveDto implements Serializable {
|
||||
|
||||
|
||||
|
||||
/** 直播间id */
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long roomid;
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 直播间标题 */
|
||||
private String name;
|
||||
|
||||
|
@ -20,6 +20,9 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@Data
|
||||
public class YxWechatLiveGoodsDto implements Serializable {
|
||||
|
||||
|
||||
private Long id;
|
||||
|
||||
/** 直播商品id */
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
|
@ -9,6 +9,7 @@
|
||||
package co.yixiang.modules.wechat.service.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
@ -87,13 +88,50 @@ public class YxWechatLiveGoodsServiceImpl extends BaseServiceImpl<YxWechatLiveGo
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removegoods(Long id) {
|
||||
this.removeById(id);
|
||||
try {
|
||||
wxMaLiveGoodsService.deleteGoods(id.intValue());
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updategoods(YxWechatLiveGoods resources) {
|
||||
YxWechatLiveGoods wechatLiveGoods = this.getById(resources.getGoodsId());
|
||||
try {
|
||||
WxMaService wxMaService = WxMaConfiguration.getWxMaService();
|
||||
if(ObjectUtil.isNotEmpty(wechatLiveGoods)){
|
||||
/** 审核状态 0:未审核,1:审核中,2:审核通过,3审核失败 */
|
||||
if("2".equals(wechatLiveGoods.getAuditStatus())){
|
||||
}else if("0".equals(wechatLiveGoods.getAuditStatus())){
|
||||
resources.setCoverImgUrl(uploadPhotoToWx(wxMaService,resources.getCoverImgeUrl()).getMediaId());
|
||||
}else if("1".equals(wechatLiveGoods.getAuditStatus())){
|
||||
throw new BadRequestException("商品审核中不允许修改");
|
||||
}
|
||||
}
|
||||
WxMaLiveInfo.Goods goods = generator.convert(resources, WxMaLiveInfo.Goods.class);
|
||||
boolean wxMaLiveResult = wxMaLiveGoodsService.updateGoods(goods);
|
||||
this.saveOrUpdate(resources);
|
||||
} catch (WxErrorException e) {
|
||||
throw new BadRequestException(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Cacheable
|
||||
public Map<String, Object> queryAll(YxWechatLiveGoodsQueryCriteria criteria, Pageable pageable) {
|
||||
getPage(pageable);
|
||||
PageInfo<YxWechatLiveGoods> page = new PageInfo<>(queryAll(criteria));
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
map.put("content", generator.convert(page.getList(), YxWechatLiveGoodsDto.class));
|
||||
List<YxWechatLiveGoodsDto> goodsDtos = generator.convert(page.getList(), YxWechatLiveGoodsDto.class);
|
||||
goodsDtos.forEach(i ->{
|
||||
i.setId(i.getGoodsId());
|
||||
});
|
||||
map.put("content",goodsDtos);
|
||||
map.put("totalElements", page.getTotal());
|
||||
return map;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ package co.yixiang.modules.wechat.service.impl;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import co.yixiang.exception.BadRequestException;
|
||||
import co.yixiang.modules.wechat.domain.YxWechatLive;
|
||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||
import co.yixiang.dozer.service.IGenerator;
|
||||
@ -96,7 +97,11 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
PageInfo<YxWechatLive> page = new PageInfo<>(queryAll(criteria));
|
||||
Map<String, Object> map = new LinkedHashMap<>(2);
|
||||
// List<WxMaLiveResult.RoomInfo> liveInfos = wxMaLiveService.getLiveInfos();
|
||||
map.put("content", generator.convert(page.getList(), YxWechatLiveDto.class));
|
||||
List<YxWechatLiveDto> liveDtos = generator.convert(page.getList(), YxWechatLiveDto.class);
|
||||
liveDtos.forEach(i ->{
|
||||
i.setId(i.getRoomid());
|
||||
});
|
||||
map.put("content",liveDtos);
|
||||
map.put("totalElements", page.getTotal());
|
||||
return map;
|
||||
}
|
||||
@ -115,6 +120,7 @@ public class YxWechatLiveServiceImpl extends BaseServiceImpl<YxWechatLiveMapper,
|
||||
this.save(resources);
|
||||
} catch (WxErrorException e) {
|
||||
e.printStackTrace();
|
||||
throw new BadRequestException(e.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user