Commit ce7cd666 by giaogiao

App意见反馈

parent 36826bc2
package com.jumeirah.api.app.controller;
import com.jumeirah.common.entity.Feedback;
import com.jumeirah.common.service.FeedbackService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.geekidea.springbootplus.framework.shiro.jwt.JwtToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 意见反馈 控制器
*
* @author giao
* @since 2020-10-26
*/
@Slf4j
@RestController
@RequestMapping("/app/feedback")
@Api(value = "意见反馈API", tags = {"意见反馈"})
public class FeedbackController extends BaseController {
@Autowired
private FeedbackService feedbackService;
/**
* 添加意见反馈
*/
@PostMapping("/add")
@OperationLog(name = "添加意见反馈", type = OperationLogType.ADD)
@ApiOperation(value = "添加意见反馈")
public ApiResult<Boolean> addFeedback(@Validated(Add.class) @RequestBody Feedback feedback) throws Exception {
JwtToken jwtToken = (JwtToken) SecurityUtils.getSubject().getPrincipal();
feedback.setUserId(jwtToken.getUserId());
boolean flag = feedbackService.saveFeedback(feedback);
return ApiResult.result(flag);
}
//
// /**
// * 修改意见反馈
// */
// @PostMapping("/update")
// @OperationLog(name = "修改意见反馈", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改意见反馈")
// public ApiResult<Boolean> updateFeedback(@Validated(Update.class) @RequestBody Feedback feedback) throws Exception {
// boolean flag = feedbackService.updateFeedback(feedback);
// return ApiResult.result(flag);
// }
//
// /**
// * 删除意见反馈
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除意见反馈", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除意见反馈")
// public ApiResult<Boolean> deleteFeedback(@PathVariable("id") Long id) throws Exception {
// boolean flag = feedbackService.deleteFeedback(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取意见反馈详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "意见反馈详情", type = OperationLogType.INFO)
// @ApiOperation(value = "意见反馈详情")
// public ApiResult<FeedbackQueryVo> getFeedback(@PathVariable("id") Long id) throws Exception {
// FeedbackQueryVo feedbackQueryVo = feedbackService.getFeedbackById(id);
// return ApiResult.ok(feedbackQueryVo);
// }
//
// /**
// * 意见反馈分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "意见反馈分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "意见反馈分页列表")
// public ApiResult<Paging<FeedbackQueryVo>> getFeedbackPageList(@Validated @RequestBody FeedbackPageParam feedbackPageParam) throws Exception {
// Paging<FeedbackQueryVo> paging = feedbackService.getFeedbackPageList(feedbackPageParam);
// return ApiResult.ok(paging);
// }
}
package com.jumeirah.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 意见反馈
*
* @author giao
* @since 2020-10-26
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Feedback对象")
public class Feedback extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "不能为空")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private String content;
private Long userId;
@ApiModelProperty("Create Time")
private Date createTime;
@ApiModelProperty("Update Time")
private Date updateTime;
}
package com.jumeirah.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jumeirah.common.entity.Feedback;
import com.jumeirah.common.param.FeedbackPageParam;
import com.jumeirah.common.param.FeedbackQueryVo;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.io.Serializable;
/**
* 意见反馈 Mapper 接口
*
* @author giao
* @since 2020-10-26
*/
@Repository
public interface FeedbackMapper extends BaseMapper<Feedback> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
FeedbackQueryVo getFeedbackById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param feedbackPageParam
* @return
*/
IPage<FeedbackQueryVo> getFeedbackPageList(@Param("page") Page page,@Param("param") FeedbackPageParam feedbackPageParam);
}
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/**
* <pre>
* 意见反馈 分页参数对象
* </pre>
*
* @author giao
* @date 2020-10-26
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "意见反馈分页参数")
public class FeedbackPageParam extends BasePageOrderParam{
private static final long serialVersionUID=1L;
}
package com.jumeirah.common.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <pre>
* 意见反馈 查询结果对象
* </pre>
*
* @author giao
* @date 2020-10-26
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "FeedbackQueryVo对象")
public class FeedbackQueryVo implements Serializable{
private static final long serialVersionUID=1L;
private Long id;
private String content;
private Long userId;
@ApiModelProperty("Create Time")
private Date createTime;
@ApiModelProperty("Update Time")
private Date updateTime;
}
\ No newline at end of file
package com.jumeirah.common.service;
import com.jumeirah.common.entity.Feedback;
import com.jumeirah.common.param.FeedbackPageParam;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import com.jumeirah.common.param.FeedbackQueryVo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
* 意见反馈 服务类
*
* @author giao
* @since 2020-10-26
*/
public interface FeedbackService extends BaseService<Feedback> {
/**
* 保存
*
* @param feedback
* @return
* @throws Exception
*/
boolean saveFeedback(Feedback feedback)throws Exception;
/**
* 修改
*
* @param feedback
* @return
* @throws Exception
*/
boolean updateFeedback(Feedback feedback)throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteFeedback(Long id)throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
FeedbackQueryVo getFeedbackById(Long id)throws Exception;
/**
* 获取分页对象
*
* @param feedbackPageParam
* @return
* @throws Exception
*/
Paging<FeedbackQueryVo> getFeedbackPageList(FeedbackPageParam feedbackPageParam) throws Exception;
}
package com.jumeirah.common.service.impl;
import com.jumeirah.common.entity.Feedback;
import com.jumeirah.common.mapper.FeedbackMapper;
import com.jumeirah.common.service.FeedbackService;
import com.jumeirah.common.param.FeedbackPageParam;
import com.jumeirah.common.param.FeedbackQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 意见反馈 服务实现类
*
* @author giao
* @since 2020-10-26
*/
@Slf4j
@Service
public class FeedbackServiceImpl extends BaseServiceImpl<FeedbackMapper, Feedback> implements FeedbackService {
@Autowired
private FeedbackMapper feedbackMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveFeedback(Feedback feedback)throws Exception{
return super.save(feedback);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateFeedback(Feedback feedback)throws Exception{
return super.updateById(feedback);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteFeedback(Long id)throws Exception{
return super.removeById(id);
}
@Override
public FeedbackQueryVo getFeedbackById(Long id)throws Exception{
return feedbackMapper.getFeedbackById(id);
}
@Override
public Paging<FeedbackQueryVo> getFeedbackPageList(FeedbackPageParam feedbackPageParam)throws Exception{
Page<FeedbackQueryVo> page=new PageInfo<>(feedbackPageParam,OrderItem.desc(getLambdaColumn(Feedback::getCreateTime)));
IPage<FeedbackQueryVo> iPage= feedbackMapper.getFeedbackPageList(page, feedbackPageParam);
return new Paging<FeedbackQueryVo>(iPage);
}
}
<?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.jumeirah.common.mapper.FeedbackMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, content, user_id, create_time, update_time
</sql>
<select id="getFeedbackById" resultType="com.jumeirah.common.param.FeedbackQueryVo">
select
<include refid="Base_Column_List"/>
from feedback where id = #{id}
</select>
<select id="getFeedbackPageList" parameterType="com.jumeirah.common.param.FeedbackPageParam" resultType="com.jumeirah.common.param.FeedbackQueryVo">
select
<include refid="Base_Column_List"/>
from feedback
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment