org.nutz.mvc.annotation.Ok Java Examples

The following examples show how to use org.nutz.mvc.annotation.Ok. 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: CaptchaController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 获取验证码
 *
 * @param session session
 * @param w       宽
 * @param h       高
 * @return
 */
@At
@Ok("raw:png")
@ApiOperation(value = "获取验证码", notes = "公共验证码", httpMethod = "GET")
public BufferedImage next(HttpSession session,
                          @Param("w") int w,
                          @Param("h") int h) {
    /**
     * 长或宽为0?重置为默认长宽.
     */
    if (w * h < 1) {
        w = 145;
        h = 35;
    }
    String text = R.captchaChar(4);
    session.setAttribute(Toolkit.captcha_attr, text);
    return Images.createCaptcha(text, w, h, null, "FFF", null);
}
 
Example #2
Source File: FrontController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 内容展示
 * @param id
 * @param req
 */
@At
@Ok("th:/cms/front/content.html")
public void articleById(@Param("id") String id, HttpServletRequest req) {
    Article article = articleService.fetch(id);
    article.setHits(article.getHits() + 1);
    if (article != null) {
        articleService.fetchLinks(article, "category|createUser");
        List<Category> list = categoryService.query(Cnd.where("id", "=", article.getCategoryId()).asc("sort"));
        req.setAttribute("id", article.getCategoryId());
        req.setAttribute("article", article);
        req.setAttribute("list", list);
    }
    req.setAttribute("nav_categories",categoryService.getCateById("1"));
    articleService.updateIgnoreNull(article);
}
 
Example #3
Source File: UserController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
     * 修改用户
     */
    @At("/edit/?")
    @Ok("th://sys/user/edit.html")
    public void edit(String id, HttpServletRequest req) {
        User user = userService.fetch(id);
        userService.fetchLinks(user, "dept|roles");
        List<Role> roles = roleService.query(Cnd.where("status", "=", false).and("del_flag", "=", false));
        roles.forEach(role -> {
            if (user.getRoles() != null && user.getRoles().size() > 0) {
//				System.out.println(user.getRoles().contains(role));
                role.setFlag(user.getRoles().contains(role));
            }
        });
        req.setAttribute("user", user);
        req.setAttribute("roles", roles);
    }
 
Example #4
Source File: UserController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
     * 修改保存用户
     */
    @RequiresPermissions("sys:user:edit")
    @At
    @POST
    @Ok("json")
    @Slog(tag = "用户管理", after = "修改保存用户管理")
    public Object editDo(@Param("..") User user, Errors es, HttpServletRequest req) {
        try {
//            if (es.hasError()) {
//                 return Result.error(es);
//            }
            if (Lang.isNotEmpty(user)) {
                user.setUpdateBy(ShiroUtils.getSysUserId());
                user.setUpdateTime(new Date());
                userService.update(user);
            }
            return Result.success("system.success");
        } catch (Exception e) {
            return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
        }
    }
 
Example #5
Source File: DeptController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@At
@POST
@Ok("json")
@RequiresPermissions("sys:dept:edit")
@Slog(tag = "部门管理", after = "修改部门")
public Object editDo(@Param("..") Dept data, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
           return Result.error(es);
        }
        deptService.update(data);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #6
Source File: CategoryController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询栏目列表
 */
@At
@Ok("json")
@RequiresPermissions("cms:category:list")
public Object list(@Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	cnd.asc("sort");
	return categoryService.query(cnd);
}
 
Example #7
Source File: CategoryController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增栏目
 */
@At({"/add/?","/add"})
@Ok("th:/cms/category/add.html")
public void add(@Param("id") String id, HttpServletRequest req) {
	Category category = null;
	if(Strings.isNotBlank(id)) {
		category = categoryService.fetch(id);
	}
	if(Lang.isNotEmpty(category)) {
		category.setParentName(category.getName());
	}else{
		category=new Category();
		category.setParentId("0");
		category.setName("无");
	}
	req.setAttribute("category",category);
}
 
Example #8
Source File: PetController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询宠物列表
 */
@RequiresPermissions("test:pet:list")
@At
@Ok("json")
public Object list(@Param("pageNum")int pageNum,
				   @Param("pageSize")int pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return petService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,"master");
}
 
Example #9
Source File: FrontController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 栏目导航
 * @param id
 * @param req
 */
@At("/category/?")
@Ok("th:/cms/front/category.html")
public void category(String id, HttpServletRequest req) {
    List<String> ids = new ArrayList<>();

    List<Category> list = categoryService.query(Cnd.where("parent_id", "=", id).asc("sort"));
    ids.add(id);
    list.stream().forEach(cate->{
        ids.add(cate.getId());
    });
    List<Article> articleList = articleService.query(Cnd.where("category_id", "in", ids));
    req.setAttribute("id", id);
    req.setAttribute("list", list);
    req.setAttribute("nav_categories",categoryService.getCateById("1"));
    req.setAttribute("articleList", articleList);
}
 
