快捷餐饮之店家后台评论管理及餐桌管理实现

简介: 快捷餐饮之店家后台评论管理及餐桌管理实现


一、评论管理


评论是客户在就完餐之后,对店里的一些服务,菜品及环境的一些评价,所有店家后台这边只能是对评论的查询和删除,不可以对这些评论进行添加和修改相关的功能,那了解了这些,是不是业务流程就清晰了呢!


客户产生评论数据,他也是不可以修改的

店家这边可以查询评论和删除这些评论没有修改功能!


1.1 创建查询条件VO


image.png


/**
 * @Package: cn.liuliang.quickdinesysstore.entity.vo
 * @Author: liuliang
 * @CreateTime: 2020/10/29 - 15:54
 * @Description:
 */
@Data
@ApiModel(value="评论查询条件vo", description="")
public class EvaluateQueryConditionVO {
    @ApiModelProperty(value = "评价人身份:游客,用户,会员")
    private String identityType;
    @ApiModelProperty(value = "标识:1,菜品口味;2,服务态度;3,店内环境;4,总体评价")
    private Integer per;
    @ApiModelProperty(value = "星值:1代表一星,依次类推,最高五星")
    private Integer perValue;
    @ApiModelProperty(value = "评价时间(格式:2020-02-20)")
    private String evaluateTime;
}


1.2 创建评论数据展示DTO


image.png


/**
 * <p>
 * 
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
@Data
@ApiModel(value="评价信息DTO", description="")
public class EvaluateDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "ID")
    private Long id;
    @ApiModelProperty(value = "评价人姓名:(游客就是游客)")
    private String evaluateName;
    @ApiModelProperty(value = "评价人账号:(游客就为空)")
    private String phone;
    @ApiModelProperty(value = "评价人身份:(游客就写游客)")
    private String identityType;
    @ApiModelProperty(value = "店家名称")
    private String storeName;
    @ApiModelProperty(value = "菜品口味:1代表一星,依次类推,最高五星")
    private Integer taste;
    @ApiModelProperty(value = "服务态度:1代表一星,依次类推,最高五星")
    private Integer attitude;
    @ApiModelProperty(value = "店内环境:1代表一星,依次类推,最高五星")
    private Integer environment;
    @ApiModelProperty(value = "总体评价:1代表一星,依次类推,最高五星")
    private Integer overallEvaluation;
    @ApiModelProperty(value = "意见")
    private String opinion;
    @ApiModelProperty(value = "评价时间")
    private Date createTime;
}


1.3 编写controller


image.png


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
@Api(value = "评价管理", tags = "评价管理")
@CrossOrigin
@RestController
@RequestMapping("/evaluate")
public class EvaluateController {
    @Autowired
    private EvaluateService evaluateService;
    @ApiOperation(value = "条件分页查看所有评论信息", notes = "条件分页查看所有评论信息")
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功!", response = EvaluateDTO.class)})
    @GetMapping("/select-all")
    public ResultDTO selectAll(
            EvaluateQueryConditionVO evaluateQueryConditionVO,
            @ApiParam("当前页码") @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @ApiParam("每页显示条数") @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return evaluateService.selectAll(evaluateQueryConditionVO, pageNum, pageSize);
    }
    @ApiOperation(value = "根据评论id删除评论", notes = "根据评论id删除评论")
    @GetMapping("/delete")
    public ResultDTO delete(@ApiParam("评论id") @RequestParam(value = "id", required = true) Long id) {
        evaluateService.removeById(id);
        return ResultDTO.success();
    }
}


1.4 编写service


image.png


/**
 * <p>
 *  服务类
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
public interface EvaluateService extends IService<Evaluate> {
    /**
     * 条件分查看所有评论信息
     * @param evaluateQueryConditionVO  查询条件
     * @param pageNum                   当前页
     * @param pageSize                  每页大小
     * @return
     */
    ResultDTO selectAll(EvaluateQueryConditionVO evaluateQueryConditionVO, Integer pageNum, Integer pageSize);
}


