src/main/java/org/springblade/common/config/BladeConfiguration.java
@@ -77,6 +77,7 @@ secureRegistry.excludePathPatterns("/blade-user/**"); secureRegistry.excludePathPatterns("/pushMsg/**"); secureRegistry.excludePathPatterns("/owner/**"); secureRegistry.excludePathPatterns("/friend/**"); return secureRegistry; } src/main/java/org/springblade/modules/friend/controller/FriendController.java
New file @@ -0,0 +1,120 @@ package org.springblade.modules.friend.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tenant.annotation.TenantDS; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.friend.entity.Friend; import org.springblade.modules.friend.service.IFriendService; import org.springblade.modules.friend.vo.FriendVO; import org.springblade.modules.friend.wrapper.FriendWrapper; import org.springframework.web.bind.annotation.*; import springfox.documentation.annotations.ApiIgnore; import java.util.Map; /** * 控制器 * * @author Chill */ @TenantDS @RestController @RequestMapping("/friend") @AllArgsConstructor public class FriendController extends BladeController { private final IFriendService friendService; /** * 详情 */ @GetMapping("/detail") @ApiOperationSupport(order = 1) @ApiOperation(value = "详情", notes = "传入friend") public R<FriendVO> detail(Friend friend) { Friend detail = friendService.getOne(Condition.getQueryWrapper(friend)); return R.data(FriendWrapper.build().entityVO(detail)); } /** * 分页 */ @GetMapping("/list") @ApiImplicitParams({ @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"), @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string") }) @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入friend") public R<IPage<FriendVO>> list(@ApiIgnore @RequestParam Map<String, Object> friend, Query query) { IPage<Friend> pages = friendService.page(Condition.getPage(query), Condition.getQueryWrapper(friend, Friend.class)); return R.data(FriendWrapper.build().pageVO(pages)); } /** * 多表联合查询自定义分页 */ @GetMapping("/page") @ApiImplicitParams({ @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"), @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string") }) @ApiOperationSupport(order = 3) @ApiOperation(value = "分页", notes = "传入friend") public R<IPage<FriendVO>> page(@ApiIgnore FriendVO friend, Query query) { IPage<FriendVO> pages = friendService.selectFriendPage(Condition.getPage(query), friend); return R.data(pages); } /** * 新增 */ @PostMapping("/save") @ApiOperationSupport(order = 4) @ApiOperation(value = "新增", notes = "传入friend") public R save(@RequestBody Friend friend) { return R.status(friendService.save(friend)); } /** * 修改 */ @PostMapping("/update") @ApiOperationSupport(order = 5) @ApiOperation(value = "修改", notes = "传入friend") public R update(@RequestBody Friend friend) { return R.status(friendService.updateById(friend)); } /** * 新增或修改 */ @PostMapping("/submit") @ApiOperationSupport(order = 6) @ApiOperation(value = "新增或修改", notes = "传入friend") public R submit(@RequestBody Friend friend) { return R.status(friendService.saveOrUpdate(friend)); } /** * 删除 */ @PostMapping("/remove") @ApiOperationSupport(order = 7) @ApiOperation(value = "逻辑删除", notes = "传入friend") public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) { boolean temp = friendService.removeByIds(Func.toLongList(ids)); return R.status(temp); } } src/main/java/org/springblade/modules/friend/entity/Friend.java
New file @@ -0,0 +1,72 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.friend.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; /** * 实体类 * * @author Chill */ @Data @TableName("sys_friend") public class Friend implements Serializable { private static final long serialVersionUID = 1L; /** * id */ @ApiModelProperty(value = "id") @TableId(value = "id", type = IdType.AUTO) private Integer id; /** * 申请人id */ @ApiModelProperty(value = "申请人id") private String applicant; /** * 好友id */ @ApiModelProperty(value = "好友id") @TableField("friend") private String friend; /** * 申请时间 */ @ApiModelProperty(value = "申请时间") @TableField("time") private String time; /** * 申请状态(0:申请中 1:同意 2:拒绝) */ @ApiModelProperty(value = "申请状态") private String type; } src/main/java/org/springblade/modules/friend/mapper/FriendMapper.java
New file @@ -0,0 +1,43 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright friend, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * friend, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.friend.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.modules.friend.entity.Friend; import org.springblade.modules.friend.vo.FriendVO; import java.util.List; /** * Mapper 接口 * * @author Chill */ public interface FriendMapper extends BaseMapper<Friend> { /** * 自定义分页 * * @param page 分页 * @param friend 实体 * @return List<FriendVO> */ List<FriendVO> selectFriendPage(IPage page, FriendVO friend); } src/main/java/org/springblade/modules/friend/mapper/FriendMapper.xml
New file @@ -0,0 +1,9 @@ <?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="org.springblade.modules.friend.mapper.FriendMapper"> <select id="selectFriendPage" resultType="org.springblade.modules.friend.vo.FriendVO"> select * from sys_friend </select> </mapper> src/main/java/org/springblade/modules/friend/service/IFriendService.java
New file @@ -0,0 +1,40 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright friend, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * friend, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.friend.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import org.springblade.modules.friend.entity.Friend; import org.springblade.modules.friend.vo.FriendVO; /** * 服务类 * * @author Chill */ public interface IFriendService extends IService<Friend> { /** * 自定义分页 * @param page * @param friend * @return */ IPage<FriendVO> selectFriendPage(IPage<FriendVO> page, FriendVO friend); } src/main/java/org/springblade/modules/friend/service/impl/FriendServiceImpl.java
New file @@ -0,0 +1,40 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright friend, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * friend, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.friend.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.modules.friend.entity.Friend; import org.springblade.modules.friend.mapper.FriendMapper; import org.springblade.modules.friend.service.IFriendService; import org.springblade.modules.friend.vo.FriendVO; import org.springframework.stereotype.Service; /** * 服务实现类 * * @author Chill */ @Service public class FriendServiceImpl extends ServiceImpl<FriendMapper, Friend> implements IFriendService { @Override public IPage<FriendVO> selectFriendPage(IPage<FriendVO> page, FriendVO friend) { return page.setRecords(baseMapper.selectFriendPage(page, friend)); } } src/main/java/org/springblade/modules/friend/vo/FriendVO.java
New file @@ -0,0 +1,19 @@ package org.springblade.modules.friend.vo; import lombok.Data; import lombok.EqualsAndHashCode; import org.springblade.modules.friend.entity.Friend; /** * 通知公告视图类 * * @author Chill */ @Data @EqualsAndHashCode(callSuper = true) public class FriendVO extends Friend { private static final long serialVersionUID = 1L; private String startTime; private String endTime; } src/main/java/org/springblade/modules/friend/wrapper/FriendWrapper.java
New file @@ -0,0 +1,43 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright friend, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * friend, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.friend.wrapper; import org.springblade.core.mp.support.BaseEntityWrapper; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.modules.friend.entity.Friend; import org.springblade.modules.friend.vo.FriendVO; import java.util.Objects; /** * Friend包装类,返回视图层所需的字段 * * @author Chill */ public class FriendWrapper extends BaseEntityWrapper<Friend, FriendVO> { public static FriendWrapper build() { return new FriendWrapper(); } @Override public FriendVO entityVO(Friend friend) { FriendVO friendVO = Objects.requireNonNull(BeanUtil.copy(friend, FriendVO.class)); return friendVO; } }