|
|
@ -6,31 +6,25 @@ import com.huoran.iasf.common.aop.annotation.NoRepeatSubmit; |
|
|
|
import com.huoran.iasf.common.exception.NotFoundException; |
|
|
|
import com.huoran.iasf.common.exception.NotFoundException; |
|
|
|
import com.huoran.iasf.common.exception.code.BaseResponseCode; |
|
|
|
import com.huoran.iasf.common.exception.code.BaseResponseCode; |
|
|
|
import com.huoran.iasf.common.utils.Constant; |
|
|
|
import com.huoran.iasf.common.utils.Constant; |
|
|
|
|
|
|
|
import com.huoran.iasf.common.utils.R; |
|
|
|
import com.huoran.iasf.entity.*; |
|
|
|
import com.huoran.iasf.entity.*; |
|
|
|
import com.huoran.iasf.service.*; |
|
|
|
import com.huoran.iasf.service.*; |
|
|
|
import com.huoran.iasf.vo.req.ColumnWeightReqVO; |
|
|
|
import com.huoran.iasf.vo.req.ColumnWeightReqVO; |
|
|
|
import com.huoran.iasf.vo.req.PaginationColumnReqVO; |
|
|
|
import com.huoran.iasf.vo.req.PaginationColumnReqVO; |
|
|
|
import com.huoran.iasf.vo.resp.SortColumnRespVO; |
|
|
|
import com.huoran.iasf.vo.resp.SortColumnRespVO; |
|
|
|
import io.swagger.annotations.*; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import com.huoran.iasf.common.utils.R; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
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.validation.annotation.Validated; |
|
|
|
import org.springframework.data.redis.RedisConnectionFailureException; |
|
|
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
import javax.validation.Valid; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -63,6 +57,8 @@ public class SysColumnController { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
public SysFilesService sysFilesService; |
|
|
|
public SysFilesService sysFilesService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
public RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/listWithTree") |
|
|
|
@PostMapping("/listWithTree") |
|
|
|
@ApiOperation(value = "栏目树结构", response = SysColumn.class) |
|
|
|
@ApiOperation(value = "栏目树结构", response = SysColumn.class) |
|
|
@ -112,10 +108,72 @@ public class SysColumnController { |
|
|
|
return updateState ? R.success() : R.fail("编辑失败"); |
|
|
|
return updateState ? R.success() : R.fail("编辑失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 缓存用户已选择或操作过的字段。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userId 用户唯一标识,必须为正整数,用于定位特定用户的缓存字段。 |
|
|
|
|
|
|
|
* @param fields 以逗号分隔的字段列表字符串,表示用户操作或关注的字段。不能为空字符串。 |
|
|
|
|
|
|
|
* @return 成功时返回成功消息,失败时返回错误描述。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@PostMapping("/cacheField") |
|
|
|
|
|
|
|
@ApiOperation(value = "缓存用户存过的字段") |
|
|
|
|
|
|
|
public R cacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId, |
|
|
|
|
|
|
|
@ApiParam(name = "fields", required = true, value = "字段(逗号隔开)") @RequestParam String fields, |
|
|
|
|
|
|
|
@ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
String key = "fieldCache_" +"siteId_" +siteId +"userId_"+ userId; |
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(key, fields); |
|
|
|
|
|
|
|
return R.success("字段缓存成功"); |
|
|
|
|
|
|
|
} catch (RedisConnectionFailureException e) { |
|
|
|
|
|
|
|
return R.fail("由于Redis连接问题,缓存字段失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取用户已缓存的字段列表。 |
|
|
|
|
|
|
|
* 将Redis中存储的字符串(以逗号分隔的字段)直接转换为字符串列表并返回。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userId 用户唯一标识,用于查询该用户在Redis中的缓存字段。 |
|
|
|
|
|
|
|
* @return 如果用户有缓存的字段,返回一个以逗号分隔的字段字符串(不包含任何额外符号); |
|
|
|
|
|
|
|
* 如果用户没有缓存的字段,则返回特定的消息提示; |
|
|
|
|
|
|
|
* 遇到Redis连接问题时返回错误信息。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@GetMapping("/getCacheField") |
|
|
|
|
|
|
|
@ApiOperation(value = "获取用户已缓存的字段列表") |
|
|
|
|
|
|
|
public R getCacheField(@ApiParam(name = "userId", value = "用户id", required = true) @RequestParam Integer userId, |
|
|
|
|
|
|
|
@ApiParam(name = "siteId", required = true, value = "站点id") @RequestParam Integer siteId) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
String key = "fieldCache_" +"siteId_" +siteId +"userId_"+ userId; |
|
|
|
|
|
|
|
Object cachedFieldsObj = redisTemplate.opsForValue().get(key); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cachedFieldsObj == null) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!(cachedFieldsObj instanceof String)) { |
|
|
|
|
|
|
|
return R.fail("缓存数据类型不匹配,预期为String类型"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 直接将字符串分割成列表
|
|
|
|
|
|
|
|
String cachedFieldsStr = (String) cachedFieldsObj; |
|
|
|
|
|
|
|
if (cachedFieldsStr.isEmpty()){ |
|
|
|
|
|
|
|
return R.success(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<String> fields = Arrays.asList(cachedFieldsStr.split(",")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return R.success(fields); // 直接返回分割后的字段列表
|
|
|
|
|
|
|
|
} catch (RedisConnectionFailureException e) { |
|
|
|
|
|
|
|
return R.fail("由于Redis连接问题,获取字段失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/controlDisplayNavigationMenu") |
|
|
|
@PostMapping("/controlDisplayNavigationMenu") |
|
|
|
@ApiOperation(value = "控制显示导航菜单", response = SysColumn.class) |
|
|
|
@ApiOperation(value = "控制显示导航菜单", response = SysColumn.class) |
|
|
|
public R controlDisplayNavigationMenu(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, |
|
|
|
public R controlDisplayNavigationMenu(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id, @ApiParam(name = "menuVisible", value = "菜单是否可见(默认0可见 1不可见)", required = true) @RequestParam Integer menuVisible) { |
|
|
|
@ApiParam(name = "menuVisible", value = "菜单是否可见(默认0可见 1不可见)", required = true) @RequestParam Integer menuVisible) { |
|
|
|
|
|
|
|
SysColumn column = new SysColumn(); |
|
|
|
SysColumn column = new SysColumn(); |
|
|
|
column.setId(id); |
|
|
|
column.setId(id); |
|
|
|
column.setMenuVisible(menuVisible);//菜单是否可见(默认0可见 1不可见)
|
|
|
|
column.setMenuVisible(menuVisible);//菜单是否可见(默认0可见 1不可见)
|
|
|
@ -217,8 +275,7 @@ public class SysColumnController { |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取一级下的子级栏目") |
|
|
|
@ApiOperation("获取一级下的子级栏目") |
|
|
|
@PostMapping("/getsTheSubColumn") |
|
|
|
@PostMapping("/getsTheSubColumn") |
|
|
|
public R getsTheSubColumn(@ApiParam(name = "id", value = "id", required = true) @RequestParam Integer id, |
|
|
|
public R getsTheSubColumn(@ApiParam(name = "id", value = "id", required = true) @RequestParam Integer id, @ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { |
|
|
|
@ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { |
|
|
|
|
|
|
|
String ids = this.getIds(id); |
|
|
|
String ids = this.getIds(id); |
|
|
|
return service.getsTheSubColumn(id, ids, siteId); |
|
|
|
return service.getsTheSubColumn(id, ids, siteId); |
|
|
|
|
|
|
|
|
|
|
@ -227,8 +284,7 @@ public class SysColumnController { |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("获取某层级下的子级栏目") |
|
|
|
@ApiOperation("获取某层级下的子级栏目") |
|
|
|
@PostMapping("/getsSublevelColumnsUnderALevel") |
|
|
|
@PostMapping("/getsSublevelColumnsUnderALevel") |
|
|
|
public R getsSublevelColumnsUnderALevel(@ApiParam(name = "id", value = "id", required = true) @RequestParam Integer id, |
|
|
|
public R getsSublevelColumnsUnderALevel(@ApiParam(name = "id", value = "id", required = true) @RequestParam Integer id, @ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { |
|
|
|
@ApiParam(name = "siteId", value = "站点id", required = true) @RequestParam Integer siteId) { |
|
|
|
|
|
|
|
String ids = this.getIds(id); |
|
|
|
String ids = this.getIds(id); |
|
|
|
return service.getsTheSubColumn(id, ids, siteId); |
|
|
|
return service.getsTheSubColumn(id, ids, siteId); |
|
|
|
|
|
|
|
|
|
|
@ -293,10 +349,7 @@ public class SysColumnController { |
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation("某一级查全部") |
|
|
|
@ApiOperation("某一级查全部") |
|
|
|
@PostMapping("/oneLevelChecksThemAll") |
|
|
|
@PostMapping("/oneLevelChecksThemAll") |
|
|
|
public R oneLevelChecksThemAll(@ApiParam(name = "id", value = "栏目id", required = true) @RequestParam Integer id, |
|
|
|
public R oneLevelChecksThemAll(@ApiParam(name = "id", value = "栏目id", required = true) @RequestParam Integer id, @ApiParam(name = "isSort", value = "判断是否为排序接口调用(1为排序接口调用 0我栏目管理列表调用)", required = true) @RequestParam Integer isSort, @ApiParam(name = "ids", value = "主键", required = true) @RequestParam Integer siteId) { |
|
|
|
@ApiParam(name = "isSort", value = "判断是否为排序接口调用(1为排序接口调用 0我栏目管理列表调用)", required = true) @RequestParam Integer isSort, |
|
|
|
|
|
|
|
@ApiParam(name = "ids", value = "主键", required = true) @RequestParam Integer siteId |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer pid = service.oneLevelChecksThemAll(id); |
|
|
|
Integer pid = service.oneLevelChecksThemAll(id); |
|
|
|
String ids = this.getIds(pid); |
|
|
|
String ids = this.getIds(pid); |
|
|
|