Ruoyi 自定义字典字段 推荐不推荐

Ruoyi 自定义字典字段 推荐不推荐

字典
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
Html
按钮

  <a class="btn btn-danger multiple disabled" onclick="$.operate.studentSuccess()" shiro:hasPermission="system:student:studentSuccess">
                <i class="fa fa-remove"></i> 推荐
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.nostudentSuccess()" shiro:hasPermission="system:student:nostudentSuccess">
                <i class="fa fa-remove"></i> 不推荐
            </a>

//主页显示推荐否 获取对应字典数据

  var recom = [[${@dict.getType('sys_student_studentSuccess')}]];

//控制器方法

  nostudentSuccess:prefix + "/nostudentSuccess",
  importTemplateUrl: prefix + "/importTemplate",

//主页显示

       {
                    field : 'success',
                    title : '推荐否',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(recom, value);
                    }
                },

按钮点击的onclick方法

 // 批量推荐信息
            studentSuccess: function() {
                table.set();
                var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
                if (rows.length == 0) {
                    $.modal.alertWarning("请至少选择一条记录");
                    return;
                }
                $.modal.confirm("确认要推荐选中的" + rows.length + "条数据吗?", function() {
                    var url = table.options.studentSuccess;
                    var data = { "ids": rows.join() };
                    $.operate.submit(url, "post", "json", data);
                });
            },
            // 批量不推荐信息
            nostudentSuccess: function() {
                table.set();
                var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
                if (rows.length == 0) {
                    $.modal.alertWarning("请至少选择一条记录");
                    return;
                }
                $.modal.confirm("确认要不推荐选中的" + rows.length + "条数据吗?", function() {
                    var url = table.options.nostudentSuccess;
                    var data = { "ids": rows.join() };
                    $.operate.submit(url, "post", "json", data);
                });
            },

Controller

 /**
     * 修改推荐
     */
    @RequiresPermissions("system:student:studentSuccess")
    @Log(title = "通知公告", businessType = BusinessType.updataSuccess)
    @PostMapping("/studentSuccess")
    @ResponseBody
    public AjaxResult studentSuccess(String ids)
    {
        return toAjax(studentService.studentSuccess(ids));
    }
    /**
     * 修改不推荐
     */
    @RequiresPermissions("system:student:nostudentSuccess")
    @Log(title = "通知公告", businessType = BusinessType.updataSuccess)
    @PostMapping("/nostudentSuccess")
    @ResponseBody
    public AjaxResult nostudentSuccess(String ids)
    {
        return toAjax(studentService.nostudentSuccess(ids));
    }

ServiceImpl

 /**
     * 推荐公告对象
     *
     * @param ids 需要推荐的数据ID
     * @return 结果
     */
    @Override
    public int studentSuccess(String ids)
    {
        return studentMapper.studentSuccess(Convert.toStrArray(ids));
    }
    /**
     * 不推荐公告对象
     *
     * @param ids 需要不推荐的数据ID
     * @return 结果
     */
    @Override
    public int nostudentSuccess(String ids)
    {
        return studentMapper.nostudentSuccess(Convert.toStrArray(ids));
    }

Mapper


    /**
     * 批量修改推荐
     *
     * @param studentIds 需要推荐的数据ID
     * @return 结果
     */
    public int studentSuccess(String[] studentIds);

    /**
     * 批量修改不推荐
     *
     * @param studentIds 需要不推荐的数据ID
     * @return 结果
     */
    public int nostudentSuccess(String[] studentIds);

Mapper.xml

<update id="studentSuccess" parameterType="Student">
        update  student set success=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="nostudentSuccess" parameterType="Student">
        update  student set success=0 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值