Java Code Examples for org.nutz.lang.Lang#isNotEmpty()

The following examples show how to use org.nutz.lang.Lang#isNotEmpty() . 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: MaterialController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存微信素材
 */
@At
@POST
@Ok("json")
@RequiresPermissions("wx:material:edit")
@Slog(tag="微信素材", after="修改保存微信素材")
public Object editDo(@Param("..") Material material,HttpServletRequest req) {
	try {
		if(Lang.isNotEmpty(material)){
			material.setUpdateBy(ShiroUtils.getSysUserId());
			material.setUpdateTime(new Date());
			materialService.update(material);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error("system.error");
	}
}
 
Example 2
Source File: UserUtils.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
public static List<User_info_list> getUser(String token){
    String data = HttpUtils.sendGet(openIdUrl,"access_token="+token);
    OpenId openId =JSON.parseObject(data,OpenId.class);
    if(Lang.isNotEmpty(openId)){
        List<User_list> userLists =new ArrayList<>();
        openId.getData().getOpenid().forEach(oid->{
            User_list user =new User_list();
            user.setOpenid(oid);
            userLists.add(user);
        });
        String jsonData = JSON.toJSONString(NutMap.NEW().addv("user_list",userLists));
        String re = HttpUtils.sendPostJson(userInfoUrl + "?access_token="+ token ,  jsonData);
        UserData userData =JSON.parseObject(re,UserData.class);
        if(Lang.isNotEmpty(userData) && userData.getUser_info_list().size()>0){
            return userData.getUser_info_list();
        }
    }
    return null;
}
 
Example 3
Source File: PostController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存岗位
 */
@RequiresPermissions("sys:post:edit")
@At
@POST
@Ok("json")
@Slog(tag="岗位", after="修改保存岗位")
public Object editDo(@Param("..") Post post, Errors es, HttpServletRequest req) {
	try {
		if(es.hasError()){
			 return Result.error(es);
		}
		if(Lang.isNotEmpty(post)){
			post.setUpdateBy(ShiroUtils.getSysUserId());
			post.setUpdateTime(new Date());
			postService.update(post);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
	}
}
 
Example 4
Source File: MaterialController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@GET
@At("/getMaterial")
@Ok("json")
public Object getWxMaterial(){
	try {
		Config config =configService.fetch("token");
		if(config!=null){
			List<Material> materialList = materialService.getWxMaterialList(config.getConfigValue());
			if(materialList.size()>0){
				Map<String, Material> materialMap =new HashMap<>();
				List<Material> materials =materialService.query();
				if(Lang.isNotEmpty(materials) && materials.size() > 0){
					materialMap = materialService.getIdMaterialMap(materials);
				}
				materialService.saveData(materialList,materialMap);
			}
		}
		return Result.success("system.success");
	} catch (Exception e) {
		throw e;
	}
}
 
Example 5
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 6
Source File: MenuController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@At
@POST
@Ok("json")
@RequiresPermissions("sys:menu:edit")
@Slog(tag="菜单", after="修改保存菜单")
public Object editDo(@Param("..") Menu menu, @Param("parentId") String parentId, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
             return Result.error(es);
        }
        if (menu != null && Strings.isEmpty(menu.getParentId())) {
            menu.setParentId("0");
        }
        if(Lang.isNotEmpty(menu)){
            menu.setUpdateBy(ShiroUtils.getSysUserId());
            menu.setUpdateTime(new Date());
            menuService.update(menu);
        }
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example 7
Source File: DictController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存字典
 */
@RequiresPermissions("sys:dict:edit")
@At
@POST
@Ok("json")
@Slog(tag="字典", after="修改保存字典")
public Object editDo(@Param("..") Dict dict,Errors es,HttpServletRequest req) {
	try {
		if(es.hasError()){
			 return Result.error(es);
		}
		if(Lang.isNotEmpty(dict)){
			dict.setUpdateBy(ShiroUtils.getSysUserId());
			dict.setUpdateTime(new Date());
			dictService.update(dict);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
	}
}
 
Example 8
Source File: CategoryController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
    * 修改保存栏目
    * @param category
    * @param req
    * @return
    */
@At
@POST
@Ok("json")
@RequiresPermissions("cms:category:edit")
@Slog(tag="栏目", after="修改保存栏目")
public Object editDo(@Param("..") Category category,HttpServletRequest req) {
	try {
		if(Lang.isNotEmpty(category)){
			category.setUpdateBy(ShiroUtils.getSysUserId());
			category.setUpdateTime(new Date());
			categoryService.update(category);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error("system.error");
	}
}
 
Example 9
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 10
Source File: GenServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 生成代码
 *
 * @param tableName
 * @return
 */
@Override
public byte[] generatorCode(String tableName, List<String> templates) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ZipOutputStream zip = new ZipOutputStream(outputStream);
    // 查询表信息
    TableInfo table = this.selectTableByName(tableName);
    // 查询列信息
    List<ColumnInfo> columns = this.selectTableColumnsByName(tableName);
    if (Lang.isNotEmpty(table) && Lang.isNotEmpty(columns)) {
        // 生成代码
        coding(table, columns, zip, templates);
        IOUtils.closeQuietly(zip);
    }
    return outputStream.toByteArray();
}
 
Example 11
Source File: MaterialController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询微信素材列表
 */
@RequiresPermissions("wx:material: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 materialService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 12
Source File: ArticleController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存文章
 */
@At
@POST
@Ok("json")
@RequiresPermissions("cms:article:edit")
@Slog(tag = "文章", after = "修改保存文章")
public Object editDo(@Param("..") Article article, HttpServletRequest req) {
    try {
        if (Lang.isNotEmpty(article)) {
            article.setUpdateBy(ShiroUtils.getSysUserId());
            article.setUpdateTime(new Date());
            articleService.updateIgnoreNull(article);
        }
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error("system.error");
    }
}
 
Example 13
Source File: ImageServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 获取图片
 * @param id
 * @return
 */
@Override
   public String get(String id){
	Image img =this.fetch(id);
	if(Lang.isNotEmpty(img)){
		if("Base64".equals(img.getPhotoType())){
			return img.getBase64();
		}else if("Qiniu".equals(img.getPhotoType())){
			return img.getUrl();
		}
		return "/open/file/get/" + img.getLocalPath();
	}
	return null;
}
 
Example 14
Source File: ShiroUtils.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
public static User getSysUser() {
    User user = null;
    Object obj = getSubject().getPrincipal();
    if (Lang.isNotEmpty(obj)) {
        user = new User();
        BeanUtils.copyBeanProp(user, obj);
    }
    return user;
}
 
Example 15
Source File: BaseServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 分页查询数据封装
 * @param pageNumber
 * @param pageSize
 * @return
 */
@Override
public TableDataInfo tableList(Integer pageNumber, Integer pageSize){
    Pager pager=null;
    if(Lang.isNotEmpty(pageNumber) && Lang.isNotEmpty(pageSize)){
        pager = this.dao().createPager(pageNumber, pageSize);
    }
    List<T> list = this.dao().query(this.getEntityClass(), null, pager);
    return new TableDataInfo(list, this.dao().count(this.getEntityClass()));
}
 
Example 16
Source File: ProfileController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
@At("/headPortrait")
@Ok("th:/sys/user/profile/headPortrait.html")
public void headPortrait(HttpServletRequest req) {
    User user = userService.fetch(ShiroUtils.getUserId());
    user = userService.fetchLinks(user, "image");
    req.setAttribute("user", user);
    if(Lang.isNotEmpty(user.getImage())){
        req.setAttribute("image", user.getImage().getBase64());
    }
}
 
Example 17
Source File: ConfigServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
@Override
public void delete(String[] ids) {
	if(Lang.isNotEmpty(ids)){
		Arrays.stream(ids).forEach(id->{
			this.dao().delete(this.getEntityClass(), id);
		});
	}
}
 
Example 18
Source File: MaterialServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 列表转map
 * @param materials
 * @return
 */
@Override
public Map<String, Material> getIdMaterialMap(List<Material> materials) {
	if(Lang.isNotEmpty(materials)){
		Map<String, Material> entityMap= materials
				.stream()
				.collect(Collectors.toMap(
						Material::getMediaId,
						Function.identity(),
						(entity1, entity2) -> entity1)
				);
		return entityMap;
	}
	return null;
}
 
Example 19
Source File: WxMenuController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 修改微信菜单
 */
@At("/edit/?")
@Ok("th://wx/menu/edit.html")
public void edit(String id, HttpServletRequest req) {
	WxMenu wxMenu = wxMenuService.fetch(id);
	req.setAttribute("menu", wxMenu);
	List<WxMenu> list =this.wxMenuService.query(Cnd.NEW().and("parent_id","=","0"));
	req.setAttribute("menuList", list);
	int menuSize =0;
	if(Lang.isNotEmpty(list)){
		menuSize =list.size();
	}
	req.setAttribute("menuSize", menuSize);
}
 
Example 20
Source File: LoginController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
@At
@Ok("re")
public String logout() {
    Subject subject = SecurityUtils.getSubject();
    while(Lang.isNotEmpty(subject) &&  subject.isAuthenticated()) {
        subject.logout();
    }
    return ">>:/login";
}