/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
@Service
public class EvaluateServiceImpl extends ServiceImpl<EvaluateMapper, Evaluate> implements EvaluateService {
    @Autowired
    private EvaluateMapper evaluateMapper;
    @Override
    public ResultDTO selectAll(EvaluateQueryConditionVO evaluateQueryConditionVO, Integer pageNum, Integer pageSize) {
        // 构造分页
        Page<Evaluate> evaluatePage = new Page<>(pageNum, pageSize);
        // 执行查询
        List<Evaluate> evaluateList = evaluateMapper.selectAll(evaluatePage, evaluateQueryConditionVO);
        // 构造传输数据
        List<EvaluateDTO> evaluateDTOList = new ArrayList<>(evaluateList.size());
        evaluateList.forEach(evaluate -> {
            EvaluateDTO evaluateDTO = new EvaluateDTO();
            BeanUtils.copyProperties(evaluate, evaluateDTO);
            evaluateDTOList.add(evaluateDTO);
        });
        return ResultDTO.success().data("total", evaluatePage.getTotal()).data("rows", evaluateDTOList);
    }
}


1.5 编写Mapper及Mapper映射文件


image.png


/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
public interface EvaluateMapper extends BaseMapper<Evaluate> {
    /**
     * 根据条件分页查询评论数据
     *
     * @param evaluatePage             分页对象
     * @param evaluateQueryConditionVO 查询条件对象
     * @return
     */
    List<Evaluate> selectAll(@Param("evaluatePage") Page<Evaluate> evaluatePage, @Param("evaluateQueryConditionVO") EvaluateQueryConditionVO evaluateQueryConditionVO);
}


<?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="cn.liuliang.quickdinesysstore.mapper.EvaluateMapper">
    <resultMap id="evaluate" type="cn.liuliang.quickdinesysstore.entity.Evaluate">
        <result property="id" javaType="long" column="id"/>
        <result property="evaluateName" javaType="string" column="evaluate_name"/>
        <result property="phone" javaType="string" column="phone"/>
        <result property="identityType" javaType="string" column="identity_type"/>
        <result property="storeName" javaType="string" column="store_name"/>
        <result property="taste" javaType="integer" column="taste"/>
        <result property="attitude" javaType="integer" column="attitude"/>
        <result property="environment" javaType="integer" column="environment"/>
        <result property="overallEvaluation" javaType="integer" column="overall_evaluation"/>
        <result property="opinion" javaType="string" column="opinion"/>
        <result property="createTime" javaType="date" column="create_time"/>
    </resultMap>
    <select id="selectAll" resultMap="evaluate">
        SELECT
        t_evaluate.`id`,
        t_evaluate.`evaluate_name`,
        t_evaluate.`phone`,
        t_evaluate.`identity_type`,
        t_evaluate.`store_name`,
        t_evaluate.`taste`,
        t_evaluate.`attitude`,
        t_evaluate.`environment`,
        t_evaluate.`overall_evaluation`,
        t_evaluate.`opinion`,
        t_evaluate.`create_time`
        FROM t_evaluate
        WHERE
        t_evaluate.`store_name` = '鲲鹏膳'
        <if test="evaluateQueryConditionVO.identityType != null and evaluateQueryConditionVO.identityType != ''">
            AND t_evaluate.`identity_type` = #{evaluateQueryConditionVO.identityType}
        </if>
        <if test="evaluateQueryConditionVO.per != null and evaluateQueryConditionVO.per == 1">
            AND t_evaluate.`taste` = #{evaluateQueryConditionVO.perValue}
        </if>
        <if test="evaluateQueryConditionVO.per != null and evaluateQueryConditionVO.per == 2">
            AND t_evaluate.`attitude` = #{evaluateQueryConditionVO.perValue}
        </if>
        <if test="evaluateQueryConditionVO.per != null and evaluateQueryConditionVO.per == 3">
            AND t_evaluate.`environment` = #{evaluateQueryConditionVO.perValue}
        </if>
        <if test="evaluateQueryConditionVO.per != null and evaluateQueryConditionVO.per == 4">
            AND t_evaluate.`overall_evaluation` = #{evaluateQueryConditionVO.perValue}
        </if>
    </select>
</mapper>


1.6 启动项目用swagger测试

访问:http://localhost:9110/swagger-ui.html#/


二、餐桌管理


餐桌其实也是一个很重要的环节,客户的点餐第一步就是选择餐桌所以店家应该有对餐桌的基本增删改查相关功能,如果后期有什么特殊的功能我们再来补充


2.1 创建餐桌展示信息DTO


image.png


/**
 * <p>
 * 
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
@Data
@ApiModel(value="餐桌信息DTO", description="")
public class DiningTableDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty(value = "ID")
    private Long id;
    @ApiModelProperty(value = "桌号:不为空,唯一")
    private String diningTableNumber;
    @ApiModelProperty(value = "餐桌名称:特色名称,有利于店面文怀")
    private String diningTableName;
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
}


2.2 编写controller


image.png


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
@Api(value = "餐桌管理", tags = "餐桌管理")
@CrossOrigin
@RestController
@RequestMapping("/dining-table")
public class DiningTableController {
    @Autowired
    private DiningTableService diningTableService;
    @ApiOperation(value = "添加餐桌", notes = "添加餐桌")
    @PostMapping("/add-or-update")
    public ResultDTO addOrUpdate(@RequestBody DiningTableVO diningTableVO) {
        return diningTableService.addOrUpdate(diningTableVO);
    }
    @ApiOperation(value = "分页查看所有餐桌信息", notes = "分页查看所有餐桌信息")
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功!", response = DiningTableDTO.class)})
    @GetMapping("/select-all")
    public ResultDTO selectAll(
            @ApiParam("当前页码") @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @ApiParam("每页显示条数") @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return diningTableService.selectAll(pageNum, pageSize);
    }
    @ApiOperation(value = "根据id查询餐桌信息", notes = "根据id查询餐桌信息")
    @ApiResponses({@ApiResponse(code = 200, message = "请求成功!", response = DiningTableDTO.class)})
    @GetMapping("/select-one")
    public ResultDTO selectOne(@ApiParam("餐桌id") @RequestParam(value = "id", required = false, defaultValue = "1") Long id){
        return diningTableService.selectOne(id);
    }
    @ApiOperation(value = "根据id删除餐桌信息", notes = "根据id删除餐桌信息")
    @GetMapping("/delete")
    public ResultDTO delete(@ApiParam("餐桌id") @RequestParam(value = "id", required = false, defaultValue = "1") Long id){
        diningTableService.removeById(id);
        return ResultDTO.success();
    }
}


2.3 编写service


image.png


/**
 * <p>
 * 服务类
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
public interface DiningTableService extends IService<DiningTable> {
    /**
     * 添加餐桌
     *
     * @param diningTableVO 餐桌信息
     * @return
     */
    ResultDTO addOrUpdate(DiningTableVO diningTableVO);
    /**
     * 分页查看所有餐桌信息
     *
     * @param pageNum  当前页
     * @param pageSize 每页大小
     * @return
     */
    ResultDTO selectAll(Integer pageNum, Integer pageSize);
    /**
     * 根据id查询餐桌信息
     *
     * @param id 餐桌id
     * @return
     */
    ResultDTO selectOne(Long id);
}


/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author j3_liuliang
 * @since 2020-10-24
 */
@Service
public class DiningTableServiceImpl extends ServiceImpl<DiningTableMapper, DiningTable> implements DiningTableService {
    @Autowired
    private DiningTableMapper diningTableMapper;
    @Override
    public ResultDTO addOrUpdate(DiningTableVO diningTableVO) {
        // 判断参数是否为空
        if (StringUtils.isEmpty(diningTableVO.getDiningTableNumber())
                || StringUtils.isEmpty(diningTableVO.getDiningTableName())) {
            throw new QuickException(ResultCodeEnum.PAEAMETER_IS_EMPTY);
        }
        // 判断是添加还是修改
        if (null == diningTableVO.getId()) {
            // 插入
            // 构造数据
            DiningTable diningTable = new DiningTable();
            BeanUtils.copyProperties(diningTableVO, diningTable);
            // 插入
            diningTableMapper.insert(diningTable);
        } else {
            // 修改
            // 根据id查询需要的数据
            QueryWrapper<DiningTable> diningTableQueryWrapper = new QueryWrapper<>();
            diningTableQueryWrapper
                    .select("dining_table_number", "dining_table_name")
                    .eq("id", diningTableVO.getId());
            DiningTable diningTable = diningTableMapper.selectOne(diningTableQueryWrapper);
            BeanUtils.copyProperties(diningTableVO, diningTable);
            diningTableMapper.updateById(diningTable);
        }
        return ResultDTO.success();
    }
    @Override
    public ResultDTO selectAll(Integer pageNum, Integer pageSize) {
        // 构造分页
        Page<DiningTable> diningTablePage = new Page<>(pageNum, pageSize);
        // 分页查询
        IPage<DiningTable> diningTablePageModel = diningTableMapper.selectPage(diningTablePage, null);
        // 构造返回数据
        List<DiningTable> diningTableList = diningTablePageModel.getRecords();
        long total = diningTablePageModel.getTotal();
        return ResultDTO.success().data("total", total).data("rows", diningTableList);
    }
    @Override
    public ResultDTO selectOne(Long id) {
        // 执行查询
        DiningTable diningTable = diningTableMapper.selectById(id);
        // 构造返回数据
        DiningTableDTO diningTableDTO = new DiningTableDTO();
        BeanUtils.copyProperties(diningTable, diningTableDTO);
        return ResultDTO.success().data("data", diningTableDTO);
    }
}


