Search in sources :

Example 1 with At

use of org.nutz.mvc.annotation.At in project nutzboot by nutzam.

the class MainLauncher method make.

@AdaptBy(type = JsonAdaptor.class)
@At("/maker/make")
@Ok("json:full")
public NutMap make(@Param("..") NutMap params) throws IOException {
    NutMap re = new NutMap();
    String key = R.UU32();
    File tmpRoot = Files.createDirIfNoExists(tmpDir + "/" + key);
    build(tmpRoot, params);
    re.put("key", key);
    re.put("ok", true);
    return re;
}
Also used : File(java.io.File) NutMap(org.nutz.lang.util.NutMap) At(org.nutz.mvc.annotation.At) AdaptBy(org.nutz.mvc.annotation.AdaptBy) Ok(org.nutz.mvc.annotation.Ok)

Example 2 with At

use of org.nutz.mvc.annotation.At in project nutzboot by nutzam.

the class EthModule method remoteAccounts.

@At("/remote/accounts")
public NutMap remoteAccounts() {
    Map<String, Web3jAccount> accounts = new HashMap<>();
    try {
        List<String> accountAddrs = web3j.ethAccounts().send().getAccounts();
        for (String address : accountAddrs) {
            Web3jAccount account = new Web3jAccount();
            account.setBanlance(web3j.ethGetBalance(address, DefaultBlockParameterName.LATEST).send().getBalance());
            account.setAddress(address);
            account.setName(address.substring(0, 8));
            accounts.put(account.getName(), account);
        }
        return new NutMap("ok", true).setv("data", accounts);
    } catch (IOException e) {
        log.info("something happen", e);
        return new NutMap("msg", e.getMessage());
    }
}
Also used : Web3jAccount(org.nutz.boot.starter.web3.Web3jAccount) HashMap(java.util.HashMap) IOException(java.io.IOException) NutMap(org.nutz.lang.util.NutMap) At(org.nutz.mvc.annotation.At)

Example 3 with At

use of org.nutz.mvc.annotation.At in project nutz by nutzam.

the class UserModule method add.

@POST
@At
public NutMap add(@Param("..") User user) {
    NutMap re = new NutMap("ok", false);
    if (Strings.isBlank(user.getName()))
        return re.setv("msg", "名字不能是空");
    if (Strings.isBlank(user.getPassword()))
        return re.setv("msg", "密码不能是空");
    dao.insert(user);
    return re.setv("ok", true);
}
Also used : NutMap(org.nutz.lang.util.NutMap) At(org.nutz.mvc.annotation.At) POST(org.nutz.mvc.annotation.POST)

Example 4 with At

use of org.nutz.mvc.annotation.At in project nutz by nutzam.

the class UserModule method list.

@At
public QueryResult list(@Param("..") Pager pager) {
    List<User> users = dao.query(User.class, null, pager);
    pager.setRecordCount(dao.count(User.class));
    QueryResult qr = new QueryResult(users, pager);
    return qr;
}
Also used : QueryResult(org.nutz.dao.QueryResult) User(net.wendal.nutzdemo.bean.User) At(org.nutz.mvc.annotation.At)

Example 5 with At

use of org.nutz.mvc.annotation.At in project nutzboot by nutzam.

the class MainLauncher method index.

@At({ "/", "/index" })
@Ok("vm:/index.vm")
public NutMap index() {
    NutMap obj = new NutMap();
    obj.setv("name", "牛牪犇").setv("age", 18);
    return obj;
}
Also used : NutMap(org.nutz.lang.util.NutMap) At(org.nutz.mvc.annotation.At) Ok(org.nutz.mvc.annotation.Ok)

Aggregations

At (org.nutz.mvc.annotation.At)14 NutMap (org.nutz.lang.util.NutMap)7 Ok (org.nutz.mvc.annotation.Ok)6 IOException (java.io.IOException)3 POST (org.nutz.mvc.annotation.POST)3 User (net.wendal.nutzdemo.bean.User)2 Web3jAccount (org.nutz.boot.starter.web3.Web3jAccount)2 User (io.nutz.cloud.demo.bean.User)1 User (io.nutz.demo.feign.bean.User)1 User (io.nutz.demo.simple.bean.User)1 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 Sha256Hash (org.apache.shiro.crypto.hash.Sha256Hash)1 Subject (org.apache.shiro.subject.Subject)1 CarrierItem (org.apache.skywalking.apm.agent.core.context.CarrierItem)1 ContextCarrier (org.apache.skywalking.apm.agent.core.context.ContextCarrier)1 AbstractSpan (org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan)1