11 changed files with 631 additions and 0 deletions
@ -0,0 +1,64 @@
|
||||
/* |
||||
* 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 com.logpm.basic.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.tenant.mp.TenantEntity; |
||||
|
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* |
||||
* |
||||
* @author pref |
||||
*/ |
||||
@Data |
||||
@TableName("logpm_basic_notice") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class BasicNotice extends TenantEntity { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
/** |
||||
* 标题 |
||||
*/ |
||||
@ApiModelProperty(value = "标题") |
||||
private String title; |
||||
|
||||
/** |
||||
* 通知类型 |
||||
*/ |
||||
@ApiModelProperty(value = "通知类型") |
||||
private Integer category; |
||||
|
||||
/** |
||||
* 发布日期 |
||||
*/ |
||||
@ApiModelProperty(value = "发布日期") |
||||
private Date releaseTime; |
||||
|
||||
/** |
||||
* 内容 |
||||
*/ |
||||
@ApiModelProperty(value = "内容") |
||||
private String content; |
||||
|
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
/* |
||||
* 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 com.logpm.basic.feign; |
||||
|
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import org.springblade.core.launch.constant.AppConstant; |
||||
import org.springblade.core.mp.support.BladePage; |
||||
import org.springframework.cloud.openfeign.FeignClient; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
||||
/** |
||||
* Notice Feign接口类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@FeignClient( |
||||
value = AppConstant.APPLICATION_DESK_NAME |
||||
) |
||||
public interface IBasicNoticeClient { |
||||
|
||||
String API_PREFIX = "/client"; |
||||
String TOP = API_PREFIX + "/top"; |
||||
|
||||
/** |
||||
* 获取notice列表 |
||||
* |
||||
* @param current |
||||
* @param size |
||||
* @return |
||||
*/ |
||||
@GetMapping(TOP) |
||||
BladePage<BasicNotice> top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); |
||||
|
||||
} |
@ -0,0 +1,23 @@
|
||||
package com.logpm.basic.vo; |
||||
|
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
/** |
||||
* 通知公告视图类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
public class BasicNoticeVO extends BasicNotice { |
||||
|
||||
@ApiModelProperty(value = "通知类型名") |
||||
private String categoryName; |
||||
|
||||
@ApiModelProperty(value = "租户编号") |
||||
private String tenantId; |
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.logpm.basic.api; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.logpm.basic.entity.BasicMaterialEntity; |
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.mapper.BasicNoticeMapper; |
||||
import com.logpm.basic.service.IBasicMaterialService; |
||||
import com.logpm.basic.service.IBasicNoticeService; |
||||
import com.logpm.basic.vo.BasicNoticeVO; |
||||
import com.logpm.basic.wrapper.BasicNoticeWrapper; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.Func; |
||||
import org.springblade.core.tool.utils.SpringUtil; |
||||
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 java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/app/basicNotice") |
||||
@Api(value = "通知公告", tags = "通知公告") |
||||
public class BasicNoticeApi { |
||||
|
||||
private final IBasicNoticeService noticeService; |
||||
@GetMapping("/list") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "查询增值服务列表", notes = "DistributionAppDeliveryListDTO") |
||||
public R<List<BasicNoticeVO>> list() { |
||||
List<BasicNotice> list = noticeService.list(); |
||||
List<BasicNoticeVO> data = new ArrayList<>(); |
||||
for (BasicNotice notice : list) { |
||||
BasicNoticeVO vo = BasicNoticeWrapper.build().entityVO(notice); |
||||
data.add(vo); |
||||
} |
||||
return R.data(data); |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,141 @@
|
||||
/* |
||||
* 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 com.logpm.basic.controller; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.service.IBasicNoticeService; |
||||
import com.logpm.basic.vo.BasicNoticeVO; |
||||
import com.logpm.basic.wrapper.BasicNoticeWrapper; |
||||
import com.mysql.cj.protocol.x.Notice; |
||||
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.springframework.web.bind.annotation.*; |
||||
import springfox.documentation.annotations.ApiIgnore; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 控制器 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@RestController |
||||
@RequestMapping("notice") |
||||
@AllArgsConstructor |
||||
@Api(value = "通知公告", tags = "通知公告") |
||||
public class BasicNoticeController extends BladeController { |
||||
|
||||
private final IBasicNoticeService noticeService; |
||||
|
||||
|
||||
/** |
||||
* 详情 |
||||
*/ |
||||
@GetMapping("/detail") |
||||
@ApiOperationSupport(order = 1) |
||||
@ApiOperation(value = "详情", notes = "传入notice") |
||||
public R<BasicNoticeVO> detail(BasicNotice notice) { |
||||
BasicNotice detail = noticeService.getOne(Condition.getQueryWrapper(notice)); |
||||
return R.data(BasicNoticeWrapper.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<BasicNoticeVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) { |
||||
BasicNoticeWrapper.build().noticeQuery(notice); |
||||
IPage<BasicNotice> pages = noticeService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, BasicNotice.class)); |
||||
return R.data(BasicNoticeWrapper.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<BasicNoticeVO>> page(@ApiIgnore BasicNoticeVO notice, Query query) { |
||||
IPage<BasicNoticeVO> pages = noticeService.selectNoticePage(Condition.getPage(query), notice); |
||||
return R.data(pages); |
||||
} |
||||
|
||||
/** |
||||
* 新增 |
||||
*/ |
||||
@PostMapping("/save") |
||||
@ApiOperationSupport(order = 4) |
||||
@ApiOperation(value = "新增", notes = "传入notice") |
||||
public R save(@RequestBody BasicNotice notice) { |
||||
return R.status(noticeService.save(notice)); |
||||
} |
||||
|
||||
/** |
||||
* 修改 |
||||
*/ |
||||
@PostMapping("/update") |
||||
@ApiOperationSupport(order = 5) |
||||
@ApiOperation(value = "修改", notes = "传入notice") |
||||
public R update(@RequestBody BasicNotice notice) { |
||||
return R.status(noticeService.updateById(notice)); |
||||
} |
||||
|
||||
/** |
||||
* 新增或修改 |
||||
*/ |
||||
@PostMapping("/submit") |
||||
@ApiOperationSupport(order = 6) |
||||
@ApiOperation(value = "新增或修改", notes = "传入notice") |
||||
public R submit(@RequestBody BasicNotice 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); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
/* |
||||
* 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 com.logpm.basic.feign; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.service.IBasicNoticeService; |
||||
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.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 BasicNoticeClient implements IBasicNoticeClient { |
||||
|
||||
private final IBasicNoticeService service; |
||||
|
||||
@Override |
||||
@GetMapping(TOP) |
||||
public BladePage<BasicNotice> top(Integer current, Integer size) { |
||||
Query query = new Query(); |
||||
query.setCurrent(current); |
||||
query.setSize(size); |
||||
IPage<BasicNotice> page = service.page(Condition.getPage(query)); |
||||
return BladePage.of(page); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,50 @@
|
||||
/* |
||||
* 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 com.logpm.basic.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.vo.BasicNoticeVO; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Mapper 接口 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface BasicNoticeMapper extends BaseMapper<BasicNotice> { |
||||
|
||||
/** |
||||
* 前N条数据 |
||||
* |
||||
* @param number 数量 |
||||
* @return List<Notice> |
||||
*/ |
||||
List<BasicNotice> topList(Integer number); |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* |
||||
* @param page 分页 |
||||
* @param notice 实体 |
||||
* @return List<NoticeVO> |
||||
*/ |
||||
List<BasicNoticeVO> selectNoticePage(IPage page, BasicNoticeVO notice); |
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
<?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.logpm.basic.mapper.BasicNoticeMapper"> |
||||
|
||||
<!-- 通用查询映射结果 --> |
||||
<resultMap id="noticeResultMap" type="com.logpm.basic.entity.BasicNotice"> |
||||
<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="com.logpm.basic.vo.BasicNoticeVO"> |
||||
<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 logpm_basic_notice limit #{number} |
||||
</select> |
||||
|
||||
<select id="selectNoticePage" resultMap="noticeVOResultMap"> |
||||
SELECT |
||||
n.* |
||||
<!-- d.dict_value AS categoryName--> |
||||
FROM |
||||
logpm_basic_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> |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* 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 com.logpm.basic.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.vo.BasicNoticeVO; |
||||
import org.springblade.core.mp.base.BaseService; |
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
public interface IBasicNoticeService extends BaseService<BasicNotice> { |
||||
|
||||
/** |
||||
* 自定义分页 |
||||
* @param page |
||||
* @param notice |
||||
* @return |
||||
*/ |
||||
IPage<BasicNoticeVO> selectNoticePage(IPage<BasicNoticeVO> page, BasicNoticeVO notice); |
||||
|
||||
} |
@ -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 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 com.logpm.basic.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.mapper.BasicNoticeMapper; |
||||
import com.logpm.basic.service.IBasicNoticeService; |
||||
import com.logpm.basic.vo.BasicNoticeVO; |
||||
import org.springblade.core.mp.base.BaseServiceImpl; |
||||
import org.springblade.core.secure.utils.AuthUtil; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author Chill |
||||
*/ |
||||
@Service |
||||
public class BasicNoticeServiceImpl extends BaseServiceImpl<BasicNoticeMapper, BasicNotice> implements IBasicNoticeService { |
||||
|
||||
@Override |
||||
public IPage<BasicNoticeVO> selectNoticePage(IPage<BasicNoticeVO> page, BasicNoticeVO notice) { |
||||
// 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
|
||||
notice.setTenantId(AuthUtil.getTenantId()); |
||||
return page.setRecords(baseMapper.selectNoticePage(page, notice)); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,65 @@
|
||||
/* |
||||
* 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 com.logpm.basic.wrapper; |
||||
|
||||
import com.logpm.basic.entity.BasicNotice; |
||||
import com.logpm.basic.vo.BasicNoticeVO; |
||||
import com.mysql.cj.protocol.x.Notice; |
||||
import org.springblade.core.mp.support.BaseEntityWrapper; |
||||
import org.springblade.core.tool.utils.BeanUtil; |
||||
import org.springblade.core.tool.utils.Func; |
||||
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 BasicNoticeWrapper extends BaseEntityWrapper<BasicNotice, BasicNoticeVO> { |
||||
|
||||
public static BasicNoticeWrapper build() { |
||||
return new BasicNoticeWrapper(); |
||||
} |
||||
|
||||
@Override |
||||
public BasicNoticeVO entityVO(BasicNotice notice) { |
||||
BasicNoticeVO noticeVO = Objects.requireNonNull(BeanUtil.copy(notice, BasicNoticeVO.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); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue