提交 73059c86 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 a8d0bf20
...@@ -3,15 +3,13 @@ ...@@ -3,15 +3,13 @@
*/ */
package com.zrqx.content.bg.controller.content; package com.zrqx.content.bg.controller.content;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.startup.Catalina;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -119,15 +117,14 @@ public class ContentController { ...@@ -119,15 +117,14 @@ public class ContentController {
@ApiOperation(value = "单条更新", notes = "更新内容") @ApiOperation(value = "单条更新", notes = "更新内容")
@PostMapping(value = ContentRequestPath.UPDATE_OID) @PostMapping(value = ContentRequestPath.UPDATE_OID)
public CallBack<Boolean> update(@RequestBody SaveUpdateContentForm form) { public CallBack<Boolean> update(@RequestBody SaveUpdateContentForm form) {
Content content = new Content(); Content content = service.selectByPrimaryKey(form.getId());
BeanUtils.copyProperties(form, content); BeanUtils.copyProperties(form, content);
// 所属栏目 // 所属栏目
if (content.getColumnId() == null) { if (form.getColumnId() == null) {
throw new BaseException(7, "请选择所属栏目"); throw new BaseException(7, "请选择所属栏目");
} }
Content content2 = service.selectByPrimaryKey(form.getId()); if(!content.getColumnId().equals(form.getColumnId())){
if(!content2.getColumnId().equals(form.getColumnId())){ ContentColumn column1 = contentColumnService.selectByPrimaryKey(content.getColumnId());
ContentColumn column1 = contentColumnService.selectByPrimaryKey(content2.getColumnId());
if(column1!=null){ if(column1!=null){
if(column1.getContentNum()>0){ if(column1.getContentNum()>0){
column1.setContentNum(column1.getContentNum()-1); column1.setContentNum(column1.getContentNum()-1);
...@@ -145,16 +142,18 @@ public class ContentController { ...@@ -145,16 +142,18 @@ public class ContentController {
ContentSource source = new ContentSource(); ContentSource source = new ContentSource();
source.setSourceName(content.getSource()); source.setSourceName(content.getSource());
if (content.getSourceId() == null) { if (content.getSourceId() == null) {
ContentSource cs = sourceService.selectOne(source); if(content.getSourceState().equals(1)){
if (cs == null || cs.getId() == null) { ContentSource cs = sourceService.selectOne(source);
source.setWebsite(content.getWebsite()); if (cs == null || cs.getId() == null) {
Integer maxSort = sourceService.getMaxSort(); source.setWebsite(content.getWebsite());
source.setSort(maxSort + 1); Integer maxSort = sourceService.getMaxSort();
source.setCreateTime(new Date()); source.setSort(maxSort + 1);
sourceService.insert(source); source.setCreateTime(new Date());
cs.setId(source.getId()); sourceService.insert(source);
cs.setId(source.getId());
}
content.setSourceId(cs.getId());
} }
content.setSourceId(cs.getId());
} }
} }
content.setUpdateTime(new Date()); content.setUpdateTime(new Date());
...@@ -195,17 +194,18 @@ public class ContentController { ...@@ -195,17 +194,18 @@ public class ContentController {
if (form.getIds().length == 0) { if (form.getIds().length == 0) {
throw new BaseException("没有选中任何数据,请重新选择"); throw new BaseException("没有选中任何数据,请重新选择");
} }
Criteria cr = service.createCriteria(); for (Integer str : form.getIds()) {
cr.andIn("id", Arrays.asList(form.getIds())); Content content = service.selectByPrimaryKey(str);
Content content = new Content(); if (form.getStatus() != null) {
if (form.getStatus() != null) { content.setStatus(form.getStatus());
content.setStatus(form.getStatus()); }
} if (form.getIsDelete() == 1) {
if (form.getIsDelete() == 1) { content.setDeleteTime(new Date());
content.setDeleteTime(new Date()); }
content.setIsDelete(form.getIsDelete());
service.updateByPrimaryKey(content);
} }
content.setIsDelete(form.getIsDelete()); return CallBack.success();
return CallBack.success(service.updateByCriteriaSelective(content));
} }
@ApiOperation(value = "批量彻底删除", notes = "批量彻底删除,回收站彻底删除才调用") @ApiOperation(value = "批量彻底删除", notes = "批量彻底删除,回收站彻底删除才调用")
...@@ -232,7 +232,7 @@ public class ContentController { ...@@ -232,7 +232,7 @@ public class ContentController {
@PostMapping(value = ContentRequestPath.DELETE_ALL) @PostMapping(value = ContentRequestPath.DELETE_ALL)
public CallBack<Integer> deleteAll() { public CallBack<Integer> deleteAll() {
int num = service.count(); int num = service.count();
if (num ==0) { if (num < 1) {
throw new BaseException("回收站也没有余粮了"); throw new BaseException("回收站也没有余粮了");
} }
List<Integer> list = service.selectAllId(); List<Integer> list = service.selectAllId();
...@@ -278,12 +278,6 @@ public class ContentController { ...@@ -278,12 +278,6 @@ public class ContentController {
@ApiOperation(value = "分页查询", notes = "分页查询") @ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping(value = ContentRequestPath.PAGE) @GetMapping(value = ContentRequestPath.PAGE)
public CallBack<PageInfo<ContentVo>> page(ContentSelectForm form, PageParam pageParam) { public CallBack<PageInfo<ContentVo>> page(ContentSelectForm form, PageParam pageParam) {
if (form.getIsDelete() == 0) {
pageParam.setOrderBy("uploadTime desc");
}
if (form.getIsDelete() == 1) {
pageParam.setOrderBy("deleteTime desc");
}
return CallBack.success(service.page(form, pageParam)); return CallBack.success(service.page(form, pageParam));
} }
......
/** /**
* @author niguanghui 1 * @author niguanghui
* @date 2018年12月24日 下午4:58:44 * @date 2018年12月24日 下午4:58:44
*/ */
package com.zrqx.content.bg.controller.contentSource; package com.zrqx.content.bg.controller.contentSource;
...@@ -90,7 +90,7 @@ public class ContentSourceController { ...@@ -90,7 +90,7 @@ public class ContentSourceController {
} }
@ApiOperation(value = "按来源名称模糊查找", notes = "按来源名称模糊查找") @ApiOperation(value = "按来源名称模糊查找", notes = "按来源名称模糊查找")
@GetMapping(ContentRequestPath.PAGE + ContentRequestPath.NAME) @GetMapping(ContentRequestPath.PAGE)
public CallBack<PageInfo<ContentSource>> selectByCondition(String sourceName,PageParam pageParam) { public CallBack<PageInfo<ContentSource>> selectByCondition(String sourceName,PageParam pageParam) {
if (null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())) { if (null != pageParam && StringUtils.isBlank(pageParam.getOrderBy())) {
pageParam.setOrderBy("createTime desc"); pageParam.setOrderBy("createTime desc");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论