org.nutz.lang.Lang Java Examples

The following examples show how to use org.nutz.lang.Lang. 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: WechatAPIImpl.java    From mpsdk4j with Apache License 2.0 6 votes vote down vote up
@Override
public Follower getWebOauth2User(String openId, String lang) {
    lang = Strings.sBlank(lang, "zh_CN");
    WebOauth2Result result = _oath2.get(openId);
    if (result == null){
       throw Lang.wrapThrow(new WechatAPIException("用户未授权"));
    } else if (!result.isAvailable()){
        result = refreshWebOauth2Result(result.getRefreshToken());
    }

    String url = mergeAPIUrl(oauth2UserURL, result.getAccessToken(), openId, lang);
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "以网页授权方式获取公众号[%s]的用户[%s-%s]信息失败.",
            openId,
            lang);
    return Json.fromJson(Follower.class, ar.getJson());
}
 
Example #2
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 #3
Source File: AsyncFactory.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
     * 同步session到数据库
     *
     * @param session 在线用户会话
     * @return 任务task
     */
    public TimerTask syncSessionToDb(OnlineSession session) {
        return new TimerTask() {
            @Override
            public void run() {
                UserOnline online = new UserOnline();
                online.setSessionId(String.valueOf(session.getId()));
                online.setDeptName(session.getDeptName());
                online.setLoginName(session.getLoginName());
                online.setStartTimestamp(session.getStartTimestamp());
                online.setLastAccessTime(session.getLastAccessTime());
                online.setExpireTime(session.getTimeout());
                online.setIpaddr(Lang.getIP(Mvcs.getReq()));
                online.setLoginLocation(AddressUtils.getRealAddressByIP(Lang.getIP(Mvcs.getReq())));
                online.setBrowser(session.getBrowser());
                online.setOs(session.getOs());
//                online.setStatus(session.getStatus());
                online.setSession(session);
                userOnlineService.insert(online);

            }
        };
    }
 
Example #4
Source File: ConvertUtil.java    From spring-boot-seed with MIT License 6 votes vote down vote up
/**
 * 将来源按转换器的方式转换成Map<Key,List<Obj>>的方式.
 *
 * @param sources   来源
 * @param convertor 转换器
 * @param <Key>     返回的Map的key的类型
 * @param <Obj>     返回的Map的value的List包含类型
 * @return 转换后的对象类型
 */
public static <Key, Obj> Map<Key, List<Obj>> maplist(Collection<Obj> sources, IConvertor<Obj, Key> convertor) {
    Map<Key, List<Obj>> mapping = new HashMap<>(16);
    // 来源不为空
    if (sources != null && sources.size() > 0) {
        for (Obj obj : sources) {
            Key key = convertor.convert(obj);
            List<Obj> list = mapping.get(key);

            if (list == null) {
                mapping.put(key, Lang.list(obj));
            } else {
                list.add(obj);
            }
        }
    }
    return mapping;
}
 
Example #5
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 #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: BaseServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
public TableDataInfo tableListFetchLinks(Integer pageNumber, Integer pageSize,Cnd cnd,String orderByColumn,String isAsc,String linkname){
    Pager pager=null;
    if(Lang.isNotEmpty(pageNumber) && Lang.isNotEmpty(pageSize)){
        pager = this.dao().createPager(pageNumber, pageSize);
    }
    if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
        MappingField field =dao().getEntity(this.getEntityClass()).getField(orderByColumn);
        if(Lang.isNotEmpty(field)){
            cnd.orderBy(field.getColumnName(),isAsc);
        }
    }
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkname)) {
        this.dao().fetchLinks(list, linkname);
    }
    return new TableDataInfo(list, this.dao().count(this.getEntityClass(),cnd));
}
 
Example #8
Source File: WxContext.java    From nutzwx with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setPath(String path) {
	PropertiesProxy pp = new PropertiesProxy(path);
	Map<String, Object> map = new LinkedHashMap(pp.toMap());
	if (pp.get("openid") != null) {
		String appid = pp.get("openid");
		WxMaster def = Lang.map2Object(map, WxMaster.class);
		masters.put(appid, def);
		apis.put(appid, new WxApiImpl(def));
		handlers.put(appid, new BasicWxHandler(def.getToken()));
	}
	for (Entry<String, Object> en : map.entrySet()) {
		String key = en.getKey();
		if (key.endsWith(".openid")) {
			key = key.substring(0, key.indexOf('.'));
			Map<String, Object> tmp = filter(map, key + ".", null, null, null);
			String openid = tmp.get("openid").toString();
			WxMaster one = Lang.map2Object(tmp, WxMaster.class);
			masters.put(openid, one);
			apis.put(openid, new WxApiImpl(one));
			handlers.put(openid, new BasicWxHandler(one.getToken()));
		}
	}
}
 
Example #9
Source File: MenuServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkMenuUnique(String id, String parentId, String menuName) {
    Cnd cnd =Cnd.NEW();
    if(Strings.isNotBlank(id)){
        cnd.and("id","!=",id);
    }
    if(Strings.isNotBlank(parentId)){
        cnd.and("parent_id","=",parentId);
    }
    if(Strings.isNotBlank(menuName)){
        cnd.and("menu_name", "=", menuName);
    }
    List<Menu> list = this.query(cnd);
    if (Lang.isEmpty(list)) {
        return true;
    }
    return false;
}
 
Example #10
Source File: DeptServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkDeptNameUnique(String id, String parentId, String menuName) {
    Cnd cnd =Cnd.NEW();
    if(Strings.isNotBlank(id)){
        cnd.and("id","!=",id);
    }
    if(Strings.isNotBlank(parentId)){
        cnd.and("parent_id","=",parentId);
    }
    if(Strings.isNotBlank(menuName)){
        cnd.and("dept_name", "=", menuName);
    }
    List<Dept> list = this.query(cnd);
    if (Lang.isEmpty(list)) {
        return true;
    }
    return false;
}
 
Example #11
Source File: XssSqlFilterProcessor.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 判断是否排除
 * @param request
 * @return
 */
private boolean handleExcludeURL(HttpServletRequest request) {
    if (!enabled) {
        return true;
    }
    if (excludes == null || Lang.isEmpty(excludes)) {
        return false;
    }
    String url = request.getServletPath();
    for (String pattern : excludes) {
        Pattern p = Pattern.compile("^" + pattern);
        Matcher m = p.matcher(url);
        if (m.find()) {
            return true;
        }
    }
    return false;
}
 
Example #12
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 #13
Source File: SimpleAuthorizingRealm.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
		UsernamePasswordToken upToken = (UsernamePasswordToken) token;
		if (Lang.isEmpty(upToken) || Strings.isEmpty(upToken.getUsername())) {
			throw Lang.makeThrow(AuthenticationException.class, "Account name is empty");
		}
		User user = userService.fetch(Cnd.where("login_name","=",upToken.getUsername()));
		if (Lang.isEmpty(user)) {
			throw Lang.makeThrow(UnknownAccountException.class, "Account [ %s ] not found", upToken.getUsername());
		}
		if (user.isStatus()) {
			throw Lang.makeThrow(LockedAccountException.class, "Account [ %s ] is locked.", upToken.getUsername());
		}
		SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user,
				user.getPassword().toCharArray(), ByteSource.Util.bytes(user.getSalt()), getName());
		info.setCredentialsSalt(ByteSource.Util.bytes(user.getSalt()));
//        info.
		return info;
	}
 
Example #14
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 #15
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 #16
Source File: BaseServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@Override
public QueryResult listPage(int pageNumber, int pageSize, Cnd cnd, String orderByColumn, String isAsc, String linkname){
    Pager pager = this.dao().createPager(pageNumber, pageSize);
    if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
        MappingField field =dao().getEntity(this.getEntityClass()).getField(orderByColumn);
        if(Lang.isNotEmpty(field)){
            cnd.orderBy(field.getColumnName(),isAsc);
        }
    }
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkname)) {
        this.dao().fetchLinks(list, linkname);
    }
    pager.setRecordCount(this.dao().count(getEntityClass(), cnd));
    return new QueryResult(list, pager);
}
 
Example #17
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 #18
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 #19
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 #20
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 #21
Source File: ConvertUtil.java    From spring-boot-seed with MIT License 6 votes vote down vote up
/**
 * 将来源collection转换成目标list.
 *
 * @param sources          来源
 * @param convertor        转换器
 * @param ignoreNull       是否忽略空值
 * @param duplicateRemoval 是否去除重复
 * @param <Source>         来源
 * @param <Target>         目标对象
 * @return 转换后的List
 */
public static <Source, Target> List<Target> convert(Collection<Source> sources, IConvertor<Source, Target> convertor,
                                                    boolean ignoreNull, boolean duplicateRemoval) {
    // 返回目标值
    Collection<Target> targets;

    //去重使用HashSet,不去冲使用ArrayList
    targets = duplicateRemoval ? new HashSet<>() : new ArrayList<>();

    // 来源不为空
    if (sources != null && sources.size() > 0) {
        for (Source source : sources) {
            Target target = convertor.convert(source);
            // 不忽略空值或者目标不为空
            if (!ignoreNull || target != null) {
                // 添加目标
                targets.add(convertor.convert(source));
            }
        }
    }
    // 转换成list
    return Lang.collection2list(targets);
}
 
Example #22
Source File: HttpTool.java    From mpsdk4j with Apache License 2.0 6 votes vote down vote up
public static String upload(String url, File file) {
    if (log.isDebugEnabled()) {
        log.debugf("Upload url: %s, file name: %s, default timeout: %d",
                   url,
                   file.getName(),
                   CONNECT_TIME_OUT);
    }

    try {
        Request req = Request.create(url, METHOD.POST);
        req.getParams().put("media", file);
        Response resp = new FilePostSender(req).send();
        if (resp.isOK()) {
            String content = resp.getContent();
            return content;
        }

        throw Lang.wrapThrow(new RuntimeException(String.format("Upload file [%s] failed. status: %d",
                                                                url,
                                                                resp.getStatus())));
    }
    catch (Exception e) {
        throw Lang.wrapThrow(e);
    }
}
 
Example #23
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 #24
Source File: Wxs.java    From nutzwx with Apache License 2.0 6 votes vote down vote up
/**
 * 检查signature是否合法
 */
public static boolean check(String token, String signature, String timestamp, String nonce) {
    // 防范长密文攻击
    if (signature == null
        || signature.length() > 128
        || timestamp == null
        || timestamp.length() > 128
        || nonce == null
        || nonce.length() > 128) {
        log.warnf("bad check : signature=%s,timestamp=%s,nonce=%s",
                  signature,
                  timestamp,
                  nonce);
        return false;
    }
    ArrayList<String> tmp = new ArrayList<String>();
    tmp.add(token);
    tmp.add(timestamp);
    tmp.add(nonce);
    Collections.sort(tmp);
    String key = Lang.concat("", tmp).toString();
    return Lang.sha1(key).equalsIgnoreCase(signature);
}
 
Example #25
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 #26
Source File: SiteController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 修改保存站点
 */
@At
@POST
@Ok("json")
@RequiresPermissions("cms:site:edit")
@Slog(tag="站点", after="修改保存站点")
public Object editDo(@Param("..") Site site,HttpServletRequest req) {
	try {
		if(Lang.isNotEmpty(site)){
			site.setUpdateBy(ShiroUtils.getSysUserId());
			site.setUpdateTime(new Date());
			siteService.update(site);
		}
		return Result.success("system.success");
	} catch (Exception e) {
		return Result.error("system.error");
	}
}
 
Example #27
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 #28
Source File: WxApi2Impl.java    From nutzwx with Apache License 2.0 6 votes vote down vote up
/**
 * 微信支付公共POST方法(带证书)
 *
 * @param url
 *            请求路径
 * @param key
 *            商户KEY
 * @param params
 *            参数
 * @param file
 *            证书文件
 * @param password
 *            证书密码
 * @return
 */
@Override
public NutMap postPay(String url, String key, Map<String, Object> params, Object data, String password) {
    params.remove("sign");
    String sign = WxPaySign.createSign(key, params);
    params.put("sign", sign);
    Request req = Request.create(url, METHOD.POST);
    req.setData(Xmls.mapToXml(params));
    Sender sender = Sender.create(req);
    SSLSocketFactory sslSocketFactory;
    try {
        sslSocketFactory = WxPaySSL.buildSSL(data, password);
    }
    catch (Exception e) {
        throw Lang.wrapThrow(e);
    }
    sender.setSSLSocketFactory(sslSocketFactory);
    Response resp = sender.send();
    if (!resp.isOK())
        throw new IllegalStateException("postPay with SSL, resp code=" + resp.getStatus());
    return Xmls.xmlToMap(resp.getContent("UTF-8"));
}
 
Example #29
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 #30
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");
    }
}