提交 2718e6fe authored 作者: renjianyu's avatar renjianyu

--no commit message

上级 16d53e1e
......@@ -49,7 +49,6 @@ import io.swagger.annotations.ApiOperation;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;
/**
* 自定义分类 Controller
*/
......@@ -73,37 +72,75 @@ public class DiyTypeController {
@PostMapping(value = ResourceRequestPath.SAVE)
public CallBack<Boolean> save(@RequestBody DiyType entity) {
Example example = service.createExample();
example.createCriteria().andEqualTo("typeName", entity.getTypeName()).andEqualTo("parentId", entity.getParentId());
if(service.selectOneByExample(example) != null){
throw new BusinessValidateException("同级已存在"+entity.getTypeName());
}
/* if(entity.getParentId().equals(0) && AllResourceTypeEnum.getCode(entity.getTypeName()) == null){
throw new BusinessValidateException("分类名称错误");
}*/
//分页排序查询当前子分类最大code值
example.createCriteria().andEqualTo("typeName", entity.getTypeName()).andEqualTo("parentId",
entity.getParentId());
if (service.selectOneByExample(example) != null) {
throw new BusinessValidateException("同级已存在" + entity.getTypeName());
}
/*
* if(entity.getParentId().equals(0) &&
* AllResourceTypeEnum.getCode(entity.getTypeName()) == null){ throw new
* BusinessValidateException("分类名称错误"); }
*/
// 分页排序查询当前子分类最大code值
example = service.createExample();
example.createCriteria().andEqualTo("parentId", entity.getParentId());
PageParam pageParam = new PageParam();
pageParam.setPageSize(1);
pageParam.setOrderBy("code desc");
PageInfo<DiyType> page = service.queryExample(pageParam,example);
if(page.getList() != null && page.getList().size() > 0){
//查询到子分类,获取最大code生成新的code
PageInfo<DiyType> page = service.queryExample(pageParam, example);
if (page.getList() != null && page.getList().size() > 0) {
// 查询到子分类,获取最大code生成新的code
String code = page.getList().get(0).getCode().toString();
entity.setCode(UUIDUtil.newCode(code));
}else{
//没有查询到子分类,获取父类code 拼接 01
if(entity.getParentId()!=0){
entity.setCode(service.selectByPrimaryKey(entity.getParentId()).getCode()+ "01");
}else{
} else {
// 没有查询到子分类,获取父类code 拼接 01
if (entity.getParentId() != 0) {
entity.setCode(service.selectByPrimaryKey(entity.getParentId()).getCode() + "01");
} else {
entity.setCode("01");
}
}
entity.setStatus(DiyTypeStatusEnum.STATUS_1.getCode());
entity.setCreateTime(new Date());
if(!service.insert(entity)){
if (!service.insert(entity)) {
throw new BusinessValidateException("操作失败");
}
System.out.println(entity.getCode().length());
if (entity.getCode().contains("0003")) {
if (entity.getCode().length() == 6) {
for (int i = 1; i <= 24; i++) {
DiyType diytype = new DiyType();
diytype.setParentId(entity.getId());
diytype.setTypeName(entity.getShowName().substring(0, 4) + "年第" + i + "期");
diytype.setShowName(entity.getShowName().substring(0, 4) + "年第" + i + "期");
diytype.setSort(i);
example = service.createExample();
System.out.println(entity.getId());
example.createCriteria().andEqualTo("parentId", entity.getId());
pageParam.setPageSize(1);
pageParam.setOrderBy("code desc");
page = service.queryExample(pageParam, example);
if (page.getList() != null && page.getList().size() > 0) {
// 查询到子分类,获取最大code生成新的code
String code = page.getList().get(0).getCode().toString();
diytype.setCode(UUIDUtil.newCode(code));
} else {
// 没有查询到子分类,获取父类code 拼接 01
if (entity.getParentId() != 0) {
diytype.setCode(service.selectByPrimaryKey(diytype.getParentId()).getCode() + "01");
} else {
diytype.setCode("01");
}
}
diytype.setStatus(DiyTypeStatusEnum.STATUS_1.getCode());
diytype.setCreateTime(new Date());
if (!service.insert(diytype)) {
throw new BusinessValidateException("操作失败");
}
}
}
}
return CallBack.success(true);
}
......@@ -111,14 +148,12 @@ public class DiyTypeController {
@PostMapping(value = ResourceRequestPath.UPDATE)
public CallBack<Boolean> update(@RequestBody DiyType entity) {
Example example = service.createExample();
example.createCriteria().
andEqualTo("typeName", entity.getTypeName()).
andEqualTo("parentId", entity.getParentId()).
andNotEqualTo("id", entity.getId());
if(service.selectOneByExample(example) != null){
throw new BusinessValidateException("同级已存在"+entity.getTypeName());
}
if(entity.getParentId().equals(0) && AllResourceTypeEnum.getCode(entity.getTypeName()) == null){
example.createCriteria().andEqualTo("typeName", entity.getTypeName())
.andEqualTo("parentId", entity.getParentId()).andNotEqualTo("id", entity.getId());
if (service.selectOneByExample(example) != null) {
throw new BusinessValidateException("同级已存在" + entity.getTypeName());
}
if (entity.getParentId().equals(0) && AllResourceTypeEnum.getCode(entity.getTypeName()) == null) {
throw new BusinessValidateException("分类名称错误");
}
DiyType old = service.selectByPrimaryKey(entity.getId());
......@@ -130,24 +165,27 @@ public class DiyTypeController {
}
return CallBack.success(true);
}
@ApiOperation(value = "更新排序自定义分类", notes = "根据ID更新排序")
@PostMapping(value = ResourceRequestPath.UPDATE + ResourceRequestPath.SORT)
public CallBack<Boolean> updateSort(@RequestBody DiyType entity) {
service.updateByPrimaryKeySelective(entity);
return CallBack.success(true);
}
@ApiOperation(value = "批量更新排序自定义分类", notes = "根据ID更新排序")
@PostMapping(value = ResourceRequestPath.BATCH_UPDATE + ResourceRequestPath.SORT)
public CallBack<Boolean> updateSort(@RequestBody List<Integer> ids) {
service.updateSortByPrimaryKey(ids);
return CallBack.success(true);
}
@ApiOperation(value = "批量删除自定义分类", notes = "批量删除")
@PostMapping(value = ResourceRequestPath.DELETE)
public CallBack<Boolean> delete(@RequestBody List<String> id) {
Example example = service.createExample();
example.createCriteria().andIn("id", id);
if(!service.deleteByExample(example)){
if (!service.deleteByExample(example)) {
throw new BusinessValidateException("操作失败");
}
return CallBack.success(true);
......@@ -158,6 +196,7 @@ public class DiyTypeController {
public CallBack<DiyType> getById(@PathVariable Integer oid) {
return CallBack.success(service.selectByPrimaryKey(oid));
}
@ApiOperation(value = "查询 自定义分类同树 同级名称是否存在接口", notes = "查询 自定义分类同树 同级名称是否存在接口")
@GetMapping(value = ResourceRequestPath.ISEXIST_TYPE_NAME)
public CallBack<Boolean> isExistTypeNameBoolean(QueryDiyTypeForm form) {
......@@ -165,18 +204,19 @@ public class DiyTypeController {
Criteria cr = example.createCriteria();
cr.andEqualTo("typeName", form.getTypeName());
cr.andEqualTo("parentId", form.getParentId());
if(form.getId() != null){
if (form.getId() != null) {
cr.andNotEqualTo("id", form.getId());
}
return CallBack.success(service.selectOneByExample(example) != null);
}
@ApiOperation(value = "查询检查旧编码名称是否已存在", notes = "查询检查旧编码名称是否已存在")
@GetMapping(value = ResourceRequestPath.ISEXIST_OLD_CODE)
public CallBack<Boolean> isExistOldCodeBoolean(Integer id, String oldCode) {
Example example = service.createExample();
Criteria cr = example.createCriteria();
cr.andEqualTo("oldCode", oldCode);
if(id != null){
if (id != null) {
cr.andNotEqualTo("id", id);
}
return CallBack.success(service.selectOneByExample(example) != null);
......@@ -197,16 +237,17 @@ public class DiyTypeController {
public CallBack<List<DiyTypeVO>> tree() {
Example example = service.createExample();
example.createCriteria().andEqualTo("status", DiyTypeStatusEnum.STATUS_1.getCode());
PageHelper.orderBy("sort");
PageHelper.orderBy("sort desc");
List<DiyType> list = service.selectByExample(example);
List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> obj.getParentId().intValue() == 0);
tree(list,voList);
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().intValue() == 0);
tree(list, voList);
return CallBack.success(voList);
}
@ApiOperation(value = "根据数据类型(一级分类名)查询自定义分类tree", notes = "查询列表")
@GetMapping(value = ResourceRequestPath.NAME + ResourceRequestPath.TREE)
public CallBack<List<DiyTypeVO>> tree(String name) {
if(StringUtils.isBlank(name)){
if (StringUtils.isBlank(name)) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "参数不能为空!");
}
Example example = service.createExample();
......@@ -214,16 +255,17 @@ public class DiyTypeController {
PageHelper.orderBy("sort");
List<DiyType> list = service.selectByExample(example);
// 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> name.equals(obj.getTypeName()) && obj.getParentId().intValue() == 0);
tree(list,voList);
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class,
obj -> name.equals(obj.getTypeName()) && obj.getParentId().intValue() == 0);
tree(list, voList);
return CallBack.success(voList);
}
@ApiOperation(value = "根据数据类型(一级分类名)查询自定义分类list", notes = "查询列表")
@GetMapping(value = ResourceRequestPath.NAME+ResourceRequestPath.LIST)
@GetMapping(value = ResourceRequestPath.NAME + ResourceRequestPath.LIST)
public CallBack<List<DiyType>> list(String name) {
List<DiyType> vos = new ArrayList<DiyType>();
if(StringUtils.isBlank(name)){
if (StringUtils.isBlank(name)) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "参数不能为空!");
}
Example example = service.createExample();
......@@ -231,44 +273,47 @@ public class DiyTypeController {
PageHelper.orderBy("sort");
List<DiyType> list = service.selectByExample(example);
// 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> name.equals(obj.getTypeName()) && obj.getParentId().intValue() == 0);
tree(list,voList);
return CallBack.success(convertAllToOne(voList,vos));
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class,
obj -> name.equals(obj.getTypeName()) && obj.getParentId().intValue() == 0);
tree(list, voList);
return CallBack.success(convertAllToOne(voList, vos));
}
public List<DiyTypeVO> tree(List<DiyType> list,List<DiyTypeVO> voList){
voList.forEach(entity ->{
//第一次设置 一级分类的子类 后续递归设置 子类的子类
entity.setList(Copy.copyList(list, DiyTypeVO.class,obj -> obj.getParentId().intValue() == entity.getId().intValue()));
//当前分类存在子类 开始递归子类
if(entity.getList().size() > 0){
public List<DiyTypeVO> tree(List<DiyType> list, List<DiyTypeVO> voList) {
voList.forEach(entity -> {
// 第一次设置 一级分类的子类 后续递归设置 子类的子类
entity.setList(Copy.copyList(list, DiyTypeVO.class,
obj -> obj.getParentId().intValue() == entity.getId().intValue()));
// 当前分类存在子类 开始递归子类
if (entity.getList().size() > 0) {
tree(list, entity.getList());
}
});
return voList;
}
public List<DiyType> convertAllToOne(List<DiyTypeVO> all ,List<DiyType> dest) {
for(DiyTypeVO v: all) {
DiyType obj=new DiyType();
public List<DiyType> convertAllToOne(List<DiyTypeVO> all, List<DiyType> dest) {
for (DiyTypeVO v : all) {
DiyType obj = new DiyType();
BeanUtils.copyProperties(v, obj);
dest.add(obj);
if(v.getList()!=null) {
convertAllToOne(v.getList(),dest);
if (v.getList() != null) {
convertAllToOne(v.getList(), dest);
}
}
return dest;
}
@ApiOperation(value = "查询自定义分类当前最大排序号" , notes ="查询当前最大排序号")
@ApiOperation(value = "查询自定义分类当前最大排序号", notes = "查询当前最大排序号")
@GetMapping(value = ResourceRequestPath.MAXORDERNUM)
public CallBack<Integer> getMaxOrderNum(Integer id){
public CallBack<Integer> getMaxOrderNum(Integer id) {
return CallBack.success(service.getMaxOrderNum(id));
}
@ApiOperation(value = "查询指定id分类以及父级分类")
@PostMapping(SysUserRequestPath.GET_TYPE)
public CallBack<List<DiyTypeNodeVo>> getDiyTypeByPid(@RequestBody Integer[] id){
public CallBack<List<DiyTypeNodeVo>> getDiyTypeByPid(@RequestBody Integer[] id) {
List<DiyTypeNodeVo> list = new ArrayList<DiyTypeNodeVo>();
for (Integer integer : id) {
DiyTypeNodeVo diyTypeNodeVo = service.getNode(integer);
......@@ -278,70 +323,72 @@ public class DiyTypeController {
}
@ApiOperation(value = "根据数据类型(一级分类名)以及关键词查询自定义分类tree", notes = "查询列表")
@GetMapping(value =ResourceRequestPath.TREE + ResourceRequestPath.GET)
public CallBack<List<DiyTypeVO>> updateTree(@RequestParam("name")String name, @RequestParam(value="search",required=false)String search) {
if(StringUtils.isBlank(name)){
@GetMapping(value = ResourceRequestPath.TREE + ResourceRequestPath.GET)
public CallBack<List<DiyTypeVO>> updateTree(@RequestParam("name") String name,
@RequestParam(value = "search", required = false) String search) {
if (StringUtils.isBlank(name)) {
throw new ParameterValidateException(ResponseCodeEnum.MISS_EXCEPTION.getCode(), "参数不能为空!");
}
CallBack<List<DiyType>> call = this.list(name);
List<DiyType> list =call.getData();
List<DiyType> list = call.getData();
List<DiyTypeVO> newTree = new ArrayList<DiyTypeVO>();
// 获取一级分类
List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> search.equals(obj.getTypeName()) && obj.getParentId().intValue() != 0);
if(!voList.isEmpty()){
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class,
obj -> search.equals(obj.getTypeName()) && obj.getParentId().intValue() != 0);
if (!voList.isEmpty()) {
Integer id = voList.get(0).getParentId();
List<DiyType> diyList = new ArrayList<DiyType>();
do{
do {
DiyType diyType = service.selectByPrimaryKey(id);
id = diyType.getParentId();
diyList.add(diyType);
}while(id!=0);
List<DiyTypeVO>fathor = getDiyTypeVO(diyList);
List<DiyTypeVO> child = tree(list,voList);
} while (id != 0);
List<DiyTypeVO> fathor = getDiyTypeVO(diyList);
List<DiyTypeVO> child = tree(list, voList);
newTree = connect(fathor, child);
}
return CallBack.success(newTree);
}
public List<DiyTypeVO> connect(List<DiyTypeVO> list,List<DiyTypeVO> voList){
public List<DiyTypeVO> connect(List<DiyTypeVO> list, List<DiyTypeVO> voList) {
DiyTypeVO vo = list.get(0);
if(ArrayUtils.isNotEmpty(vo.getList())){
connect(vo.getList(),voList);
}else{
if (ArrayUtils.isNotEmpty(vo.getList())) {
connect(vo.getList(), voList);
} else {
vo.setList(voList);
}
return Arrays.asList(vo);
}
public List<DiyTypeVO> getDiyTypeVO(List<DiyType> list){
List<DiyTypeVO> voList = Copy.copyList(list , DiyTypeVO.class, obj -> obj.getParentId().intValue() == 0);
tree(list,voList);
public List<DiyTypeVO> getDiyTypeVO(List<DiyType> list) {
List<DiyTypeVO> voList = Copy.copyList(list, DiyTypeVO.class, obj -> obj.getParentId().intValue() == 0);
tree(list, voList);
return voList;
}
@ApiOperation(value = "根据code查询自定义分类", notes = "查询列表")
@GetMapping(value = ResourceRequestPath.CODE + ResourceRequestPath.GET)
public CallBack<DiyType> selectDiyTypeByCode(@RequestParam("code")String code) {
public CallBack<DiyType> selectDiyTypeByCode(@RequestParam("code") String code) {
Example example = service.createExample();
example.createCriteria().andEqualTo("status", DiyTypeStatusEnum.STATUS_1.getCode()).andEqualTo("code", code);
DiyType list = service.selectOneByExample(example);
return CallBack.success(list);
}
@GetMapping(value = "/modify")
public CallBack<Integer> getMaxOrderNum(){
public CallBack<Integer> getMaxOrderNum() {
List<DiyType> diyTypeList = service.selectAll();
diyTypeList.forEach(item ->{
String str ="";
if(item.getCode().length()==6) {
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4)+"00"+item.getCode().substring(4,6);
diyTypeList.forEach(item -> {
String str = "";
if (item.getCode().length() == 6) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4) + "00"
+ item.getCode().substring(4, 6);
}else if (item.getCode().length()==4){
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4);
}else if(item.getCode().length()==2) {
str="00"+item.getCode();
} else if (item.getCode().length() == 4) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4);
} else if (item.getCode().length() == 2) {
str = "00" + item.getCode();
}
item.setCode(str);
service.updateByPrimaryKey(item);
......@@ -351,19 +398,20 @@ public class DiyTypeController {
}
@GetMapping(value = "/modify1")
public CallBack<Integer> getMaxOrderNum1(){
public CallBack<Integer> getMaxOrderNum1() {
List<ArticleLibraryDiyType> diyTypeList = aldtService.selectAll();
diyTypeList.forEach(item ->{
String str ="";
diyTypeList.forEach(item -> {
String str = "";
if(item.getCode().length()==6) {
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4)+"00"+item.getCode().substring(4,6);
if (item.getCode().length() == 6) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4) + "00"
+ item.getCode().substring(4, 6);
}else if (item.getCode().length()==4){
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4);
}else if(item.getCode().length()==2) {
str="00"+item.getCode();
} else if (item.getCode().length() == 4) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4);
} else if (item.getCode().length() == 2) {
str = "00" + item.getCode();
}
item.setCode(str);
aldtService.updateByPrimaryKey(item);
......@@ -371,22 +419,22 @@ public class DiyTypeController {
return null;
}
@GetMapping(value = "/modify2")
public CallBack<Integer> getMaxOrderNum2(){
public CallBack<Integer> getMaxOrderNum2() {
List<EbookDiyType> diyTypeList = edtServce.selectAll();
diyTypeList.forEach(item ->{
String str ="";
if(item.getCode().length()==6) {
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4)+"00"+item.getCode().substring(4,6);
diyTypeList.forEach(item -> {
String str = "";
if (item.getCode().length() == 6) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4) + "00"
+ item.getCode().substring(4, 6);
}else if (item.getCode().length()==4){
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4);
}else if(item.getCode().length()==2) {
str="00"+item.getCode();
} else if (item.getCode().length() == 4) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4);
} else if (item.getCode().length() == 2) {
str = "00" + item.getCode();
}
item.setCode(str);
edtServce.updateByPrimaryKey(item);
......@@ -396,18 +444,19 @@ public class DiyTypeController {
}
@GetMapping(value = "/modify3")
public CallBack<Integer> getMaxOrderNum3(){
public CallBack<Integer> getMaxOrderNum3() {
List<ImageLibraryDiyType> diyTypeList = ildtService.selectAll();
diyTypeList.forEach(item ->{
String str ="";
if(item.getCode().length()==6) {
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4)+"00"+item.getCode().substring(4,6);
diyTypeList.forEach(item -> {
String str = "";
if (item.getCode().length() == 6) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4) + "00"
+ item.getCode().substring(4, 6);
}else if (item.getCode().length()==4){
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4);
}else if(item.getCode().length()==2) {
str="00"+item.getCode();
} else if (item.getCode().length() == 4) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4);
} else if (item.getCode().length() == 2) {
str = "00" + item.getCode();
}
item.setCode(str);
ildtService.updateByPrimaryKey(item);
......@@ -416,20 +465,20 @@ public class DiyTypeController {
return null;
}
@GetMapping(value = "/modify4")
public CallBack<Integer> getMaxOrderNum4(){
public CallBack<Integer> getMaxOrderNum4() {
List<PdfLibraryDiyType> diyTypeList = pldtService.selectAll();
diyTypeList.forEach(item ->{
String str ="";
if(item.getCode().length()==6) {
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4)+"00"+item.getCode().substring(4,6);
diyTypeList.forEach(item -> {
String str = "";
if (item.getCode().length() == 6) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4) + "00"
+ item.getCode().substring(4, 6);
}else if (item.getCode().length()==4){
str="00"+item.getCode().substring(0, 2)+"00"+item.getCode().substring(2,4);
}else if(item.getCode().length()==2) {
str="00"+item.getCode();
} else if (item.getCode().length() == 4) {
str = "00" + item.getCode().substring(0, 2) + "00" + item.getCode().substring(2, 4);
} else if (item.getCode().length() == 2) {
str = "00" + item.getCode();
}
item.setCode(str);
pldtService.updateByPrimaryKey(item);
......
......@@ -525,6 +525,7 @@ public class EbookController {
}
return CallBack.success();
}
// 未导入,但已存在该isbn图书,则修改该图书及章节
BeanUtils.copyPropertiesIgnoreNotNull(ev.getBook(), book, book);
bookservice.updateByPrimaryKeySelective(book);
......@@ -533,6 +534,10 @@ public class EbookController {
ebook.setUpdateTime(new Date());
ebookservice.updateByPrimaryKeySelective(ebook);
// 插入文章及分类关联表
//查询图书关联的文章进行下架处理
ev.getArticleSet().forEach(article -> {
......@@ -541,7 +546,7 @@ public class EbookController {
article.setBookName(book.getName());
article.setUploadTime(new Date());
article.setUpdateTime(new Date());
article.setStatus(0);
article.setStatus(1);
article.setSource(book.getName());
article.setBrowseNum(50);
// article.setNationsType(book.getNationsType());
......@@ -621,6 +626,7 @@ public class EbookController {
ev.getChapterSet().forEach(chapter -> {
chapter.setBookid(book.getId());
chapter.setBookName(book.getName());
if(chapter.getLevel()>0) {
//关联关系建立
Example example1=alservice.createExample();
example1.createCriteria().andEqualTo("bookId",book.getId()).andEqualTo("markid", chapter.getMarkid());
......@@ -635,6 +641,7 @@ public class EbookController {
relation1.setUploadTime(new Date());
resourceRelationService.insert(relation1);
}
}
});
clservice.insertList(new ArrayList(ev.getChapterSet()));
......@@ -689,7 +696,7 @@ public class EbookController {
article.setSource(ev.getBook().getName());
article.setUploadTime(new Date());
article.setUpdateTime(new Date());
article.setStatus(0);
article.setStatus(1);
article.setBrowseNum(50);
// article.setNationsType(ev.getBook().getNationsType());
article.setResourceType(AllResourceTypeEnum.ARTICLE.getCode());
......@@ -716,14 +723,18 @@ public class EbookController {
aldtservice.insertSelective(aldt);
});
ev.getChapterSet().forEach(chapter -> {
chapter.setBookid(ev.getBook().getId());
chapter.setBookName(ev.getBook().getName());
// clservice.insert(chapter);
//关联关系建立
if(chapter.getLevel()>0) {
Example example2=alservice.createExample();
example2.createCriteria().andEqualTo("bookId",ev.getBook().getId()).andEqualTo("markid", chapter.getMarkid());
List<ArticleLibrary> list = alservice.selectByExample(example2);
if(list.size()>0) {
ResourceRelation relation =new ResourceRelation();
relation.setObjectId(ev.getBook().getId());
relation.setResourceId(list.get(0).getId());
......@@ -733,6 +744,7 @@ public class EbookController {
relation.setUploadTime(new Date());
resourceRelationService.insert(relation);
}
}
});
clservice.insertList(new ArrayList(ev.getChapterSet()));
// 删除当前对象与年份的关系
......
......@@ -133,7 +133,7 @@ public class ResourceRelationServiceImpl extends BaseServiceImpl<ResourceRelatio
@Override
public List<ResourceRelationVo> queryByIdAndResourceType(QueryResourceRelationForm entity, PageParam pageParam) {
if(null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("sort asc");
pageParam.setOrderBy("sort desc");
}
PageHelper.startPage(pageParam);
return mapper.queryByIdAndResourceType(entity);
......@@ -145,7 +145,7 @@ public class ResourceRelationServiceImpl extends BaseServiceImpl<ResourceRelatio
@Override
public List<ResourceRelationVo> queryByIdAndGoodsType(QueryResourceRelationForm entity, PageParam pageParam) {
if(null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("sort asc,uploadTime desc");
pageParam.setOrderBy("sort desc,uploadTime desc");
}
PageHelper.startPage(pageParam);
List<ResourceRelationVo> list = mapper.queryByIdAndGoodsType(entity);
......
......@@ -3,6 +3,7 @@ package com.zrqx.resource.bg.service.audiolibrary;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -146,6 +147,9 @@ public class AudioLibrarySerivceImpl extends BaseServiceImpl<AudioLibrary,String
}
@Override
public PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
if(pageParam != null && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("a.uploadTime desc, a.id desc");
}
startPage(pageParam);
List<ResourceRelationListVo> list = mapper.queryByTileAndDiyType(form);
return new PageInfo<ResourceRelationListVo>(list);
......
......@@ -24,6 +24,7 @@ import com.zrqx.core.model.resource.ebook.Ebook;
import com.zrqx.core.model.resource.ebook.EbookMainBody;
import com.zrqx.core.model.resource.ebook.EbookMainBodyRelation;
import com.zrqx.core.model.resource.pdffilelibrary.PdfLibrary;
import com.zrqx.core.model.resource.year.PeriodsLibrary;
import com.zrqx.core.model.resource.year.YearLibrary;
import com.zrqx.core.service.BaseServiceImpl;
import com.zrqx.core.util.page.PageInfo;
......@@ -35,6 +36,7 @@ import com.zrqx.resource.bg.mapper.ebook.EbookMainBodyMapper;
import com.zrqx.resource.bg.mapper.ebook.EbookMainBodyRelationMapper;
import com.zrqx.resource.bg.mapper.ebook.EbookMapper;
import com.zrqx.resource.bg.mapper.pdffilelibrary.PdfLibraryMapper;
import com.zrqx.resource.bg.mapper.year.PeriodsLibraryMapper;
import com.zrqx.resource.bg.mapper.year.YearLibraryMapper;
/**
......@@ -57,6 +59,8 @@ public class EbookServiceImpl extends BaseServiceImpl<Ebook, String> implements
@Autowired
private YearLibraryMapper yearLibraryMapper;
@Autowired
private PeriodsLibraryMapper periodsLibraryMapper;
@Autowired
private EbookMainBodyRelationMapper ebookMainBodyRelationMapper;
@Autowired
private FileClient client;
......@@ -166,8 +170,9 @@ public class EbookServiceImpl extends BaseServiceImpl<Ebook, String> implements
book.setYearId(str);
book.setYear(year.getName());
} else if (i == 3) {
PeriodsLibrary per = periodsLibraryMapper.selectByPrimaryKey(str);
book.setPeriodsId(str);
book.setPeriods(str);
book.setPeriods(per.getName());
}
}
}
......
......@@ -229,9 +229,9 @@ public class VideoLibrarySerivceImpl extends BaseServiceImpl<VideoLibrary,String
*/
@Override
public PageInfo<ResourceRelationListVo> pageByTitleAndDiyType(QueryResourceForPoPForm form, PageParam pageParam) {
// if(pageParam != null && StringUtils.isBlank(pageParam.getOrderBy())){
// pageParam.setOrderBy("uploadTime desc, id desc");
// }
if(pageParam != null && StringUtils.isBlank(pageParam.getOrderBy())){
pageParam.setOrderBy("a.uploadTime desc, a.id desc");
}
startPage(pageParam);
List<ResourceRelationListVo> list = mapper.queryByTileAndDiyType(form);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论