org.nutz.mvc.annotation.At Java Examples

The following examples show how to use org.nutz.mvc.annotation.At. 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: ApiMasterController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存主人
 */
@At
@POST
@Ok("json")
@AccessToken
public Object addDo(@Param("..") Master master, Errors es, HttpServletRequest req) {
    try {
        if (es.hasError()) {
            return Result.error(es);
        }
        masterService.insert(master);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #2
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 #3
Source File: OpenWeixinController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 开发者接入验证 确认请求来自微信服务器
 *
 * @param signature 微信加密签名
 * @param timestamp 时间戳
 * @param nonce     随机数
 * @param echostr   成为开发者验证
 * @param request
 * @param response
 * @throws IOException
 */
@At({"","get"})
public void get( @Param("signature") String signature,
                 @Param("timestamp") String timestamp,
                 @Param("nonce") String nonce,
                 @Param( "echostr") String echostr,
                HttpServletRequest request,
                HttpServletResponse response) throws IOException {
    //消息来源可靠性验证
    //确认此次GET请求来自微信服务器,原样返回echostr参数内容,则接入生效,成为开发者成功,否则接入失败
    PrintWriter out = response.getWriter();
    if (WebChatUtil.checkSignature(signature, timestamp, nonce)) {
        System.out.println("=======请求校验成功======" + echostr);
        out.print(echostr);
    }
    out.close();
    out = null;
}
 
Example #4
Source File: UserOnlineController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询在线用户记录列表
 */
@RequiresPermissions("monitor:online:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String ipaddr,
				   @Param("loginName") String loginName,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(ipaddr)){
		cnd.and("ipaddr", "=", ipaddr);
	}
	if (!Strings.isBlank(loginName)){
		cnd.and("login_name", "=", loginName);
	}
	return userOnlineService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #5
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 #6
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 #7
Source File: RoleController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
                   @Param("pageSize")Integer pageSize,
                   @Param("roleName") String roleName,
                   @Param("roleKey") String roleKey,
                   @Param("orderByColumn") String orderByColumn,
                   @Param("isAsc") String isAsc,
                   HttpServletRequest req) {
    Cnd cnd = Cnd.NEW();
    if (!Strings.isBlank(roleName)){
        cnd.and("role_name", "like", "%" + roleName +"%");
    }
    if (!Strings.isBlank(roleKey)){
        cnd.and("role_key", "=", roleKey);
    }
    return roleService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #8
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 #9
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 #10
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 #11
Source File: UserModule.java    From nutzcloud with Apache License 2.0 6 votes vote down vote up
/**
 * 这是演示api调用的入口,会顺序调用一堆请求,请关注日志
 */
@Ok("raw")
@At
public String apitest() {
    List<User> users = userService.list();
    log.info("users=" + Json.toJson(users));
    User haoqoo = userService.add("haoqoo", 19);
    User wendal = userService.add("wendal", 28);
    users = userService.list();
    log.info("users=" + Json.toJson(users));
    userService.delete(haoqoo.getId());
    userService.delete(wendal.getId());
    users = userService.list();
    log.info("users=" + Json.toJson(users));
    return "done";
}
 
Example #12
Source File: AreaController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 新增保存区域
 */
@RequiresPermissions("sys:area:add")
@At
@POST
@Ok("json")
@Slog(tag="区域", after="新增保存区域id=${args[0].id}")
public Object addDo(@Param("..") Area area, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
            return Result.error(es);
        }
        areaService.insert(area);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #13
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 #14
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 #15
Source File: DeptController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@At
@POST
@Ok("json")
@RequiresPermissions("sys:dept:add")
@Slog(tag = "部门管理", after = " 新增部门id=${args[0].id}")
public Object addDo(@Param("..") Dept data, @Param("parentId") String parentId, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
            return Result.error(es);
        }
        deptService.insertDept(data);
        return Result.success("system.success", data);
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #16
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 #17
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 #18
Source File: AreaController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存区域
 */
@RequiresPermissions("sys:area:edit")
@At
@POST
@Ok("json")
@Slog(tag="区域", after="修改保存区域")
public Object editDo(@Param("..") Area area, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
            return Result.error(es);
        }
        if(Lang.isNotEmpty(area)){
            area.setUpdateBy(ShiroUtils.getSysUserId());
            area.setUpdateTime(new Date());
            areaService.update(area);
        }
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example #19
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 #20
Source File: MasterController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询主人列表
 */
@RequiresPermissions("test:master: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 masterService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example #21
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 #22
Source File: LogininforController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
@At("/clean")
@Ok("json")
@Slog(tag="系统访问记录", after="清除系统访问记录")
@RequiresPermissions("monitor:logininfor:remove")
public Object clean()
{
	logininforService.cleanLogininfor();
	return Result.success("system.success");
}
 
Example #23
Source File: DeptController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
@At
@Ok("json")
public Object list(@Param("deptName") String deptName, HttpServletRequest req) {
    Cnd cnd = Cnd.NEW();
    if (Strings.isNotBlank(deptName)) {
        cnd.and("dept_name", "like", "%" + deptName + "%");
    }
    cnd.and("del_flag", "=", false);
    return deptService.query(cnd);
}
 
Example #24
Source File: PetController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 修改宠物
 */
@At("/edit/?")
@Ok("th:/test/pet/edit.html")
public void edit(String id, HttpServletRequest req) {
	Pet pet = petService.fetch(id);
	req.setAttribute("pet",pet);
}
 
Example #25
Source File: ArticleController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 查询文章列表
 */
@RequiresPermissions("cms:article:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
                   @Param("pageSize")Integer pageSize,
                   @Param("name") String name,
                   @Param("categoryId") String categoryId,
                   @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 (!Strings.isBlank(categoryId)){
        //cnd.and("category_id", "=", categoryId);
        cnd.where().andInBySql("category_id","SELECT id FROM cms_category  WHERE FIND_IN_SET ('%s',parent_ids)", categoryId)
                .or("category_id","=", categoryId);
    }
    if (Lang.isNotEmpty(beginTime)) {
        cnd.and("create_time", ">=", beginTime);
    }
    if (Lang.isNotEmpty(endTime)) {
        cnd.and("create_time", "<=", endTime);
    }
    return articleService.tableList(pageNum, pageSize, cnd, orderByColumn, isAsc, "category");
}
 
Example #26
Source File: PetController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
   * 详情宠物
   */
  @At("/detail/?")
  @Ok("th:/test/pet/detail.html")
  public void detail(String id, HttpServletRequest req) {
Pet pet = petService.fetch(id);
      req.setAttribute("pet",pet);
  }
 
Example #27
Source File: WxMenuController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 新增保存微信菜单
 */

@At
@POST
@Ok("json")
@RequiresPermissions("wx:menu:add")
@Slog(tag="微信菜单", after="新增保存微信菜单 id=${args[0].id}")
public Object addDo(@Param("..") WxMenu wxMenu, HttpServletRequest req) {
	try {
		wxMenuService.insert(wxMenu);
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error("system.error");
	}
}
 
Example #28
Source File: WxMenuController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
* 获取树数据
* @param parentId
* @param name
* @return
*/
@At
@Ok("json")
public List<Map<String, Object>> treeData( @Param("parentId") String parentId,
										   @Param("name") String name) {
	List<Map<String, Object>> tree = wxMenuService.selectTree(parentId,name);
	return tree;
}
 
Example #29
Source File: ActionMethodInterceptor.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    PathMappingCache pathMappingCache = (PathMappingCache) objInst.getSkyWalkingDynamicField();
    String requestURL = pathMappingCache.findPathMapping(method);
    if (requestURL == null) {
        At methodRequestMapping = method.getAnnotation(At.class);
        if (methodRequestMapping.value().length > 0) {
            requestURL = methodRequestMapping.value()[0];
        } else {
            requestURL = "";
        }
        pathMappingCache.addPathMapping(method, requestURL);
        requestURL = pathMappingCache.findPathMapping(method);
    }

    HttpServletRequest request = Mvcs.getReq();
    ContextCarrier contextCarrier = new ContextCarrier();
    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(request.getHeader(next.getHeadKey()));
    }
    AbstractSpan span = ContextManager.createEntrySpan(requestURL, contextCarrier);
    Tags.URL.set(span, request.getRequestURL().toString());
    Tags.HTTP.METHOD.set(span, request.getMethod());
    span.setComponent(ComponentsDefine.NUTZ_MVC_ANNOTATION);
    SpanLayer.asHttp(span);
}
 
Example #30
Source File: ApiMasterController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 删除主人
 */
@At("/remove")
@Ok("json")
@AccessToken
public Object remove(@Param("ids") String[] ids, HttpServletRequest req) {
    try {
        masterService.delete(ids);
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error("system.error");
    }
}