Example #10
Source File: ApiMasterController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
     * 修改保存主人
     */
    @At
    @POST
    @Ok("json")
    @AccessToken
    public Object editDo(@Param("..") Master master, Errors es, HttpServletRequest req) {
        try {
            if (es.hasError()) {
                return Result.error(es);
            }
            if (Lang.isNotEmpty(master)) {
//				master.setUpdateBy(JWTUtil.getId());
//				master.setUpdateTime(new Date());
                masterService.update(master);
            }
            return Result.success("system.success");
        } catch (Exception e) {
            return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
        }
    }
 
Example #11
Source File: WxUserController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@At("/down")
@Ok("json")
@RequiresPermissions("wx:wxUser:sync")
@Slog(tag="微信会员", after="同步会员信息")
public Object down(HttpServletRequest req) {
	try {
		Config config =configService.fetch("token");
		if(Lang.isNotEmpty(config)){
			List<User_info_list>  userInfoLists = UserUtils.getUser(config.getConfigValue());
			if(Lang.isNotEmpty(userInfoLists)){
				userInfoLists.forEach( user->{
					int count =wxUserService.count(Cnd.NEW().and("openid","=",user.getOpenid()));
					if(count==0){
						wxUserService.insert(User_info_list.getUser(user));
					}
				});
			}
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error("system.error");
	}
}
 
Example #12
Source File: WxMenuController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 选择菜单树
 */
@At("/selectTree/?")
@Ok("th:/wx/menu/tree.html")
public void selectTree(String id, HttpServletRequest req) {
       WxMenu wxMenu = null;
       if(Strings.isNotBlank(id)) {
           wxMenu = wxMenuService.fetch(id);
       }
       if (wxMenu ==null)  {
           wxMenu =new WxMenu();
           wxMenu.setId("");
           wxMenu.setParentId("0");
           wxMenu.setName("无");
       }
       req.setAttribute("menu", wxMenu);
}
 
Example #13
Source File: WxMenuController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询微信菜单列表
 */
@At
@Ok("json")
@RequiresPermissions("wx:menu:list")
public Object list(@Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return wxMenuService.query(cnd);
}
 
Example #14
Source File: PetController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
	 * 修改保存宠物
	 */
	@At
	@POST
	@Ok("json")
	@RequiresPermissions("test:pet:edit")
	@Slog(tag="宠物", after="修改保存宠物")
	public Object editDo(@Param("..") Pet pet,HttpServletRequest req) {
		try {
			if(Lang.isNotEmpty(pet)){
//				pet.setUpdateBy(ShiroUtils.getSysUserId());
//				pet.setUpdateTime(new Date());
				petService.update(pet);
			}
			return Result.success("system.success");
		} catch (Exception e) {
			return Result.error("system.error");
		}
	}
 
Example #15
Source File: ApiPetController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
     * 修改保存宠物
     */
    @At
    @POST
    @Ok("json")
    @AccessToken
    public Object editDo(@Param("..") Pet pet, Errors es, HttpServletRequest req) {
        try {
            if (es.hasError()) {
                return Result.error(es);
            }
            if (Lang.isNotEmpty(pet)) {
//				pet.setUpdateBy(JWTUtil.getId());
//				pet.setUpdateTime(new Date());
                petService.update(pet);
            }
            return Result.success("system.success");
        } catch (Exception e) {
            return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
        }
    }
 
Example #16
Source File: WxMenuController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存微信菜单
 */

@At
@POST
@Ok("json")
@RequiresPermissions("wx:menu:edit")
@Slog(tag="微信菜单", after="修改保存微信菜单")
public Object editDo(@Param("..") WxMenu wxMenu, HttpServletRequest req) {
	try {
		if(Lang.isNotEmpty(wxMenu)){
			wxMenu.setUpdateBy(ShiroUtils.getSysUserId());
			wxMenu.setUpdateTime(new Date());
			wxMenuService.update(wxMenu);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error("system.error");
	}
}
 
Example #17
Source File: CategoryController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 选择菜单树
 */
@At("/selectTree/?")
@Ok("th:/cms/category/tree.html")
public void selectTree(String id, HttpServletRequest req) {
	Category category = null;
	if(Strings.isNotBlank(id)) {
		category = categoryService.fetch(id);
	}
	if (category ==null)  {
		category=new Category();
		category.setId("");
		category.setParentId("0");
		category.setName("无");
	}
	req.setAttribute("category",category);
}
 
Example #18
Source File: DictController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存字典
 */
@RequiresPermissions("sys:dict:add")
@At
@POST
@Ok("json")
@Slog(tag="字典", after="新增保存字典id=${args[0].id}")
public Object addDo(@Param("..") Dict dict, Errors es,HttpServletRequest req) {
	try {
	    if(es.hasError()){
			 return Result.error(es);
           }
		dictService.insert(dict);
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
	}
}
 
Example #19
Source File: ApiPetController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存宠物
 */
@At
@POST
@Ok("json")
@AccessToken
public Object addDo(@Param("..") Pet pet, Errors es, HttpServletRequest req) {
    try {
        if (es.hasError()) {
            return Result.error(es);
        }
        petService.insert(pet);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #20
Source File: LogininforController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询系统访问记录列表
 */
@RequiresPermissions("monitor:logininfor:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	return logininforService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #21
Source File: SiteController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询站点列表
 */
@RequiresPermissions("cms:site:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return siteService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #22
Source File: TaskController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存定时任务
 */
@RequiresPermissions("sys:task:add")
@At
@POST
@Ok("json")
@Slog(tag="定时任务", after="新增保存定时任务id=${args[0].id}")
public Object addDo(@Param("..") Task task, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
             return Result.error(es);
        }
        Task sysTask =taskService.insert(task);
        taskService.addQuartz(sysTask);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #23
Source File: RoleController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@At
@POST
@Ok("json")
@RequiresPermissions("sys:role:edit")
@Slog(tag="角色", after="修改保存角色")
public Object editDo(@Param("..") Role data,Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
             return Result.error(es);
        }
        if(Lang.isNotEmpty(data)){
            data.setUpdateBy(ShiroUtils.getSysUserId());
            data.setUpdateTime(new Date());
            roleService.update(data);
        }
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #24
Source File: ConfigController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存系统参数
 */
@RequiresPermissions("sys:config:add")
@At
@POST
@Ok("json")
@Slog(tag="系统参数", after="新增保存系统参数id=${args[0].configKey}")
public Object addDo(@Param("..") Config config, Errors es, HttpServletRequest req) {
	try {
		if(es.hasError()){
			throw new ErrorException(es);
		}
		configService.insert(config);
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
	}
}
 
Example #25
Source File: ConfigController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存系统参数
 */
@RequiresPermissions("sys:config:edit")
@At
@POST
@Ok("json")
@Slog(tag="系统参数", after="修改保存系统参数")
public Object editDo(@Param("..") Config config, Errors es, HttpServletRequest req) {
	try {
		if(es.hasError()){
			throw new ErrorException(es);
		}
		if(Lang.isNotEmpty(config)){
			config.setUpdateBy(ShiroUtils.getSysUserId());
			config.setUpdateTime(new Date());
			configService.update(config);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
	}
}
 
Example #26
Source File: TaskController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存定时任务
 */
@RequiresPermissions("sys:task:edit")
@At
@POST
@Ok("json")
@Slog(tag="定时任务", after="修改保存定时任务")
public Object editDo(@Param("..") Task sysTask, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
             return Result.error(es);
        }
        taskService.addQuartz(sysTask);
        if(Lang.isNotEmpty(sysTask)){
            sysTask.setUpdateBy(ShiroUtils.getSysUserId());
            sysTask.setUpdateTime(new Date());
            taskService.update(sysTask);
        }
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #27
Source File: PostController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存岗位
 */
@RequiresPermissions("sys:post:add")
@At
@POST
@Ok("json")
@Slog(tag="岗位", after="新增保存岗位id=${args[0].id}")
public Object addDo(@Param("..") Post post, Errors es, HttpServletRequest req) {
	try {
		if(es.hasError()){
			 return Result.error(es);
		}
		postService.insert(post);
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
	}
}
 
Example #28
Source File: TaskController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 删除定时任务
 */
@At("/remove")
@Ok("json")
@RequiresPermissions("sys:task:remove")
@Slog(tag ="定时任务", after= "删除定时任务:${array2str(args[0])}")
public Object remove(@Param("ids") String[] ids, HttpServletRequest req) {
    try {
        taskService.delete(ids);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error("system.error");
    }
}
 
Example #29
Source File: ArticleController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 修改文章
 */
@At("/edit/?")
@Ok("th://cms/article/edit.html")
public void edit(String id, HttpServletRequest req) {
    Article article = articleService.fetch(id);
    article = articleService.fetchLinks(article,"category");
    req.setAttribute("article", article);
}
 
Example #30
Source File: TaskController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 查询定时任务列表
 */
@RequiresPermissions("sys:task:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
                   @Param("pageSize")Integer pageSize,
                   @Param("name") String name,
                   HttpServletRequest req) {
    Cnd cnd = Cnd.NEW();
    if (!Strings.isBlank(name)) {
        //cnd.and("name", "like", "%" + name +"%");
    }
    return taskService.tableList(pageNum, pageSize, cnd);
}