2.4 编写mapper及mapper映射文件

无需编写,使用了MyBatisPlus内置方法,就是这么爽


2.5 启动项目,swagger测试

http://localhost:9110/swagger-ui.html#/


image.png


结束语


  • 由于博主才疏学浅,难免会有纰漏,假如你发现了错误或偏见的地方,还望留言给我指出来,我会对其加以修正。
  • 如果你觉得文章还不错,你的转发、分享、点赞、留言就是对我最大的鼓励。
  • 感谢您的阅读,十分欢迎并感谢您的关注。


目录
相关文章
|
10月前
|
人工智能 安全 测试技术
🦞 OpenClaw部署保姆级指南:2026年如何在OpenClaw(Clawdbot/Moltbot)配置阿里云百炼 API
OpenClaw作为2026年开源社区的现象级产品,前身为Clawdbot、Moltbot,凭借强大的任务执行能力的成为无数用户搭建专属AI助手的首选工具。它区别于普通聊天型AI,能够真正深入系统完成读写文件、浏览器自动化、邮件管理等实操任务,而这些核心智能能力的实现,离不开与大模型的对接。阿里云百炼作为一站式大模型开发与应用构建平台,集成了通义千问全系列及第三方优质模型,提供统一且兼容的API接口,可与OpenClaw无缝衔接,为其提供稳定、高效的智能推理支撑。
1591 12
|
10月前
|
人工智能 运维 API
阿里云OpenClaw汉化版零门槛部署指南:全中文界面+代码命令详解
在AI自动化办公全面普及的2026年,OpenClaw(前身为Clawdbot、Moltbot)凭借自然语言指令操控、多任务自动化执行、多平台适配的核心优势,成为个人与中小企业搭建专属AI助手的首选开源轻量级工具。它不仅能完成文档生成、文件解析、服务器运维等基础工作,更可通过阿里云一键部署实现7×24小时稳定运行。尤其适配的汉化版,以全中文界面彻底解决了原版英文操作门槛高的痛点,搭配零配置适配设计,让零基础用户也能快速上手,真正实现“零技术门槛解锁中文AI办公”。
6104 7
|
11月前
|
人工智能 Java Go
2026年免费AI编程助手测评:通义灵码领衔,谁是国产开发者的最佳Copilot?
随着 Qwen 2.5-Coder 等开源模型的爆发,2026年 AI 编程工具已进入“百模大战”的深水区。本文基于代码生成准确率、中文语境理解能力及免费额度三大维度,对市场主流工具进行实测
|
人工智能 IDE 程序员
Qoder用户上手指南:安装、登录、快捷键、功能亮点(新用户免费领300credits,首购2美元/月)
这个容易让程序员上瘾的 Agentic Coding 平台有哪些上头的功能?对于小白开发者和资深开发者如何用好Qoder呢?
20857 6
Qoder用户上手指南:安装、登录、快捷键、功能亮点(新用户免费领300credits,首购2美元/月)
|
1天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8067 2
|
11天前
|
域名解析 人工智能 Linux
|
21天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
18474 64
|
19天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置