Browse Source

Merge branch 'dev' into pre-production

pre-production
pref_mail@163.com 3 months ago
parent
commit
7dd7464365
  1. 153
      blade-service/blade-desk/src/main/java/org/springblade/desk/controller/NoticeController.java
  2. 54
      blade-service/blade-desk/src/main/java/org/springblade/desk/feign/NoticeClient.java
  3. 50
      blade-service/blade-desk/src/main/java/org/springblade/desk/mapper/NoticeMapper.java
  4. 54
      blade-service/blade-desk/src/main/java/org/springblade/desk/mapper/NoticeMapper.xml
  5. 39
      blade-service/blade-desk/src/main/java/org/springblade/desk/service/INoticeService.java
  6. 43
      blade-service/blade-desk/src/main/java/org/springblade/desk/service/impl/NoticeServiceImpl.java
  7. 64
      blade-service/blade-desk/src/main/java/org/springblade/desk/wrapper/NoticeWrapper.java
  8. 3
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RegionServiceImpl.java

153
blade-service/blade-desk/src/main/java/org/springblade/desk/controller/NoticeController.java

@ -1,153 +0,0 @@
/*
* 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.desk.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.BladePage;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.secure.constant.AuthConstant;
import org.springblade.core.tenant.annotation.TenantDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.desk.entity.Notice;
import org.springblade.desk.feign.INoticeClient;
import org.springblade.desk.service.INoticeService;
import org.springblade.desk.vo.NoticeVO;
import org.springblade.desk.wrapper.NoticeWrapper;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
* 控制器
*
* @author Chill
*/
@PreAuth(AuthConstant.HAS_CRYPTO)
@TenantDS
@RestController
@RequestMapping("notice")
@AllArgsConstructor
@Api(value = "用户博客", tags = "博客接口")
public class NoticeController extends BladeController {
private final INoticeService noticeService;
private final INoticeClient noticeClient;
/**
* 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "详情", notes = "传入notice")
public R<NoticeVO> detail(Notice notice) {
Notice detail = noticeService.getOne(Condition.getQueryWrapper(notice));
return R.data(NoticeWrapper.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 = "传入notice")
public R<IPage<NoticeVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) {
NoticeWrapper.build().noticeQuery(notice);
IPage<Notice> pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, Notice.class));
return R.data(NoticeWrapper.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 = "传入notice")
public R<IPage<NoticeVO>> page(@ApiIgnore NoticeVO notice, Query query) {
IPage<NoticeVO> pages = noticeService.selectNoticePage(Condition.getPage(query), notice);
return R.data(pages);
}
/**
* 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增", notes = "传入notice")
public R save(@RequestBody Notice notice) {
return R.status(noticeService.save(notice));
}
/**
* 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入notice")
public R update(@RequestBody Notice notice) {
return R.status(noticeService.updateById(notice));
}
/**
* 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@ApiOperation(value = "新增或修改", notes = "传入notice")
public R submit(@RequestBody Notice notice) {
return R.status(noticeService.saveOrUpdate(notice));
}
/**
* 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@ApiOperation(value = "逻辑删除", notes = "传入notice")
public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
boolean temp = noticeService.deleteLogic(Func.toLongList(ids));
return R.status(temp);
}
/**
* 远程调用分页接口
*/
@GetMapping("/top")
@ApiOperationSupport(order = 8)
@ApiOperation(value = "分页远程调用", notes = "传入current,size")
public R<BladePage<Notice>> top(@ApiParam(value = "当前页") @RequestParam Integer current, @ApiParam(value = "每页显示条数") @RequestParam Integer size) {
BladePage<Notice> page = noticeClient.top(current, size);
return R.data(page);
}
}

54
blade-service/blade-desk/src/main/java/org/springblade/desk/feign/NoticeClient.java

@ -1,54 +0,0 @@
/*
* 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.desk.feign;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.BladePage;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.desk.entity.Notice;
import org.springblade.desk.service.INoticeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
/**
* Notice Feign
*
* @author Chill
*/
@NonDS
@ApiIgnore()
@RestController
@AllArgsConstructor
public class NoticeClient implements INoticeClient {
private final INoticeService service;
@Override
@GetMapping(TOP)
public BladePage<Notice> top(Integer current, Integer size) {
Query query = new Query();
query.setCurrent(current);
query.setSize(size);
IPage<Notice> page = service.page(Condition.getPage(query));
return BladePage.of(page);
}
}

50
blade-service/blade-desk/src/main/java/org/springblade/desk/mapper/NoticeMapper.java

@ -1,50 +0,0 @@
/*
* 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.desk.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.desk.entity.Notice;
import org.springblade.desk.vo.NoticeVO;
import java.util.List;
/**
* Mapper 接口
*
* @author Chill
*/
public interface NoticeMapper extends BaseMapper<Notice> {
/**
* 前N条数据
*
* @param number 数量
* @return List<Notice>
*/
List<Notice> topList(Integer number);
/**
* 自定义分页
*
* @param page 分页
* @param notice 实体
* @return List<NoticeVO>
*/
List<NoticeVO> selectNoticePage(IPage page, NoticeVO notice);
}

54
blade-service/blade-desk/src/main/java/org/springblade/desk/mapper/NoticeMapper.xml

@ -1,54 +0,0 @@
<?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.desk.mapper.NoticeMapper">
<!-- 通用查询映射结果 -->
<resultMap id="noticeResultMap" type="org.springblade.desk.entity.Notice">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="release_time" property="releaseTime"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
</resultMap>
<!-- 通用查询映射结果 -->
<resultMap id="noticeVOResultMap" type="org.springblade.desk.vo.NoticeVO">
<result column="id" property="id"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="release_time" property="releaseTime"/>
<result column="title" property="title"/>
<result column="content" property="content"/>
</resultMap>
<select id="topList" resultMap="noticeResultMap">
select * from blade_notice limit #{number}
</select>
<select id="selectNoticePage" resultMap="noticeVOResultMap">
SELECT
n.*,
d.dict_value AS categoryName
FROM
blade_notice n
LEFT JOIN ( SELECT * FROM blade_dict WHERE CODE = 'notice' ) d ON n.category = d.dict_key
WHERE
n.is_deleted = 0 and n.tenant_id = #{notice.tenantId}
<if test="notice.title!=null">
and n.title like concat(concat('%', #{notice.title}), '%')
</if>
<if test="notice.category!=null">
and n.category = #{notice.category}
</if>
</select>
</mapper>

39
blade-service/blade-desk/src/main/java/org/springblade/desk/service/INoticeService.java

@ -1,39 +0,0 @@
/*
* 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.desk.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.desk.entity.Notice;
import org.springblade.desk.vo.NoticeVO;
/**
* 服务类
*
* @author Chill
*/
public interface INoticeService extends BaseService<Notice> {
/**
* 自定义分页
* @param page
* @param notice
* @return
*/
IPage<NoticeVO> selectNoticePage(IPage<NoticeVO> page, NoticeVO notice);
}

43
blade-service/blade-desk/src/main/java/org/springblade/desk/service/impl/NoticeServiceImpl.java

@ -1,43 +0,0 @@
/*
* 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.desk.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.desk.entity.Notice;
import org.springblade.desk.mapper.NoticeMapper;
import org.springblade.desk.service.INoticeService;
import org.springblade.desk.vo.NoticeVO;
import org.springframework.stereotype.Service;
/**
* 服务实现类
*
* @author Chill
*/
@Service
public class NoticeServiceImpl extends BaseServiceImpl<NoticeMapper, Notice> implements INoticeService {
@Override
public IPage<NoticeVO> selectNoticePage(IPage<NoticeVO> page, NoticeVO notice) {
// 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
notice.setTenantId(AuthUtil.getTenantId());
return page.setRecords(baseMapper.selectNoticePage(page, notice));
}
}

64
blade-service/blade-desk/src/main/java/org/springblade/desk/wrapper/NoticeWrapper.java

@ -1,64 +0,0 @@
/*
* 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.desk.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.desk.entity.Notice;
import org.springblade.desk.vo.NoticeVO;
import org.springblade.system.cache.DictCache;
import org.springblade.system.enums.DictEnum;
import java.util.Map;
import java.util.Objects;
/**
* Notice包装类,返回视图层所需的字段
*
* @author Chill
*/
public class NoticeWrapper extends BaseEntityWrapper<Notice, NoticeVO> {
public static NoticeWrapper build() {
return new NoticeWrapper();
}
@Override
public NoticeVO entityVO(Notice notice) {
NoticeVO noticeVO = Objects.requireNonNull(BeanUtil.copy(notice, NoticeVO.class));
String dictValue = DictCache.getValue(DictEnum.NOTICE, noticeVO.getCategory());
noticeVO.setCategoryName(dictValue);
return noticeVO;
}
/**
* 查询条件处理
*/
public void noticeQuery(Map<String, Object> notice) {
// 此场景仅在 pg数据库 map类型传参的情况下需要处理,entity传参已经包含数据类型,则无需关心
// 针对 pg数据库 int类型字段查询需要强转的处理示例
String searchKey = "category";
if (Func.isNotEmpty(notice.get(searchKey))) {
// 数据库字段为int类型,设置"="查询,具体查询参数请见 @org.springblade.core.mp.support.SqlKeyword
notice.put(searchKey.concat("_equal"), Func.toInt(notice.get(searchKey)));
// 默认"like"查询,pg数据库 场景会报错,所以将其删除
notice.remove(searchKey);
}
}
}

3
blade-service/blade-system/src/main/java/org/springblade/system/service/impl/RegionServiceImpl.java

@ -37,6 +37,7 @@ import org.springblade.system.service.IRegionService;
import org.springblade.system.vo.RegionAllVO;
import org.springblade.system.vo.RegionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@ -69,6 +70,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
private BladeRedis bladeRedis;
@Override
@CacheEvict(cacheNames = "blade:sys:regions")
public boolean submit(Region region) {
// 设置市级编号格式
String regionCode = region.getCode();
@ -114,6 +116,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
}
@Override
@CacheEvict(cacheNames = "blade:sys:regions")
public boolean removeRegion(String id) {
Long cnt = baseMapper.selectCount(Wrappers.<Region>query().lambda().eq(Region::getParentCode, id));
if (cnt > 0L) {

Loading…
Cancel
Save