Merge branch 'master' of https://git.oa00.com/SWS/wxapp-back
commit
460df01518
@ -0,0 +1,44 @@
|
||||
package com.zh.project0512.controller.wxApp;
|
||||
|
||||
import com.zh.project0512.model.dto.AppMessageListDTO;
|
||||
import com.zh.project0512.model.vo.AppMessageListVo;
|
||||
import com.zh.project0512.service.IAppMessageService;
|
||||
import com.zh.project0512.utils.JwtUtil;
|
||||
import com.zh.project0512.utils.result.ResultPageInfo;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* app消息
|
||||
* </p>
|
||||
*
|
||||
* @author zh
|
||||
* @since 2022-05-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/wxApp/appMessage")
|
||||
@Tag(name = "app消息")
|
||||
public class AppMessageController {
|
||||
@Resource
|
||||
IAppMessageService appMessageService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有的app消息
|
||||
* @param appMessageListDTO app消息 list DTO
|
||||
* @return 所有的app消息
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResultPageInfo<AppMessageListVo> list(AppMessageListDTO appMessageListDTO,@RequestHeader(value = "token") @Parameter(name = "登录token") String token){
|
||||
String openid = new JwtUtil().parseOpenid(token);
|
||||
return ResultPageInfo.success(appMessageService.list(appMessageListDTO,openid),"请求成功");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zh.project0512.model.AppMessage;
|
||||
|
||||
public interface AppMessageMapper extends BaseMapper<AppMessage> {
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
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 lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* app消息
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("appMessage")
|
||||
public class AppMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@TableField("id")
|
||||
private Integer id;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
@TableField("type")
|
||||
private Integer type;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@TableField("title")
|
||||
private String title;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField("describe")
|
||||
private String describe;
|
||||
/**
|
||||
* url
|
||||
*/
|
||||
@TableField("url")
|
||||
private String url;
|
||||
/**
|
||||
* 发送人openid
|
||||
*/
|
||||
@TableField("sendId")
|
||||
private String sendOpenId;
|
||||
/**
|
||||
* 接收人openid
|
||||
*/
|
||||
@TableField("receiverId")
|
||||
private String receiverOpenId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("createDate")
|
||||
private Date createDate;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.zh.project0512.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* app消息 list DTO
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AppMessageListDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private int pageNum;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int pageSize;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.zh.project0512.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* app消息 list Vo
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AppMessageListVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 消息类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String describe;
|
||||
/**
|
||||
* url
|
||||
*/
|
||||
private String url;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.zh.project0512.service;
|
||||
|
||||
import com.zh.project0512.model.dto.AppMessageListDTO;
|
||||
import com.zh.project0512.model.vo.AppMessageListVo;
|
||||
import com.zh.project0512.utils.page.PageInfo;
|
||||
|
||||
public interface IAppMessageService {
|
||||
/**
|
||||
* 查询所有的app消息
|
||||
* @param appMessageListDTO app消息 list DTO
|
||||
* @param openid openid
|
||||
* @return app消息 list Vo
|
||||
*/
|
||||
PageInfo<AppMessageListVo> list(AppMessageListDTO appMessageListDTO, String openid);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.zh.project0512.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.zh.project0512.mapper.AppMessageMapper;
|
||||
import com.zh.project0512.model.AdminRole;
|
||||
import com.zh.project0512.model.AppMessage;
|
||||
import com.zh.project0512.model.dto.AppMessageListDTO;
|
||||
import com.zh.project0512.model.vo.AdminRoleListVo;
|
||||
import com.zh.project0512.model.vo.AppMessageListVo;
|
||||
import com.zh.project0512.service.IAppMessageService;
|
||||
import com.zh.project0512.utils.PropertyUtils;
|
||||
import com.zh.project0512.utils.page.PageInfo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AppMessageServiceImpl implements IAppMessageService {
|
||||
@Resource
|
||||
AppMessageMapper appMessageMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<AppMessageListVo> list(AppMessageListDTO appMessageListDTO, String openid) {
|
||||
ArrayList<AppMessageListVo> appMessageListVos = new ArrayList<>();
|
||||
QueryWrapper<AppMessage> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(appMessageListDTO.getType() != null,"type", appMessageListDTO.getType());
|
||||
|
||||
Page<AppMessage> page = new Page<>(appMessageListDTO.getPageNum(), appMessageListDTO.getPageSize());
|
||||
IPage<AppMessage> appMessageIPage = appMessageMapper.selectPage(page, queryWrapper);
|
||||
List<AppMessage> records = appMessageIPage.getRecords();
|
||||
if (records != null && records.size()>0){
|
||||
for (AppMessage record : records) {
|
||||
AppMessageListVo appMessageListVo = new AppMessageListVo();
|
||||
PropertyUtils.copyProperties(record, appMessageListVo);
|
||||
appMessageListVos.add(appMessageListVo);
|
||||
}
|
||||
}
|
||||
|
||||
return new PageInfo<>(appMessageIPage.getPages(), appMessageListVos, appMessageIPage.getTotal());
|
||||
}
|
||||
}
|
Loading…
Reference in new issue