parent
40e4fd255f
commit
b355a3cd9c
18 changed files with 3158 additions and 11 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,85 @@ |
||||
package com.huoran.iasf.controller; |
||||
|
||||
import com.huoran.iasf.common.utils.R; |
||||
import com.huoran.iasf.entity.SysNavigationIcon; |
||||
import com.huoran.iasf.service.SysNavigationIconService; |
||||
import com.huoran.iasf.vo.req.SortOrderReq; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import io.swagger.annotations.ApiParam; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @描述:导航图标设置控制类 |
||||
* @作者: Rong |
||||
* @日期: 2024-07-04 |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("/SysNavigationIconService/SysNavigationIcon") |
||||
@Api(value = "导航图标设置:SysNavigationIconController", tags = "A-导航图标设置:导航图标设置") |
||||
public class SysNavigationIconController { |
||||
|
||||
@Autowired |
||||
public SysNavigationIconService service; |
||||
|
||||
|
||||
/** |
||||
* 保存或更新导航图标设置记录 |
||||
* 如果ID为空,则执行保存操作;如果ID有值,则视为更新操作。 |
||||
* |
||||
* @param sysNavigationIcon 要保存或更新的导航图标设置对象 |
||||
* @return R 结果对象,包含操作状态信息 |
||||
*/ |
||||
@PostMapping("/saveOrUpdate") |
||||
@ApiOperation(value = "保存或更新导航图标设置记录", response = SysNavigationIcon.class) |
||||
public R saveOrUpdate(@RequestBody @ApiParam(name = "导航图标设置对象", value = "包含导航图标设置详细信息,若id不存在则新建,否则视为更新", required = true) SysNavigationIcon sysNavigationIcon) { |
||||
|
||||
if (sysNavigationIcon.getId() == null) { |
||||
// 保存操作
|
||||
boolean addState = service.save(sysNavigationIcon); |
||||
return addState ? R.success(sysNavigationIcon.getId()) : R.fail("新增失败"); |
||||
} else { |
||||
// 更新操作
|
||||
boolean updateState = service.updateById(sysNavigationIcon); |
||||
return updateState ? R.success() : R.fail("编辑失败"); |
||||
} |
||||
} |
||||
|
||||
@PostMapping("/updateSortOrder") |
||||
@ApiOperation(value = "批量更新导航图标的排序顺序", notes = "接收一个包含ID和对应排序值的列表") |
||||
public R updateSortOrder(@RequestBody List<SortOrderReq> sortOrderRequests) { |
||||
// 调用服务层方法来批量更新排序值
|
||||
service.batchUpdateSortOrder(sortOrderRequests); |
||||
|
||||
// 返回操作成功的结果
|
||||
return R.success("排序顺序更新成功"); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/list") |
||||
@ApiOperation(value = "根据站点ID查询列表数据,可选过滤禁用状态", response = SysNavigationIcon.class, responseContainer = "List") |
||||
public R listSysNavigationIconsByCondition(@ApiParam(value = "站点ID", required = true) @RequestParam Integer siteId, @ApiParam(value = "禁用状态:0-启用,1-禁用,默认查询所有状态") @RequestParam(required = false) Integer isDisable) { |
||||
List<SysNavigationIcon> sysNavigationIcons = service.listBySiteIdAndStatus(siteId, isDisable); |
||||
return R.success(sysNavigationIcons); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/findById") |
||||
@ApiOperation(value = "查询详情", response = SysNavigationIcon.class) |
||||
public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { |
||||
SysNavigationIcon sysNavigationIcon = service.getById(id); |
||||
return R.success(sysNavigationIcon); |
||||
} |
||||
|
||||
|
||||
@PostMapping("/batchDeletion") |
||||
@ApiOperation(value = "批量删除", response = SysNavigationIcon.class) |
||||
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) { |
||||
boolean delState = service.removeByIds(ids); |
||||
return delState ? R.success() : R.fail("删除失败"); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,89 @@ |
||||
package com.huoran.iasf.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||
import com.baomidou.mybatisplus.annotation.IdType; |
||||
import com.baomidou.mybatisplus.annotation.TableField; |
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* <p> |
||||
* 导航图标设置 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2024-07-04 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = false) |
||||
@ApiModel(value = "SysNavigationIcon对象", description = "导航图标设置") |
||||
public class SysNavigationIcon implements Serializable { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@ApiModelProperty(value = "主键") |
||||
@TableId(value = "id", type = IdType.AUTO) |
||||
private Integer id; |
||||
|
||||
@ApiModelProperty(value = "站点ID") |
||||
private Integer siteId; |
||||
|
||||
@ApiModelProperty(value = "标题") |
||||
private String title; |
||||
|
||||
@ApiModelProperty(value = "按钮文字") |
||||
private String buttonText; |
||||
|
||||
@ApiModelProperty(value = "图标") |
||||
private String icon; |
||||
|
||||
@ApiModelProperty(value = "按钮内容") |
||||
private String buttonContent; |
||||
|
||||
@ApiModelProperty(value = "链接地址") |
||||
private String linkAddress; |
||||
|
||||
@ApiModelProperty(value = "图片路径") |
||||
private String imagePath; |
||||
|
||||
@ApiModelProperty(value = "设置内容类型:0-跳转链接,1-图片上传") |
||||
private Integer type; |
||||
|
||||
@ApiModelProperty(value = "是否新开页面") |
||||
private Integer newTab; |
||||
|
||||
@ApiModelProperty(value = "创建时间") |
||||
@TableField(fill = FieldFill.INSERT) |
||||
private Date createTime; |
||||
|
||||
@ApiModelProperty(value = "更新时间") |
||||
@TableField(fill = FieldFill.INSERT_UPDATE) |
||||
private Date updateTime; |
||||
|
||||
@ApiModelProperty(value = "创建人ID") |
||||
private Integer founderId; |
||||
|
||||
@ApiModelProperty(value = "编辑人ID") |
||||
private Integer editorId; |
||||
|
||||
@ApiModelProperty(value = "是否删除:1-未删除;0-已删除") |
||||
private Integer deleted; |
||||
|
||||
@ApiModelProperty(value = "发布状态:0-草稿,1-已发布") |
||||
private Integer publishStatus; |
||||
|
||||
@ApiModelProperty(value = "是否禁用:0-启用,1-禁用") |
||||
private Integer isDisable; |
||||
|
||||
|
||||
@ApiModelProperty(value = "排序顺序") |
||||
private Integer sortOrder; |
||||
|
||||
|
||||
} |
@ -0,0 +1,21 @@ |
||||
package com.huoran.iasf.mapper; |
||||
|
||||
import com.huoran.iasf.entity.SysNavigationIcon; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.apache.ibatis.annotations.Update; |
||||
|
||||
/** |
||||
* <p> |
||||
* 导航图标设置 Mapper 接口 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2024-07-04 |
||||
*/ |
||||
public interface SysNavigationIconMapper extends BaseMapper<SysNavigationIcon> { |
||||
// 更新单个记录的sort_order
|
||||
@Update("UPDATE sys_navigation_icon SET sort_order = #{sortOrder} WHERE id = #{id}") |
||||
void updateSortOrder(@Param("id") Integer id, @Param("sortOrder") Integer sortOrder); |
||||
|
||||
} |
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.huoran.iasf.mapper.SysNavigationIconMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,22 @@ |
||||
package com.huoran.iasf.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.huoran.iasf.entity.SysNavigationIcon; |
||||
import com.huoran.iasf.vo.req.SortOrderReq; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 导航图标设置 服务类 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2024-07-04 |
||||
*/ |
||||
public interface SysNavigationIconService extends IService<SysNavigationIcon> { |
||||
List<SysNavigationIcon> listBySiteIdAndStatus(Integer siteId, Integer disableStatus); |
||||
|
||||
|
||||
void batchUpdateSortOrder(List<SortOrderReq> sortOrderRequests); |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.huoran.iasf.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.huoran.iasf.entity.SysNavigationIcon; |
||||
import com.huoran.iasf.mapper.SysNavigationIconMapper; |
||||
import com.huoran.iasf.service.SysNavigationIconService; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.huoran.iasf.vo.req.SortOrderReq; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* <p> |
||||
* 导航图标设置 服务实现类 |
||||
* </p> |
||||
* |
||||
* @author cheney |
||||
* @since 2024-07-04 |
||||
*/ |
||||
@Service |
||||
public class SysNavigationIconServiceImpl extends ServiceImpl<SysNavigationIconMapper, SysNavigationIcon> implements SysNavigationIconService { |
||||
|
||||
@Override |
||||
public List<SysNavigationIcon> listBySiteIdAndStatus(Integer siteId, Integer disableStatus) { |
||||
QueryWrapper<SysNavigationIcon> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.eq("site_id", siteId); |
||||
if (disableStatus != null) { |
||||
queryWrapper.eq("disable_status", disableStatus); |
||||
} |
||||
return this.list(queryWrapper); |
||||
} |
||||
|
||||
@Override |
||||
public void batchUpdateSortOrder(List<SortOrderReq> sortOrderRequests) { |
||||
for (SortOrderReq request : sortOrderRequests) { |
||||
// 根据ID更新每个记录的sort_order字段
|
||||
baseMapper.updateSortOrder(request.getId(), request.getSortOrder()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,12 @@ |
||||
package com.huoran.iasf.vo.req; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
/** |
||||
* 接收排序请求的数据结构 |
||||
*/ |
||||
public class SortOrderReq { |
||||
private Integer id; |
||||
private Integer sortOrder; |
||||
} |
Loading…
Reference in new issue