首页>代码>基于SpringBoot+Vue实现的社团管理系统>/club-management/server/src/main/java/com/bishe/club/controller/ActiveLogsController.java
package com.bishe.club.controller;

import com.bishe.club.entity.ActiveLogs;
import com.bishe.club.handle.CacheHandle;
import com.bishe.club.msg.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bishe.club.entity.Users;
import com.bishe.club.service.UsersService;
import com.bishe.club.utils.DateUtils;
import com.bishe.club.utils.IDUtils;

import com.bishe.club.service.ActiveLogsService;

import java.util.List;
import java.util.Map;

/**
 * 系统请求响应控制器
 * 报名记录
 */
@Controller
@RequestMapping("/activeLogs")
public class ActiveLogsController extends BaseController {

    protected static final Logger Log = LoggerFactory.getLogger(ActiveLogsController.class);

    @Autowired
    private CacheHandle cacheHandle;

    @Autowired
    private UsersService usersService;

    @Autowired
    private ActiveLogsService activeLogsService;

    @RequestMapping("")
    public String index() {

        return "pages/ActiveLogs";
    }

    @GetMapping("/info")
    @ResponseBody
    public R getInfo(String id) {

        Log.info("查找指定报名记录,ID:{}", id);
        ActiveLogs activeLogs = activeLogsService.getOne(id);
        return R.successData(activeLogs);
    }

    @GetMapping("/list")
    @ResponseBody
    public R getList(String activeId) {

        Log.info("获取指定活动的报名记录,活动ID:{}", activeId);
        List<Map<String, Object>> list = activeLogsService.getListByActiveId(activeId);
        return R.successData(list);
    }

    @PostMapping("/add")
    @ResponseBody
    public R addInfo(String token, ActiveLogs activeLogs) {

        Users user = usersService.getOne(cacheHandle.getUserInfoCache(token));
        if(activeLogsService.isActive(activeLogs.getActiveId(), user.getId())){
            activeLogs.setId(IDUtils.makeIDByCurrent());
            activeLogs.setUserId(user.getId());
            activeLogs.setCreateTime(DateUtils.getNowDate());

            Log.info("添加报名记录,传入参数:{}", activeLogs);
            activeLogsService.add(activeLogs);

            return R.success();
        }else{
            return R.warn("该活动您已参与,请勿重复报名");
        }
    }

    @PostMapping("/upd")
    @ResponseBody
    public R updInfo(ActiveLogs activeLogs) {

        Log.info("修改报名记录,传入参数:{}", activeLogs);
        activeLogsService.update(activeLogs);
        return R.success();
    }

    @PostMapping("/del")
    @ResponseBody
    public R delInfo(String id) {

        Log.info("删除报名记录, ID:{}", id);
        ActiveLogs activeLogs = activeLogsService.getOne(id);
        activeLogsService.delete(activeLogs);
        return R.success();
    }
}
最近下载更多
jc121140  LV3 4月15日
玖零定制问题修复  LV34 4月4日
dapeng0011  LV13 4月4日
yuan666  LV1 3月27日
xiaozhi丶  LV14 3月24日
crazyAndy  LV7 3月20日
wanglinddad  LV55 3月9日
zhujunnan  LV12 3月8日
wbw123  LV5 3月4日
可是不知道么  LV23 3月1日
最近浏览更多
kenhomeliu  LV29 4月30日
1941549176 4月29日
暂无贡献等级
denliv_hui  LV13 4月26日
ilovecode521  LV3 4月20日
khhuyvhgcd  LV1 4月15日
玖零定制问题修复  LV34 4月4日
dapeng0011  LV13 4月4日
邓艺妮 4月3日
暂无贡献等级
儒雅男士  LV8 3月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友