提交 d8361fbd authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 111c24b8
......@@ -5,7 +5,6 @@ import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -18,12 +17,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.zrqx.core.constant.resource.ResourceRequestPath;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
import com.zrqx.core.form.resource.bg.annexlibrary.BatchUpdateAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.annexlibrary.QueryAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.annexlibrary.SaveAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.annexlibrary.SaveUpdateAnnexLibraryForm;
import com.zrqx.core.form.resource.bg.videolibrary.BatchUpdateVideoLibraryForm;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibraryDiyType;
import com.zrqx.core.util.page.PageInfo;
......@@ -31,10 +28,8 @@ import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.util.response.CallBack;
import com.zrqx.core.vo.resource.annexlibrary.AnnexLibraryListVO;
import com.zrqx.core.vo.resource.annexlibrary.AnnexLibraryOneVO;
import com.zrqx.resource.bg.service.ResourceRelationService;
import com.zrqx.resource.bg.service.annexlibrary.AnnexLibraryDiyTypeService;
import com.zrqx.resource.bg.service.annexlibrary.AnnexLibraryService;
import com.zrqx.resource.bg.service.recommend.RecommendResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -45,20 +40,13 @@ import tk.mybatis.mapper.entity.Example;
*/
@RestController
@RequestMapping(ResourceRequestPath.BG+ResourceRequestPath.ANNEX_LIBRARY)
@Api(description = "资源管理-件库")
@Api(description = "资源管理-件库")
public class AnnexLibraryController {
@Autowired
private AnnexLibraryService service;
@Autowired
private AnnexLibraryDiyTypeService vdrService;
//@Autowired
//private AnnexResourceService resourceService;
@Autowired
private ResourceRelationService resourceRelationService;
/** 推荐位内容*/
@Autowired
private RecommendResourceService recommendResourceService;
@ApiOperation(value = "新增" , notes ="新增一个")
......@@ -85,7 +73,6 @@ public class AnnexLibraryController {
if(!service.saveOrUpdate(form)){
throw new BusinessValidateException("操作失败");
}
AnnexLibrary entity = service.selectByPrimaryKey(form.getId());
return CallBack.success();
}
@ApiOperation(value = "批量修改价格" , notes ="批量修改价格")
......@@ -116,13 +103,13 @@ public class AnnexLibraryController {
ls.forEach(l -> l.setAnnexId(alId));
list.addAll(ls);
});
if (!vdrService.insertList(list)) {
if (!vdrService.insertUuidList(list)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
@ApiOperation(value = "批量审核", notes = "批量审核")
/*@ApiOperation(value = "批量审核", notes = "批量审核")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE_STATUS)
public CallBack<Boolean> updateArray(@RequestBody List<String> ids) {
Example example = service.createExample();
......@@ -141,12 +128,6 @@ public class AnnexLibraryController {
public CallBack<Boolean> updateShowState(@RequestBody BatchUpdateAnnexLibraryForm form){
Example example = service.createExample();
example.createCriteria().andIn("id", form.getIds());
List<AnnexLibrary> list = service.selectByExample(example);
for (AnnexLibrary entity : list) {
if(entity.getStatus() == LibraryStatusEnum.STATUS_0.getCode()){
throw new BusinessValidateException("待审核状态的文章不能直接操作上架状态需通过批量审核操作上架");
}
}
AnnexLibrary entity = new AnnexLibrary();
entity.setStatus(form.getStatus());
entity.setUpdateTime(new Date());
......@@ -154,7 +135,7 @@ public class AnnexLibraryController {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
}*/
......@@ -181,17 +162,6 @@ public class AnnexLibraryController {
AnnexLibrary entity = service.selectByPrimaryKey(oid);
AnnexLibraryOneVO vo = new AnnexLibraryOneVO();
BeanUtils.copyProperties(entity,vo);
if(StringUtils.isNotBlank(entity.getAuthorId())){
vo.setAuthorNameAndId(entity.getAuthor() + "," + entity.getAuthorId());
}else{
vo.setAuthorNameAndId(entity.getAuthor());
}
if(entity.getRealPrice() != null){
vo.setRealPrice(entity.getRealPrice().toString());
}
if(entity.getPrice() != null){
vo.setPrice(entity.getPrice().toString());
}
Example example = vdrService.createExample();
example.createCriteria().andEqualTo("annexId",oid);
List<AnnexLibraryDiyType> list = vdrService.selectByExample(example);
......@@ -205,12 +175,12 @@ public class AnnexLibraryController {
public CallBack<PageInfo<AnnexLibraryListVO>> page(QueryAnnexLibraryForm form, PageParam pageParam){
return CallBack.success(service.page(form, pageParam));
}
@ApiOperation(value = "选择弹窗中的列表" , notes ="查询选择弹窗中的列表")
/*@ApiOperation(value = "选择弹窗中的列表" , notes ="查询选择弹窗中的列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.POPPAGE)
public CallBack<PageInfo<AnnexLibraryListVO>> page(QueryResourceForPoPForm form, PageParam pageParam){
return CallBack.success(service.pageByTitleAndDiyType(form, pageParam));
}
/*@ApiOperation("相关资源列表")
@ApiOperation("相关资源列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.PAGE)
public CallBack<PageInfo<ResourceRelationVo>> reousrceRelationPage(QueryResourceRelationForm entity,
PageParam pageParam) {
......@@ -265,7 +235,7 @@ public class AnnexLibraryController {
resource.setSort(form.getSort());
resourceService.updateByPrimaryKeySelective(resource);
return CallBack.success();
}*/
}
@ApiOperation(value = "批量修改阅读权限", notes = "批量修改阅读权限")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE_READ)
......@@ -279,5 +249,5 @@ public class AnnexLibraryController {
throw new BusinessValidateException("操作失败");
}
return CallBack.success();
}
}*/
}
......@@ -15,34 +15,15 @@ import com.zrqx.core.vo.resource.annexlibrary.AnnexLibraryListVO;
*/
public interface AnnexLibraryMapper extends BaseMapper<AnnexLibrary> {
@Select("<script>"
+ "select a.id,a.name,a.source,a.bookName,a.realprice,a.timeLength,a.size,a.uploadTime,a.status "
+ "select a.id,a.name,a.source,a.uploadTime "
+ "from res_annex_library a left join res_annex_library_Diy_Type ad "
+ "on a.id = ad.annexid "
+ "where 1=1 "
+ "on a.id = ad.annexid where 1=1 "
+ "<if test='" + NOTBLANK + "(form.diyTypeCode)'>"
+ "and ad.code like concat(#{form.diyTypeCode},'%') "
+ " and ad.code like concat(#{form.diyTypeCode},'%') "
+ "</if>"
/* + "<if test='form.diyTypeId != null and form.diyTypeId.size > 0'>"
+ "and ad.dtId in "
+ " <foreach collection=\"form.diyTypeId\" index=\"index\" item=\"id\" open=\"(\" separator=\",\" close=\")\">"
+ "#{id}"
+ "</foreach>"
+ "</if>"*/
+ "<if test='" + NOTBLANK + "(form.name)'>"
+ " and a.name like concat('%',#{form.name},'%') "
+ " and (a.name like concat('%',#{form.name},'%') or a.source like concat('%',#{form.name},'%')"
+ "</if>"
+ "<if test='" + NOTBLANK + "(form.bookName)'>"
+ "and a.bookName like concat('%',#{form.bookName},'%') "
+ "</if>"
+ "<if test='form.status != null'>"
+ "and a.status = #{form.status} "
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.beginTime)'>"
+ "and a.uploadTime &gt;= concat(#{form.beginTime}, ' 00:00:00' )"
+ "</if>"
+ "<if test = '" + NOTBLANK + "(form.endTime)'>"
+ "and a.uploadTime &lt;= concat(#{form.endTime}, ' 23:59:59')"
+ "</if>"
+ " order by a.uploadTime desc "
+ "</script>")
List<AnnexLibraryListVO> query(@Param("form")QueryAnnexLibraryForm form);
......
package com.zrqx.resource.bg.service.annexlibrary;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -12,7 +10,6 @@ import org.springframework.stereotype.Service;
import com.zrqx.core.enums.AllResourceTypeEnum;
import com.zrqx.core.enums.ResponseCodeEnum;
import com.zrqx.core.enums.resource.LibraryStatusEnum;
import com.zrqx.core.enums.resource.PriceOptionEnum;
import com.zrqx.core.exception.BusinessValidateException;
import com.zrqx.core.exception.ParameterValidateException;
import com.zrqx.core.form.resource.bg.QueryResourceForPoPForm;
......@@ -22,26 +19,16 @@ import com.zrqx.core.form.resource.bg.annexlibrary.SaveUpdateAnnexLibraryForm;
import com.zrqx.core.mapper.BaseMapper;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibrary;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibraryDiyType;
import com.zrqx.core.model.resource.annexlibrary.AnnexLibraryLabelContentDiyType;
import com.zrqx.core.model.resource.membercollection.MemberCollection;
import com.zrqx.core.model.resource.record.Record;
import com.zrqx.core.model.resource.resourcerelation.ResourceRelation;
import com.zrqx.core.model.resource.shoppingcart.ShoppingCart;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.bean.BeanUtils;
import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam;
import com.zrqx.core.vo.resource.annexlibrary.AnnexLibraryListVO;
import com.zrqx.resource.bg.client.order.OrderClient;
import com.zrqx.resource.bg.mapper.annexlibrary.AnnexLibraryDiyTypeMapper;
import com.zrqx.resource.bg.mapper.annexlibrary.AnnexLibraryMapper;
import com.zrqx.resource.bg.mapper.annexlibrary.AnnexResourceMapper;
import com.zrqx.resource.bg.mapper.authorLibrary.ResourceRelationMapper;
import com.zrqx.resource.bg.mapper.marketing.PromotionContentMapper;
import com.zrqx.resource.bg.mapper.membercollection.MemberCollectionMapper;
import com.zrqx.resource.bg.mapper.recommend.RecommendResourceMapper;
import com.zrqx.resource.bg.mapper.record.RecordMapper;
import com.zrqx.resource.bg.mapper.shoppingcart.ShoppingCartMapper;
import tk.mybatis.mapper.entity.Example;
......@@ -56,20 +43,6 @@ public class AnnexLibrarySerivceImpl extends BaseServiceImpl<AnnexLibrary,String
@Autowired
private AnnexLibraryDiyTypeMapper vdrMapper;
@Autowired
private OrderClient orderClient;
@Autowired
private MemberCollectionMapper memberCollectionMapper;
@Autowired
private RecordMapper recordMapper;
@Autowired
private ShoppingCartMapper shoppingCartMapper;
@Autowired
private RecommendResourceMapper recommendResourceMapper;
@Autowired
private PromotionContentMapper promotionContentMapper;
@Autowired
private AnnexResourceMapper annexResourceMapper;
@Autowired
private ResourceRelationMapper resourceRelationMapper;
@Override
......@@ -86,36 +59,19 @@ public class AnnexLibrarySerivceImpl extends BaseServiceImpl<AnnexLibrary,String
@Override
public boolean saveOrUpdate(SaveUpdateAnnexLibraryForm form) {
AnnexLibrary entity = new AnnexLibrary();
if(StringUtils.isNotBlank(form.getAuthorNameAndId())){
String[] authorNameAndId = form.getAuthorNameAndId().split(",");
form.setAuthor(authorNameAndId[0]);
if(authorNameAndId.length > 1){
form.setAuthorId(authorNameAndId[1]);
}
}
BeanUtils.copyProperties(form, entity);
if(PriceOptionEnum.STATUS_0.getCode() == form.getPriceOption()){
entity.setRealPrice(new BigDecimal(0));
}
if(entity.getId() == null){
//添加
entity.setStatus(LibraryStatusEnum.STATUS_0.getCode());
entity.setStatus(LibraryStatusEnum.STATUS_1.getCode());
entity.setUploadTime(new Date());
entity.setResourceType(AllResourceTypeEnum.ANNEX.getCode());
entity.setBrowseNum(50);
entity.setReadTextPower(1);
entity.setDownloadNum(50);
entity.setBrowseNum(0);
entity.setSalesNum(0);
mapper.insert(entity);
}else{
//修改
entity.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(entity);
if(form.getPrice() == null){
AnnexLibrary a = mapper.selectByPrimaryKey(entity.getId());
a.setPrice(form.getPrice());
mapper.updateByPrimaryKey(a);
}
//删除当前对象与自定义分类的关系
AnnexLibraryDiyType old = new AnnexLibraryDiyType();
old.setAnnexId(entity.getId());
......@@ -125,7 +81,7 @@ public class AnnexLibrarySerivceImpl extends BaseServiceImpl<AnnexLibrary,String
if(form.getDiyType() != null && form.getDiyType().size() > 0){
List<AnnexLibraryDiyType> list = form.getDiyType();
list.forEach(li -> li.setAnnexId(entity.getId()));
vdrMapper.insertList(list);
vdrMapper.insertUuidList(list);
}
return true;
}
......@@ -150,13 +106,9 @@ public class AnnexLibrarySerivceImpl extends BaseServiceImpl<AnnexLibrary,String
obj.setSize(form.getSize().get(i));
obj.setFormats(form.getFormats().get(i));
obj.setUploadTime(new Date());
obj.setStatus(LibraryStatusEnum.STATUS_0.getCode());
obj.setStatus(LibraryStatusEnum.STATUS_1.getCode());
obj.setResourceType(AllResourceTypeEnum.ANNEX.getCode());
obj.setBrowseNum(50);
obj.setReadTextPower(1);
obj.setDownloadNum(50);
obj.setSalesNum(0);
obj.setPriceOption(1);
obj.setBrowseNum(0);
obj.setAnnexName(form.getNames().get(i));
mapper.insert(obj);
if(form.getDiyType() != null){
......@@ -198,10 +150,6 @@ public class AnnexLibrarySerivceImpl extends BaseServiceImpl<AnnexLibrary,String
example = new Example(ResourceRelation.class);
example.createCriteria().andIn("objectId", ids).orIn("resourceId", ids);
resourceRelationMapper.deleteByExample(example);
//删除资源收藏相关信息
example = new Example(MemberCollection.class);
example.createCriteria().andIn("objectId", ids);
memberCollectionMapper.deleteByExample(example);
return true;
}
/**
......@@ -235,11 +183,6 @@ public class AnnexLibrarySerivceImpl extends BaseServiceImpl<AnnexLibrary,String
}
startPage(pageParam);
List<AnnexLibraryListVO> list = mapper.queryByTileAndDiyType(form);
if(!list.isEmpty()){
for(AnnexLibraryListVO ebookListVO : list){
ebookListVO.setStatus_zh(LibraryStatusEnum.getName(Integer.parseInt(ebookListVO.getStatus())));
}
}
return new PageInfo<AnnexLibraryListVO>(list);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论