banner接口,小区列表接口
parent
7e4033e0bd
commit
728aa92f0c
|
|
@ -0,0 +1,102 @@
|
|||
package com.fjrcloud.community.module.community.controller.admin.banner;
|
||||
|
||||
import com.fjrcloud.community.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import com.fjrcloud.community.framework.common.pojo.CommonResult;
|
||||
import com.fjrcloud.community.framework.common.pojo.PageParam;
|
||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
||||
import com.fjrcloud.community.framework.excel.core.util.ExcelUtils;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerPageReqVO;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerRespVO;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerSaveReqVO;
|
||||
import com.fjrcloud.community.module.community.dal.dataobject.banner.BannerDO;
|
||||
import com.fjrcloud.community.module.community.service.banner.BannerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fjrcloud.community.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static com.fjrcloud.community.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - banner管理")
|
||||
@RestController
|
||||
@RequestMapping("/community/banner")
|
||||
@Validated
|
||||
public class BannerController {
|
||||
|
||||
@Resource
|
||||
private BannerService bannerService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建banner管理")
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:create')")
|
||||
public CommonResult<Long> createBanner(@Valid @RequestBody BannerSaveReqVO createReqVO) {
|
||||
return success(bannerService.createBanner(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新banner管理")
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:update')")
|
||||
public CommonResult<Boolean> updateBanner(@Valid @RequestBody BannerSaveReqVO updateReqVO) {
|
||||
bannerService.updateBanner(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除banner管理")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:delete')")
|
||||
public CommonResult<Boolean> deleteBanner(@RequestParam("id") Long id) {
|
||||
bannerService.deleteBanner(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除banner管理")
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:delete')")
|
||||
public CommonResult<Boolean> deleteBannerList(@RequestParam("ids") List<Long> ids) {
|
||||
bannerService.deleteBannerListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得banner管理")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:query')")
|
||||
public CommonResult<BannerRespVO> getBanner(@RequestParam("id") Long id) {
|
||||
BannerDO banner = bannerService.getBanner(id);
|
||||
return success(BeanUtils.toBean(banner, BannerRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得banner管理分页")
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:query')")
|
||||
public CommonResult<PageResult<BannerRespVO>> getBannerPage(@Valid BannerPageReqVO pageReqVO) {
|
||||
PageResult<BannerDO> pageResult = bannerService.getBannerPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, BannerRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出banner管理 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('community:banner:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportBannerExcel(@Valid BannerPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<BannerDO> list = bannerService.getBannerPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "banner管理.xls", "数据", BannerRespVO.class,
|
||||
BeanUtils.toBean(list, BannerRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.fjrcloud.community.module.community.controller.admin.banner.vo;
|
||||
|
||||
import com.fjrcloud.community.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - banner管理分页 Request VO")
|
||||
@Data
|
||||
public class BannerPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "banner名称", example = "banner1")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "是否有效(0-开启,1-关闭)", example = "0")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "显示位置(1-首页,2-个人中心,3-好房出租)", example = "1")
|
||||
private Integer position;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
package com.fjrcloud.community.module.community.controller.admin.banner.vo;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import com.fjrcloud.community.framework.excel.core.annotations.DictFormat;
|
||||
import com.fjrcloud.community.framework.excel.core.convert.DictConvert;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - banner管理 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class BannerRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "banner名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "banner1")
|
||||
@ExcelProperty("banner名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "banner图片URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.fjrcloud.cn/banner.jpg")
|
||||
@ExcelProperty("banner图片URL")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "显示位置(1-首页,2-个人中心,3-好房出租)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty(value = "显示位置", converter = DictConvert.class)
|
||||
@DictFormat("comm_banner_location")
|
||||
private Integer position;
|
||||
|
||||
@Schema(description = "跳转链接", example = "/pageB/member_open/index")
|
||||
@ExcelProperty("跳转链接")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "有效期开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("有效期开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "有效期结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("有效期结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "是否有效(0-开启,1-关闭)", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@ExcelProperty(value = "是否有效", converter = DictConvert.class)
|
||||
@DictFormat("common_status")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注", example = "备注信息")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.fjrcloud.community.module.community.controller.admin.banner.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - banner管理新增/修改 Request VO")
|
||||
@Data
|
||||
public class BannerSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "banner名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "banner1")
|
||||
@NotEmpty(message = "banner名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "banner图片URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.fjrcloud.cn/banner.jpg")
|
||||
@NotEmpty(message = "banner图片URL不能为空")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "显示位置(1-首页,2-个人中心,3-好房出租)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "显示位置不能为空")
|
||||
private Integer position;
|
||||
|
||||
@Schema(description = "跳转链接", example = "/pageB/member_open/index")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "有效期开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "有效期开始时间不能为空")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "有效期结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "有效期结束时间不能为空")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "是否有效(0-开启,1-关闭)", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注", example = "备注信息")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.fjrcloud.community.module.community.controller.app.banner;
|
||||
|
||||
import com.fjrcloud.community.framework.common.pojo.CommonResult;
|
||||
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
||||
import com.fjrcloud.community.module.community.controller.app.banner.vo.AppBannerRespVO;
|
||||
import com.fjrcloud.community.module.community.dal.dataobject.banner.BannerDO;
|
||||
import com.fjrcloud.community.module.community.service.banner.BannerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fjrcloud.community.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户APP - Banner")
|
||||
@RestController
|
||||
@RequestMapping("/community/banner")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppBannerController {
|
||||
|
||||
@Resource
|
||||
private BannerService bannerService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取Banner列表")
|
||||
@Parameter(name = "position", description = "显示位置(1-首页,2-个人中心,3-好房出租)", example = "1")
|
||||
public CommonResult<List<AppBannerRespVO>> getBannerList(@RequestParam(value = "position", required = false) Integer position) {
|
||||
List<BannerDO> list = bannerService.getBannerListByPosition(position);
|
||||
return success(BeanUtils.toBean(list, AppBannerRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.fjrcloud.community.module.community.controller.app.banner.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "用户APP - Banner Response VO")
|
||||
@Data
|
||||
public class AppBannerRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "banner名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "banner1")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "banner图片URL", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.fjrcloud.cn/banner.jpg")
|
||||
private String picUrl;
|
||||
|
||||
@Schema(description = "显示位置(1-首页,2-个人中心,3-好房出租)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer position;
|
||||
|
||||
@Schema(description = "跳转链接", example = "/pageB/member_open/index")
|
||||
private String url;
|
||||
|
||||
@Schema(description = "有效期开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "有效期结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)", example = "1")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package com.fjrcloud.community.module.community.controller.app.community;
|
||||
|
||||
import com.fjrcloud.community.framework.common.pojo.CommonResult;
|
||||
import com.fjrcloud.community.module.community.controller.admin.community.vo.CommunitySimpleRespVO;
|
||||
import com.fjrcloud.community.module.community.service.community.CommunityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fjrcloud.community.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户APP - 小区信息")
|
||||
@RestController
|
||||
@RequestMapping("/community/community")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppCommunityController {
|
||||
|
||||
@Resource
|
||||
private CommunityService communityService;
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获取小区精简列表")
|
||||
public CommonResult<List<CommunitySimpleRespVO>> getCommunitySimpleList() {
|
||||
List<CommunitySimpleRespVO> list = communityService.getAppCommunitySimpleList();
|
||||
return success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.fjrcloud.community.module.community.dal.dataobject.banner;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* banner管理 DO
|
||||
*
|
||||
* @author zzy
|
||||
*/
|
||||
@TableName("comm_banner")
|
||||
@KeySequence("comm_banner_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BannerDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* banner名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* banner图片URL
|
||||
*/
|
||||
private String picUrl;
|
||||
/**
|
||||
* 显示位置(1-首页,2-个人中心,3-好房出租)
|
||||
*
|
||||
* 枚举 {@link TODO comm_banner_location 对应的类}
|
||||
*/
|
||||
private Integer position;
|
||||
/**
|
||||
* 跳转链接
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 状态(0-开启,1-关闭)
|
||||
*
|
||||
* 枚举 {@link TODO common_status 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 有效期开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
/**
|
||||
* 有效期结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
/**
|
||||
* 排序(数字越小越靠前)
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.fjrcloud.community.module.community.dal.mysql.banner;
|
||||
|
||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||
import com.fjrcloud.community.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerPageReqVO;
|
||||
import com.fjrcloud.community.module.community.dal.dataobject.banner.BannerDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* banner管理 Mapper
|
||||
*
|
||||
* @author zzy
|
||||
*/
|
||||
@Mapper
|
||||
public interface BannerMapper extends BaseMapperX<BannerDO> {
|
||||
|
||||
default PageResult<BannerDO> selectPage(BannerPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BannerDO>()
|
||||
.likeIfPresent(BannerDO::getName, reqVO.getName())
|
||||
.eqIfPresent(BannerDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(BannerDO::getPosition, reqVO.getPosition())
|
||||
.orderByAsc(BannerDO::getSort)
|
||||
.orderByDesc(BannerDO::getId));
|
||||
}
|
||||
|
||||
default List<BannerDO> selectListByPosition(Integer position) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return selectList(new LambdaQueryWrapperX<BannerDO>()
|
||||
.eqIfPresent(BannerDO::getPosition, position)
|
||||
.eq(BannerDO::getStatus, 0)
|
||||
.le(BannerDO::getStartTime, now)
|
||||
.ge(BannerDO::getEndTime, now)
|
||||
.orderByAsc(BannerDO::getSort));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -31,4 +31,5 @@ public interface ErrorCodeConstants {
|
|||
|
||||
ErrorCode MEMBER_HOUSE_MOBILE_REQUIRED = new ErrorCode(2_002_001_007,"手机号不能为空");
|
||||
|
||||
ErrorCode BANNER_NOT_EXISTS = new ErrorCode(2_002_002_007, "banner不存在");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
package com.fjrcloud.community.module.community.service.banner;
|
||||
|
||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerPageReqVO;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerSaveReqVO;
|
||||
import com.fjrcloud.community.module.community.dal.dataobject.banner.BannerDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* banner管理 Service 接口
|
||||
*
|
||||
* @author zzy
|
||||
*/
|
||||
public interface BannerService {
|
||||
|
||||
/**
|
||||
* 创建banner管理
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createBanner(@Valid BannerSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新banner管理
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateBanner(@Valid BannerSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除banner管理
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteBanner(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除banner管理
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteBannerListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得banner管理
|
||||
*
|
||||
* @param id 编号
|
||||
* @return banner管理
|
||||
*/
|
||||
BannerDO getBanner(Long id);
|
||||
|
||||
/**
|
||||
* 获得banner管理分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return banner管理分页
|
||||
*/
|
||||
PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得banner列表(App端)
|
||||
*
|
||||
* @param position 显示位置
|
||||
* @return banner列表
|
||||
*/
|
||||
List<BannerDO> getBannerListByPosition(Integer position);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.fjrcloud.community.module.community.service.banner;
|
||||
|
||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerPageReqVO;
|
||||
import com.fjrcloud.community.module.community.controller.admin.banner.vo.BannerSaveReqVO;
|
||||
import com.fjrcloud.community.module.community.dal.dataobject.banner.BannerDO;
|
||||
import com.fjrcloud.community.module.community.dal.mysql.banner.BannerMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.fjrcloud.community.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.BANNER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* banner管理 Service 实现类
|
||||
*
|
||||
* @author zzy
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class BannerServiceImpl implements BannerService {
|
||||
|
||||
@Resource
|
||||
private BannerMapper bannerMapper;
|
||||
|
||||
@Override
|
||||
public Long createBanner(BannerSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
BannerDO banner = BeanUtils.toBean(createReqVO, BannerDO.class);
|
||||
bannerMapper.insert(banner);
|
||||
|
||||
// 返回
|
||||
return banner.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBanner(BannerSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateBannerExists(updateReqVO.getId());
|
||||
// 更新
|
||||
BannerDO updateObj = BeanUtils.toBean(updateReqVO, BannerDO.class);
|
||||
bannerMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBanner(Long id) {
|
||||
// 校验存在
|
||||
validateBannerExists(id);
|
||||
// 删除
|
||||
bannerMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBannerListByIds(List<Long> ids) {
|
||||
// 删除
|
||||
bannerMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateBannerExists(Long id) {
|
||||
if (bannerMapper.selectById(id) == null) {
|
||||
throw exception(BANNER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BannerDO getBanner(Long id) {
|
||||
return bannerMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BannerDO> getBannerPage(BannerPageReqVO pageReqVO) {
|
||||
return bannerMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BannerDO> getBannerListByPosition(Integer position) {
|
||||
return bannerMapper.selectListByPosition(position);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -79,4 +79,11 @@ public interface CommunityService {
|
|||
*/
|
||||
List<CommunitySimpleRespVO> getCommunitySimpleList();
|
||||
|
||||
/**
|
||||
* 获取小区精简列表(App端)
|
||||
*
|
||||
* @return 小区精简列表
|
||||
*/
|
||||
List<CommunitySimpleRespVO> getAppCommunitySimpleList();
|
||||
|
||||
}
|
||||
|
|
@ -378,4 +378,16 @@ public class CommunityServiceImpl implements CommunityService {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CommunitySimpleRespVO> getAppCommunitySimpleList() {
|
||||
// App端查询当前租户下的小区列表
|
||||
List<CommunityDO> communities = communityMapper.selectList();
|
||||
return communities.stream()
|
||||
.map(community -> CommunitySimpleRespVO.builder()
|
||||
.id(community.getId())
|
||||
.communityName(community.getCommunityName())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?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.fjrcloud.community.module.community.dal.mysql.banner.BannerMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.fjrcloud.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue