修复文件批量删除移动
This commit is contained in:
parent
099209c484
commit
d3812b128a
|
|
@ -8,10 +8,12 @@ import com.hxkj.admin.validate.PageParam;
|
|||
import com.hxkj.admin.vo.album.AlbumVo;
|
||||
import com.hxkj.common.core.AjaxResult;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
import com.hxkj.common.utils.ToolsUtil;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -58,8 +60,17 @@ public class AlbumController {
|
|||
*/
|
||||
@Log(title = "相册移动")
|
||||
@PostMapping("/albumMove")
|
||||
public Object albumMove(@Validated(value = AlbumParam.albumMove.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.albumMove(albumParam.getId(), albumParam.getCid());
|
||||
public Object albumMove(@RequestBody Map<String, Object> params) {
|
||||
if (params.get("ids") == null) {
|
||||
return AjaxResult.failed("缺少ids参数");
|
||||
}
|
||||
|
||||
if (params.get("cid") == null) {
|
||||
return AjaxResult.failed("缺少cid参数");
|
||||
}
|
||||
|
||||
List<Integer> ids = ToolsUtil.objectToListAsInt(params.get("ids"));
|
||||
iAlbumService.albumMove(ids, Integer.parseInt(params.get("cid").toString()));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -71,8 +82,12 @@ public class AlbumController {
|
|||
*/
|
||||
@Log(title = "相册删除")
|
||||
@PostMapping("/albumDel")
|
||||
public Object albumDel(@Validated(value = AlbumParam.delete.class) @RequestBody AlbumParam albumParam) {
|
||||
iAlbumService.albumDel(albumParam.getId());
|
||||
public Object albumDel(@RequestBody Map<String, List<Integer>> params) {
|
||||
if (params.get("ids") == null) {
|
||||
return AjaxResult.failed("缺少ids参数");
|
||||
}
|
||||
|
||||
iAlbumService.albumDel(params.get("ids"));
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.hxkj.admin.validate.PageParam;
|
|||
import com.hxkj.admin.vo.album.AlbumVo;
|
||||
import com.hxkj.common.core.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
|
@ -35,10 +36,10 @@ public interface IAlbumService {
|
|||
* 文件移动
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param ids 文件ID
|
||||
* @param cid 类目ID
|
||||
*/
|
||||
void albumMove(Integer id, Integer cid);
|
||||
void albumMove(List<Integer> ids, Integer cid);
|
||||
|
||||
/**
|
||||
* 文件新增
|
||||
|
|
@ -52,9 +53,9 @@ public interface IAlbumService {
|
|||
* 文件删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param ids 文件ID
|
||||
*/
|
||||
void albumDel(Integer id);
|
||||
void albumDel(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
|
|
|
|||
|
|
@ -113,28 +113,29 @@ public class AlbumServiceImpl implements IAlbumService {
|
|||
* 文件移动
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param ids 文件ID
|
||||
* @param cid 类目ID
|
||||
*/
|
||||
@Override
|
||||
public void albumMove(Integer id, Integer cid) {
|
||||
Album album = albumMapper.selectOne(new QueryWrapper<Album>()
|
||||
public void albumMove(List<Integer> ids, Integer cid) {
|
||||
List<Album> albums = albumMapper.selectList(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
.in("id", ids)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(album, "文件丢失!");
|
||||
Assert.notNull(albums, "文件丢失!");
|
||||
|
||||
Assert.notNull( albumCateMapper.selectOne(
|
||||
Assert.notNull(albumCateMapper.selectOne(
|
||||
new QueryWrapper<AlbumCate>()
|
||||
.eq("id", cid)
|
||||
.eq("is_delete", 0)
|
||||
), "类目已不存在!");
|
||||
|
||||
album.setCid(cid);
|
||||
album.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
for (Album album : albums) {
|
||||
album.setCid(cid);
|
||||
album.setUpdateTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -164,21 +165,22 @@ public class AlbumServiceImpl implements IAlbumService {
|
|||
* 文件删除
|
||||
*
|
||||
* @author fzr
|
||||
* @param id 文件ID
|
||||
* @param ids 文件ID
|
||||
*/
|
||||
@Override
|
||||
public void albumDel(Integer id) {
|
||||
Album album = albumMapper.selectOne(new QueryWrapper<Album>()
|
||||
public void albumDel(List<Integer> ids) {
|
||||
List<Album> albums = albumMapper.selectList(new QueryWrapper<Album>()
|
||||
.select("id", "name")
|
||||
.eq("id", id)
|
||||
.eq("is_delete", 0)
|
||||
.last("limit 1"));
|
||||
.in("id", ids)
|
||||
.eq("is_delete", 0));
|
||||
|
||||
Assert.notNull(album, "文件丢失!");
|
||||
Assert.notNull(albums, "文件丢失!");
|
||||
|
||||
album.setIsDelete(1);
|
||||
album.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
for (Album album : albums) {
|
||||
album.setIsDelete(1);
|
||||
album.setDeleteTime(System.currentTimeMillis() / 1000);
|
||||
albumMapper.updateById(album);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class ConfigUtil {
|
|||
return new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
return ToolsUtil.jsonToStrMap(config.getValue());
|
||||
return ToolsUtil.jsonToMapAsStr(config.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public class ToolsUtil {
|
|||
* @param json 对象
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static Map<String, String> jsonToStrMap(String json){
|
||||
public static Map<String, String> jsonToMapAsStr(String json){
|
||||
Type type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
return JSON.parseObject(json, type);
|
||||
}
|
||||
|
|
@ -168,11 +168,30 @@ public class ToolsUtil {
|
|||
return JSON.parseObject(JSONObject.toJSONString(object), type);
|
||||
}
|
||||
|
||||
public static List<Map<String, String>> stringToList(String s) {
|
||||
/**
|
||||
* 字符串转List<Map<String, String>>
|
||||
*
|
||||
* @author fzr
|
||||
* @param s 字符串
|
||||
* @return Map<String, String>
|
||||
*/
|
||||
public static List<Map<String, String>> stringToListAsMap(String s) {
|
||||
Type type = new TypeToken<List<Map<String, String>>>() {}.getType();
|
||||
return JSON.parseObject(s, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象转List<Integer>
|
||||
*
|
||||
* @author fzr
|
||||
* @param object 对象
|
||||
* @return List<Integer>
|
||||
*/
|
||||
public static List<Integer> objectToListAsInt(Object object) {
|
||||
Type type = new TypeToken<List<Integer>>() {}.getType();
|
||||
return JSON.parseObject(JSONObject.toJSONString(object), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* map合并
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue