com.jfinal.aop.Before Java Examples

The following examples show how to use com.jfinal.aop.Before. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysRoleController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 角色配置权限 菜单更新
 */
@Before(Tx.class)
public void menuTreeUpdate() {
    String roleId = get("roleId");
    String menuIds = get("menuIds");
    if (StringUtils.isEmpty(roleId)) {
        renderFail("roleId 参数不可为空.");
        return;
    }
    // 删除 角色原有菜单
    String deleteSql = "delete from  sys_role_menu where sysRoleId = ?";
    Db.update(deleteSql, roleId);

    // 添加 角色新菜单
    if (StringUtils.notEmpty(menuIds)) {
        String[] menuIdAry = menuIds.split(",");
        for (String menuId : menuIdAry) {
            SysRoleMenu sysRoleMenu = new SysRoleMenu();
            sysRoleMenu.setSysRoleId(roleId).setSysMenuId(menuId)
                    .setCreater(WebUtils.getSessionUsername(this))
                    .setCreateTime(new Date())
                    .save();
        }
    }
    renderSuccess("菜单权限操作成功");
}
 
Example #2
Source File: UserController.java    From jboot-admin with Apache License 2.0 6 votes vote down vote up
/**
 * 修改密码提交
 */
@Before( {POST.class, ChangePwdValidator.class} )
public void postChangepwd() {
    User sysUser = getBean(User.class, "user");
    if (!sysUser.getId().equals(AuthUtils.getLoginUser().getId())) {
        throw new BusinessException("无权操作");
    }

    String pwd = getPara("newPwd");


    String salt2 = new SecureRandomNumberGenerator().nextBytes().toHex();
    SimpleHash hash = new SimpleHash("md5", pwd, salt2, 2);
    pwd = hash.toHex();
    sysUser.setPwd(pwd);
    sysUser.setSalt2(salt2);
    sysUser.setLastUpdAcct(AuthUtils.getLoginUser().getName());
    sysUser.setLastUpdTime(new Date());
    sysUser.setNote("用户修改密码");

    if (!userService.update(sysUser)) {
        throw new BusinessException("修改密码失败");
    }

    renderJson(RestResult.buildSuccess());
}
 
Example #3
Source File: SysOrgController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 删除 action
 */
@Before(IdRequired.class)
public void deleteAction() {
    String id = getPara("id");
    Db.tx(() -> {
        // 子孙id,包括自身
        String sonIds = TreeTableUtils.getSonTreeIds(id, "sys_org", "id", "pid");
        if (StringUtils.isEmpty(sonIds)) {
            return true;
        }
        sonIds = sonIds.replaceAll(",", "','");
        // 删除机构
        String sql = "delete from sys_org where id in ('" + sonIds + "')";
        Db.update(sql);
        // 相关 人员 机构字段 置空
        sql = "update sys_user set orgId = null where orgId  in ('" + sonIds + "')";
        Db.update(sql);
        return true;
    });
    renderSuccess(DELETE_SUCCESS);
}
 
Example #4
Source File: ResController.java    From jboot-admin with Apache License 2.0 6 votes vote down vote up
/**
 * 修改提交
 */
@Before({POST.class, ResValidator.class})
public void postUpdate() {
    Long pid = getParaToLong("pid");
    Res sysRes = getBean(Res.class, "res");

    if (StrKit.isBlank(sysRes.getIconCls())) {
        sysRes.setIconCls("");
    }

    sysRes.setPid(pid);
    sysRes.setLastUpdAcct(AuthUtils.getLoginUser().getName());
    sysRes.setLastUpdTime(new Date());
    sysRes.setNote("修改系统资源");

    if (!resService.update(sysRes)) {
        throw new BusinessException("修改失败,请重试");
    }

    renderJson(RestResult.buildSuccess());
}
 
Example #5
Source File: SysVisitLogController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 导出excel
 */
@RequirePermission("sysVisitLog:export")
@Before(SearchSql.class)
public void exportExcel() {
    String where = getAttr(Constant.SEARCH_SQL);
    if (SysVisitLog.dao.findCountByWhere(where) > 50000) {
        setAttr("msg", "一次导出数据不可大于 5W 条,请修改查询条件。");
        render("common/card.ftl");
        return;
    }

    // 测试大数据量导出
    List<SysVisitLog> list = SysVisitLog.dao.findByWhere(where);

    Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("访问日志", "访问日志"),
            SysVisitLog.class, list);
    render(ExcelRender.me(workbook).fileName("访问日志.xls"));
}
 
Example #6
Source File: ExStaffController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 删除 action
 */
@Before({IdsRequired.class, Tx.class})
public void deleteAction() {
    String ids = getPara("ids").replaceAll(",", "','");
    String deleteSql;

    // 删从表
    deleteSql = "delete from ex_staff_education where exStaffId in ('" + ids + "')";
    Db.update(deleteSql);
    deleteSql = "delete from ex_staff_experience where exStaffId in ('" + ids + "')";
    Db.update(deleteSql);
    deleteSql = "delete from ex_staff_family where exStaffId in ('" + ids + "')";
    Db.update(deleteSql);
    // 删主表
    deleteSql = "delete from ex_staff where id in ( '" + ids + "' ) ";
    Db.update(deleteSql);

    renderSuccess(DELETE_SUCCESS);
}
 
Example #7
Source File: SysVisitLogController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 批量删除
 */
@RequirePermission("sysVisitLog:delete")
@Before(IdsRequired.class)
public void deleteAction() {
    String ids = getPara("ids").replaceAll(",", "','");
    String sql = "delete from sys_visit_log where  id in ('" + ids + "')";
    int number = Db.update(sql);

    // 发送系统通知
    String noticeTypeCode = "delVisitLog";
    Map<String, Object> params = new HashMap<>();
    params.put("username", WebUtils.getSessionUsername(this));
    params.put("datetime", new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
    params.put("number", number);
    SysNoticeService service = Duang.duang(SysNoticeService.class);
    service.sendNotice(noticeTypeCode, params);

    renderSuccess(DELETE_SUCCESS);
}
 
Example #8
Source File: FormLeaveController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 逻辑 删除 action
 */
@TxConfig(ActivitiConfig.DATASOURCE_NAME)
@Before({IdRequired.class, Tx.class})
public void deleteAction() {
    String id = getPara("id");     // 业务表主键
    FormLeave formLeave = FormLeave.dao.findById(id);
    // 不可删除非自己创建的申请
    if (!WebUtils.getSessionUsername(this).equals(formLeave.getCreater())) {
        throw new RuntimeException("非法删除流程操作");
    }
    ProcessInstance instance = ActivitiKit.getRuntimeService().createProcessInstanceQuery()
            .processInstanceBusinessKey(id)
            .singleResult();
    if (instance != null) {
        // 未结束流程 添加删除标志字段
        ActivitiKit.getRuntimeService().deleteProcessInstance(instance.getId(), ActivitiConfig.DEL_INSTANCE_BY_USER);
        formLeave.setDelFlag("Y").update();
        renderSuccess(DELETE_FORM_SUCCESS);
    } else {
        renderFail(DELETE_FORM_FAIL);
    }
}
 
Example #9
Source File: SysUserController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 用户改角色保存
 */
@SuppressWarnings("Duplicates")
@Before(Tx.class)
public void addUserRoleAction() {
    String userId = getPara("userId");
    String roleIds = getPara("roleIds");
    if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(roleIds)) {
        renderFail("userId roleIds 参数不可为空.");
        return;
    }
    String[] roleIdAry = roleIds.split(",");
    for (String roleId : roleIdAry) {
        SysUserRole sysUserRoleOld = SysUserRole.dao.findByIds(userId, roleId);
        if (sysUserRoleOld == null) {
            SysUserRole sysUserRole = new SysUserRole();
            sysUserRole.setSysUserId(userId).setSysRoleId(roleId)
                    .setCreater(WebUtils.getSessionUsername(this))
                    .setCreateTime(new Date())
                    .save();
        }
    }
    renderSuccess("添加用户角色成功.");
}
 
Example #10
Source File: OAController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 历史流程 详情
 */
@Before(IdRequired.class)
public void historicProcessInstanceDetail() {
    String processInstanceId = getPara("id"); // 历史流程实例 id
    HistoricProcessInstance instance = ActivitiKit.getHistoryService().createHistoricProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .includeProcessVariables()
            .singleResult();
    String businessKey = instance.getBusinessKey();
    String businessForm = (String) instance.getProcessVariables().get("businessForm"); // 业务表单
    String initiator = (String) instance.getProcessVariables().get("initiator"); // 申请人
    setAttr("initiator", initiator);
    setAttr("processInstanceId", processInstanceId);
    setAttr("processInstanceName", instance.getName());
    setAttr("businessKey", businessKey);
    setAttr("businessForm", businessForm);
    render("oa/processInstance_detail.ftl");
}
 
Example #11
Source File: SysNoticeTypeController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 单条 删除  关联关系
 */
@Before(Tx.class)
public void deleteTypeRoleAction() {
    // ,; 格式
    String idPairs = getPara("idPairs");
    if (StringUtils.isEmpty(idPairs)) {
        renderFail("参数不可为空");
        return;
    }
    String[] idPairAry = idPairs.split(";");
    String[] idAry;
    for (String idPair : idPairAry) {
        idAry = idPair.split(",");
        SysNoticeTypeSysRole.dao.deleteByIds(idAry[0], idAry[1]);
    }
    renderSuccess(DELETE_SUCCESS);
}
 
Example #12
Source File: ProcessDeployController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 下载部署包
 */
@Before(IdRequired.class)
public void downloadZip() {
    String deploymentId = getPara("id");
    Deployment deployment = ActivitiKit.getRepositoryService().createDeploymentQuery()
            .deploymentId(deploymentId)
            .singleResult();
    if (deployment == null) {
        renderFail("部署包不存在");
        return;
    }

    List<String> resourceNames = ActivitiKit.getRepositoryService().getDeploymentResourceNames(deploymentId);
    List<InputStream> resourceDatas = new ArrayList<>();

    for (String resourceName : resourceNames) {
        resourceDatas.add(ActivitiKit.getRepositoryService().getResourceAsStream(deploymentId, resourceName));
    }
    render(ZipRender.me().filenames(resourceNames).dataIn(resourceDatas).fileName("部署包[" + deployment.getId() + "].zip"));
}
 
Example #13
Source File: MyTaskController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
@RequirePermission("myTask:changeAssignee")
@TxConfig(ActivitiConfig.DATASOURCE_NAME)
@Before(Tx.class)
public void changeAssigneeAction() {
    String taskId = getPara("taskId"); // taskId;
    String username = getPara("username");
    if (StringUtils.isEmpty(taskId) || StringUtils.isEmpty(username)) {
        renderFail("参数缺失");
        return;
    }
    TaskService taskService = ActivitiKit.getTaskService();
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    if (task == null) {
        renderFail("任务不存在");
        return;
    }
    if (username.equals(task.getAssignee())) {
        renderFail("原任务处理人 和 转办人 不可相同");
        return;
    }

    // 设置上个任务处理人
    ActivitiKit.getTaskService().setVariableLocal(taskId, "lastAssignee", task.getAssignee());
    ActivitiKit.getTaskService().setAssignee(taskId, username);
    renderSuccess("转办 操作成功 ");
}
 
Example #14
Source File: MyCandidateTaskController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 认领任务
 */
@Before(IdRequired.class)
public void claimAction() {
    String taskId = getPara("id");

    Task task = ActivitiKit.getTaskService().createTaskQuery().taskId(taskId).singleResult();
    if (task == null) {
        renderFail("任务不存在");
        return;
    }
    if (task.isSuspended()) {
        renderFail("任务已被暂停");
        return;
    }
    if (task.getAssignee() != null) {
        renderFail("任务已被认领");
        return;
    }

    ActivitiKit.getTaskService().claim(taskId, WebUtils.getSessionUsername(this));
    renderSuccess("认领成功");
}
 
Example #15
Source File: SysNoticeTypeController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
@Before(IdsRequired.class)
public void deleteAction() {
    String ids = getPara("ids").replaceAll(",", "','");
    Db.tx(() -> {
        String sql = "delete from sys_notice_type where id in ('" + ids + "')";
        Db.update(sql);
        sql = "delete from sys_notice_type_sys_role where sysNoticeTypeId in ('" + ids + "')";
        Db.update(sql);
        // 删除通知消息表
        sql = "delete from sys_notice_detail where sysNoticeId in (select id from sys_notice where typeCode in (select typeCode from sys_notice_type where id in ('" + ids + "')))";
        Db.update(sql);
        sql = "delete from sys_notice where typeCode in (select typeCode from sys_notice_type where id in ('" + ids + "'))";
        Db.update(sql);
        return true;
    });
    renderSuccess(DELETE_SUCCESS);
}
 
Example #16
Source File: MainController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 用户通知数据
 */
@Before(SearchSql.class)
public void noticeData() {
    String userId = WebUtils.getSysUser(this).getId();
    int pageNumber = getAttr("pageNumber");
    int pageSize = getAttr("pageSize");
    String where = getAttr(Constant.SEARCH_SQL);

    if (StringUtils.notEmpty(where)) {
        where += " and receiver = '" + userId + "'";
    } else {
        where = " receiver = '" + userId + "'";
    }
    Page<SysNotice> sysNoticePage = SysNotice.dao.page(pageNumber, pageSize, where);
    renderDatagrid(sysNoticePage);
}
 
Example #17
Source File: SysUserUnlockController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 解锁
 */
@Before(Tx.class)
public void unlockAction() {
    String usernames = getPara("usernames");
    if (StringUtils.isEmpty(usernames)) {
        renderFail("参数不可为空");
        return;
    }

    String[] usernameAry = usernames.split(",");
    BaseCache<String, AtomicInteger> baseCache = CacheContainer.getLoginRetryLimitCache();
    for (String username : usernameAry) {
        baseCache.put(username, new AtomicInteger());
    }

    renderSuccess("解锁成功");
}
 
Example #18
Source File: SysNoticeTypeController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 增加 关联关系
 */
@Before(Tx.class)
public void addTypeRoleAction() {
    String roleIds = getPara("roleIds");
    String sysNoticeTypeId = getPara("sysNoticeTypeId");
    SysNoticeTypeSysRole sysNTRoleOld;
    for (String roleId : roleIds.split(",")) {
        sysNTRoleOld = SysNoticeTypeSysRole.dao.findByIds(sysNoticeTypeId, roleId);
        if (sysNTRoleOld != null) {
            continue;
        }
        SysNoticeTypeSysRole sysNTRole = new SysNoticeTypeSysRole();
        sysNTRole.setSysNoticeTypeId(sysNoticeTypeId)
                .setSysRoleId(roleId)
                .setCreater(WebUtils.getSessionUsername(this))
                .setCreateTime(new Date())
                .save();
    }
    renderSuccess("关联角色成功");
}
 
Example #19
Source File: OAController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 运行时流程 详情
 */
@Before(IdRequired.class)
public void processInstanceDetail() {
    String processInstanceId = getPara("id"); // 运行时流程实例id
    ProcessInstance instance = ActivitiKit.getRuntimeService().createProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .includeProcessVariables()
            .singleResult();
    String businessKey = instance.getBusinessKey();
    String businessForm = (String) instance.getProcessVariables().get("businessForm");
    String initiator = (String) instance.getProcessVariables().get("initiator");

    setAttr("initiator", initiator); // 申请人
    setAttr("processInstanceId", processInstanceId);// 流程实例id
    setAttr("processInstanceName", instance.getName());//流程实例 名称
    setAttr("businessKey", businessKey);  // 业务表主键
    setAttr("businessForm", businessForm); // 业务表名称
    render("oa/processInstance_detail.ftl");
}
 
Example #20
Source File: SysMenuController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 删除 action
 */
@Before(IdRequired.class)
public void deleteAction() {
    String id = get("id");
    Db.tx(() -> {
        String allIds = TreeTableUtils.getSonTreeIds(id, "sys_menu", "id", "pid");
        if (StringUtils.isEmpty(allIds)) {
            return true;
        }
        allIds = allIds.replaceAll(",", "','");
        String sql = "delete from sys_menu where id in ('" + allIds + "')";
        Db.update(sql);
        sql = "delete from sys_role_menu where sysMenuId in ('" + allIds + "')";
        Db.update(sql);

        // 删相关按钮
        sql = "delete from sys_role_button where sysButtonId in (select id from sys_button where sysMenuId in ('" + allIds + "'))";
        Db.update(sql);
        sql = "delete from sys_button where sysMenuId in ('" + allIds + "')";
        Db.update(sql);

        return true;
    });
    renderSuccess(DELETE_SUCCESS);
}
 
Example #21
Source File: SysRoleController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 删除 action
 */
@Before(IdsRequired.class)
public void deleteAction() {
    String ids = getPara("ids").replaceAll(",", "','");
    Db.tx(() -> {
        // 删除角色数据
        String sql = "delete from sys_role where id in ('" + ids + "')";
        Db.update(sql);
        // 删除 角色用户 中间表
        sql = "delete from sys_user_role where sysRoleId in ('" + ids + "')";
        Db.update(sql);
        // 删除角色菜单中间表
        sql = "delete from sys_role_menu where sysRoleId in ('" + ids + "')";
        Db.update(sql);
        // 通知类型 角色 中间表
        sql = "delete from sys_notice_type_sys_role where sysRoleId in ('" + ids + "')";
        Db.update(sql);
        return true;
    });
    renderSuccess(DELETE_SUCCESS);
}
 
Example #22
Source File: ProductController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 购买商品
 */
@Before(ProductValidate.class)
public void doBuy() {
    Product product = ProductValidate.getThreadLocalProduct();
    User user = getLoginedUser();
    Long distUserId = CookieUtil.getLong(this, buildDistUserCookieName(product.getId()));
    UserCart userCart = product.toUserCartItem(user.getId(), distUserId, getPara("spec"));

    Object cartId = cartService.save(userCart);

    if (isAjaxRequest()) {
        renderJson(Ret.ok().set("gotoUrl", JFinal.me().getContextPath() + "/ucenter/checkout/" + cartId));
    } else {
        redirect("/ucenter/checkout/" + cartId);
    }
}
 
Example #23
Source File: SysMenuController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 删除按钮
 */
@Before({Tx.class, IdsRequired.class})
public void deleteButtonAction() {
    String sysMenuId = get("menuId");
    if (StringUtils.isEmpty(sysMenuId)) {
        renderFail("参数menuId 缺失");
        return;
    }
    String ids = get("ids");
    ids = ids.replaceAll(",", "','");
    String sql = "delete from sys_role_button where sysButtonId in ('" + ids + "')";
    Db.update(sql);
    sql = "delete from sys_button where id in ('" + ids + "')";
    Db.update(sql);

    renderSuccess(DELETE_SUCCESS);
}
 
Example #24
Source File: SysMenuController.java    From my_curd with Apache License 2.0 6 votes vote down vote up
/**
 * 新增按钮
 */
@Before(Tx.class)
public void addButtonAction() {
    SysButton sysButton = getBean(SysButton.class, "")
            .setId(IdUtils.id())
            .setCreater(WebUtils.getSessionUsername(this))
            .setCreateTime(new Date());

    if (SysButton.dao.findUniqueByProperty("buttonCode", sysButton.getButtonCode()) != null) {
        renderFail(ADD_FAIL + " 编码已经存在");
        return;
    }

    SysMenu sysMenu = SysMenu.dao.findById(sysButton.getSysMenuId());
    if (sysMenu == null) {
        renderFail(ADD_FAIL);
        return;
    }

    sysButton.save();
    renderSuccess(ADD_SUCCESS);
}
 
Example #25
Source File: SysSettingController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 列表数据
 */
@Before(SearchSql.class)
public void query() {
    int pageNumber = getAttr("pageNumber");
    int pageSize = getAttr("pageSize");
    String where = getAttr(Constant.SEARCH_SQL);
    Page<SysSetting> sysSettingPage = SysSetting.dao.page(pageNumber, pageSize, where);
    renderDatagrid(sysSettingPage);
}
 
Example #26
Source File: SysSettingController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 导出excel
 */
@Before(SearchSql.class)
public void exportExcel() {
    String where = getAttr(Constant.SEARCH_SQL);
    if (SysSetting.dao.findCountByWhere(where) > 50000) {
        setAttr("msg", "一次导出数据不可大于 5W 条,请修改查询条件。");
        render("common/card.ftl");
        return;
    }

    List<SysSetting> list = SysSetting.dao.findByWhere(where);
    Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("系统设置项", "系统设置项"),
            SysSetting.class, list);
    render(ExcelRender.me(workbook).fileName("系统设置项.xls"));
}
 
Example #27
Source File: SysSettingController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 导入excel
 */
@SuppressWarnings("Duplicates")
@Before(Tx.class)
public void importExcel() {
    UploadFile uploadFile = getFile();
    if (uploadFile == null) {
        renderFail("上传文件不可为空");
        return;
    }
    if (!FilenameUtils.getExtension(uploadFile.getFileName()).equals("xls")) {
        FileUtils.deleteFile(uploadFile.getFile());
        renderFail("上传文件后缀必须是xls");
        return;
    }

    List<SysSetting> list;
    try {
        ImportParams params = new ImportParams();
        params.setTitleRows(1);
        params.setHeadRows(1);
        list = ExcelImportUtil.importExcel(uploadFile.getFile(), SysSetting.class, params);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        FileUtils.deleteFile(uploadFile.getFile());
        renderFail("模板文件格式错误");
        return;
    }

    for (SysSetting sysSetting : list) {
        sysSetting.setId(IdUtils.id())
                .setUpdater(WebUtils.getSessionUsername(this))
                .setUpdateTime(new Date())
                .save();
    }

    FileUtils.deleteFile(uploadFile.getFile());
    refreshSetting();
    renderSuccess(IMPORT_SUCCESS);
}
 
Example #28
Source File: SysTaskController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
@Before(SearchSql.class)
public void taskLogQuery() {
    int pageNumber = getAttr("pageNumber");
    int pageSize = getAttr("pageSize");
    String where = getAttr(Constant.SEARCH_SQL);
    Page<SysTaskLog> sysTaskLogPage = SysTaskLog.dao.page(pageNumber, pageSize, where);
    renderDatagrid(sysTaskLogPage);
}
 
Example #29
Source File: ProductController.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 添加到购物车
 */
@Before(ProductValidate.class)
public void doAddCart() {

    Product product = ProductValidate.getThreadLocalProduct();
    User user = getLoginedUser();
    Long distUserId = CookieUtil.getLong(this, buildDistUserCookieName(product.getId()));
    UserCart userCart = product.toUserCartItem(user.getId(), distUserId, getPara("spec"));

    Object cartId = cartService.save(userCart);
    renderJson(Ret.ok().set("cartId",cartId));
}
 
Example #30
Source File: SysDictController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * 删除 sysDict
 */
@Before(IdsRequired.class)
public void deleteDictAction() {
    String ids = getPara("ids").replaceAll(",", "','");
    String sql = "update sys_dict set delFlag = 'X' where id in ('" + ids + "')";
    Db.update(sql);
    renderSuccess(DELETE_SUCCESS);
}