温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

activitycontroller

发布时间:2020-07-08 00:06:09 来源:网络 阅读:639 作者:pwgan 栏目:开发技术

package com.renesola.apollo.controller;

import java.util.List;

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

import com.renesola.apollo.auth.Session;
import com.renesola.apollo.model.ActivityCategory;
import com.renesola.apollo.model.base.DataModel;
import com.renesola.apollo.service.ActivityCategoryService;
import com.renesola.apollo.sql.Where;
import com.renesola.apollo.util.Requests;

@Controller@RequestMapping("activity")
br/>@RequestMapping("activity")
br/>@Autowired

/**
 * 跳转到活动分类页面
 * @return
 */
@RequestMapping("activityList")
public String activityList(){
    List<ActivityCategory> actLists=activityCateoryService.list(new Where().eq("dr",0).setOrderBy("createAt"));
    Requests.attr("actLists",actLists);
    return "activity/activityList";
}

/**
 * 删除分类
 * @return
 */
@RequestMapping("removeCateory")
@ResponseBody
public Object removeCateory() {
    try {
        // 权限ID
        String actId = Requests.param("actId");

        ActivityCategory act = activityCateoryService.require(actId);
        activityCateoryService.require(actId);
        act.setDr(1);
        act.setDeleteAtNow(Session.getUserId());
        activityCateoryService.save(act);
        return DataModel.instance().setSuccess(true);
    } catch(Exception e) {
        e.printStackTrace();
        return DataModel.instance().setSuccess(false);
    }
}

/**
 * 新增分类
 * @return
 */
@RequestMapping("addCateory")
@ResponseBody
public Object addCateory() {
    try {
        // 权限内容
        String cate_name_add = Requests.param("cate_name_add");
        // 权限描述
        String cate_desc_add = Requests.param("cate_desc_add");

        // 权限名称重复check
        List<ActivityCategory> bakActList = activityCateoryService.list(new Where().eq("dr", 0).eq("cate_name", cate_name_add.trim()));
        if (bakActList != null && bakActList.size() > 0) {
            return DataModel.instance().setSuccess(false).setMsg("该活动分类名称已被使用.");
        }
        ActivityCategory act = new ActivityCategory();

        act.setCateName(cate_name_add.trim());
        act.setCateDesc(cate_desc_add.trim());
        act.setCreateAtNow(Session.getUserId());

        activityCateoryService.save(act);
        return DataModel.instance().setSuccess(true);
    } catch(Exception e) {
        e.printStackTrace();
        return DataModel.instance().setSuccess(false);
    }
}

/**
 * 更新分类
 * @return
 */
@RequestMapping("updateCateory")
@ResponseBody
public Object updatePermission() {
    try {
        // 权限ID
        String actId = Requests.param("actId");
        // 权限内容
        String cate_name_edit = Requests.param("cate_name_edit");
        // 权限描述
        String cate_desc_edit = Requests.param("cate_desc_edit");
        // 权限名称重复check
        List<ActivityCategory> bakActList = activityCateoryService.list(new Where().eq("dr", 0).eq("cate_name", cate_name_edit.trim()));
        if (bakActList == null) {
            // do nothing.
        } else if (bakActList.size() > 2) {
            return DataModel.instance().setSuccess(false).setMsg("该活动分类名称已被使用.");
        } else if (bakActList.size() == 1 && !actId.equals(bakActList.get(0).getId())) {
            return DataModel.instance().setSuccess(false).setMsg("该活动分类名称已被使用.");
        } else {
            // do nothing.
        }

        ActivityCategory act = activityCateoryService.require(actId);
        act.setCateName(cate_name_edit.trim());
        act.setCateDesc(cate_desc_edit.trim());
        act.setUpdateAtNow(Session.getUserId());
        activityCateoryService.save(act);
        return DataModel.instance().setSuccess(true);
    } catch(Exception e) {
        e.printStackTrace();
        return DataModel.instance().setSuccess(false);
    }
}

}

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI