ShyActivityController.java 3.84 KB
package com.cnlive.shenhe.controller;
//
//                            _ooOoo_  
//                           o8888888o  
//                           88" . "88  
//                           (| -_- |)  
//                            O\ = /O  
//                        ____/`---'\____  
//                      .   ' \\| |// `.  
//                       / \\||| : |||// \  
//                     / _||||| -:- |||||- \  
//                       | | \\\ - /// | |  
//                     | \_| ''\---/'' | |  
//                      \ .-\__ `-` ___/-. /  
//                   ___`. .' /--.--\ `. . __  
//                ."" '< `.___\_<|>_/___.' >'"".  
//               | | : `- \`.;`\ _ /`;.`/ - ` : | |  
//                 \ \ `-. \_ __\ /__ _/ .-` / /  
//         ======`-.____`-.___\_____/___.-`____.-'======  
//                            `=---='  
//  
//         .............................................  
//                  佛祖镇楼                  BUG辟易  
//          佛曰:  
//                  写字楼里写字间,写字间里程序员;  
//                  程序人员写程序,又拿程序换酒钱。  
//                  酒醒只在网上坐,酒醉还来网下眠;  
//                  酒醉酒醒日复日,网上网下年复年。  
//                  但愿老死电脑间,不愿鞠躬老板前;  
//                  奔驰宝马贵者趣,公交自行程序员。  
//                  别人笑我忒疯癫,我笑自己命太贱;  
//  

import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.entity.ShyActivity;
import com.cnlive.shenhe.serviceImpl.ShyActivityImpl;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator
 * @author yanzhaowang
 * @create 2022-03-08 12:37
 */
@Controller
@RequestMapping("/page")
public class ShyActivityController {
    @Autowired
    private ShyActivityImpl shyActivityImpl;

    @PostMapping("/add")
    @ResponseBody
    public ResponseBean insterShyActivity(ShyActivity shyActivity, Model model){
        int i = shyActivityImpl.insertShyActivity(shyActivity);
        if (i>0) {
            return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "当前用户添加成功");
        }
        return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "添加失败,请重试");
    }

    @DeleteMapping("/delete/{id}")
    @ResponseBody
    public ResponseBean deleteShyActivity(@PathVariable(value = "id") Integer id,Model model){
        int i = shyActivityImpl.deleteShyActivity(id);
        if (i>0) {
            return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "删除当前用户添加成功");
        }
        return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "删除失败,请重试");

    }
    @PutMapping("/update")
    @ResponseBody
    public ResponseBean updateShyActivity(ShyActivity shyActivity,Model model){
        int i = shyActivityImpl.updateShyActivity(shyActivity);
        if (i>0) {
            return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "修改当前用户添加成功");
        }
        return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "修改失败,请重试");

    }

    @GetMapping("/get/{page}/{Pagesize}")
    public String getShyActivity(Integer id,@PathVariable(name = "page",value = "1") Integer page,@PathVariable(name = "Pagesize",value = "10") Integer Pagesize,Model model){
        PageInfo<ShyActivity> shyActivityPageInfo = shyActivityImpl.selectByExample(page, Pagesize, id);
        List<ShyActivity> list = shyActivityPageInfo.getList();
        model.addAttribute("list", list);
        return "page/activity.html";
    }

}