Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wendal chen <wendal1985@gmail.com>
- Loading branch information
Showing
18 changed files
with
887 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/main/java/net/wendal/nutzbook/module/DemoModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package net.wendal.nutzbook.module; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.nutz.json.Json; | ||
import org.nutz.lang.util.NutMap; | ||
import org.nutz.mvc.adaptor.JsonAdaptor; | ||
import org.nutz.mvc.adaptor.WhaleAdaptor; | ||
import org.nutz.mvc.annotation.AdaptBy; | ||
import org.nutz.mvc.annotation.At; | ||
import org.nutz.mvc.annotation.Ok; | ||
import org.nutz.mvc.annotation.Param; | ||
import org.nutz.mvc.upload.TempFile; | ||
import org.nutz.mvc.upload.UploadAdaptor; | ||
import org.nutz.mvc.upload.Uploads; | ||
|
||
import net.wendal.nutzbook.bean.User; | ||
|
||
@At("/demo") | ||
public class DemoModule { | ||
|
||
@At("/param/mydate") | ||
public void mydate(@Param("..")P p) { | ||
System.out.println(Json.toJson(p)); | ||
} | ||
|
||
public static class P { | ||
public Date mydate; | ||
} | ||
|
||
@At | ||
@AdaptBy(type=UploadAdaptor.class) | ||
public void upload(@Param("file")TempFile tmp, @Param("file")List<TempFile> files, | ||
@Param("file")List<File> files2) throws IOException{ | ||
System.out.println(tmp.getFile().getAbsolutePath()); | ||
//if (tmp != null) | ||
// tmp.delete(); | ||
System.out.println(tmp); | ||
System.out.println(files); | ||
System.out.println(files.get(0)); | ||
System.out.println(files2); | ||
} | ||
|
||
@At | ||
@Ok("json") | ||
public Object uploadp(HttpServletRequest req) { | ||
return Uploads.getInfo(req); | ||
} | ||
|
||
@Ok("json") | ||
@At("/whale/test") | ||
@AdaptBy(type=WhaleAdaptor.class) | ||
public Object whaleInput(@Param("lines")String[] lines) { | ||
return lines; | ||
} | ||
|
||
@AdaptBy(type=JsonAdaptor.class) | ||
@At("/pathjson/**") | ||
public void pathjson(NutMap map) { | ||
System.out.println(Json.toJson(map)); | ||
} | ||
|
||
@At("/get/?/?/?") | ||
@Ok("json") | ||
public void get(String host,String startTime,String endTime) { | ||
|
||
} | ||
|
||
@At("/url") | ||
@Ok("json") | ||
public void url(String url) { | ||
System.out.println(url); | ||
} | ||
|
||
@At("/play/mp3") | ||
@Ok("raw") | ||
public File play_mp3() { | ||
return new File("D:\\05472810ed6b26f5c90cc02d41e08865.mp3"); | ||
} | ||
|
||
@At("/dw/mp3") | ||
@Ok("raw") | ||
public File download_mp3() { | ||
return new File("D:\\05472810ed6b26f5c90cc02d41e08865.mp3"); | ||
} | ||
|
||
@At(value="/notfound",top=false) | ||
@Ok("raw") | ||
public String notfound() { | ||
return "404了啊啊啊"; | ||
} | ||
|
||
@At("/param/list") | ||
@Ok("json:forlook") | ||
public Object paramList(@Param("::user")List<User> users) { | ||
return users; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 48 additions & 48 deletions
96
src/main/java/net/wendal/nutzbook/service/RoleService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
package net.wendal.nutzbook.service; | ||
|
||
import java.util.List; | ||
|
||
import net.wendal.nutzbook.bean.Role; | ||
import net.wendal.nutzbook.page.Pagination; | ||
|
||
import org.nutz.dao.FieldFilter; | ||
import org.nutz.dao.FieldMatcher; | ||
import org.nutz.dao.pager.Pager; | ||
import org.nutz.dao.util.Daos; | ||
import org.nutz.ioc.loader.annotation.IocBean; | ||
import org.nutz.lang.Lang; | ||
import org.nutz.service.IdNameEntityService; | ||
|
||
@IocBean(fields = "dao") | ||
public class RoleService extends IdNameEntityService<Role> { | ||
|
||
public Pagination getListByPager(int pageNumber) { | ||
Pager pager = dao().createPager(pageNumber, 20); | ||
List<Role> list = dao().query(getEntityClass(), null, pager); | ||
pager.setRecordCount(dao().count(getEntityClass(), null)); | ||
return new Pagination(pageNumber, 20, pager.getRecordCount(), list); | ||
} | ||
|
||
public List<Role> roleList() { | ||
return dao().query(getEntityClass(), null); | ||
} | ||
|
||
public void insert(Role role) { | ||
dao().insert(role); | ||
} | ||
|
||
public void update(Role role) { | ||
FieldFilter filter = FieldFilter.create(getEntityClass(), FieldMatcher.make(null, "^(createTime|updateTime)$", true)); | ||
Daos.ext(dao(), filter).update(role); | ||
} | ||
|
||
public void updateRoleRelation(Role role, List<net.wendal.nutzbook.bean.Permission> perms) { | ||
dao().clearLinks(role, "permissions"); | ||
role.getPermissions().clear(); | ||
dao().update(role); | ||
if (!Lang.isEmpty(perms)) { | ||
role.setPermissions(perms); | ||
dao().insertRelation(role, "permissions"); | ||
} | ||
} | ||
} | ||
package net.wendal.nutzbook.service; | ||
|
||
import java.util.List; | ||
|
||
import net.wendal.nutzbook.bean.Role; | ||
import net.wendal.nutzbook.page.Pagination; | ||
|
||
import org.nutz.dao.FieldFilter; | ||
import org.nutz.dao.FieldMatcher; | ||
import org.nutz.dao.pager.Pager; | ||
import org.nutz.dao.util.Daos; | ||
import org.nutz.ioc.loader.annotation.IocBean; | ||
import org.nutz.lang.Lang; | ||
import org.nutz.service.IdNameEntityService; | ||
|
||
@IocBean(fields = "dao") | ||
public class RoleService extends IdNameEntityService<Role> { | ||
|
||
public Pagination getListByPager(int pageNumber) { | ||
Pager pager = dao().createPager(pageNumber, 20); | ||
List<Role> list = dao().query(getEntityClass(), null, pager); | ||
pager.setRecordCount(dao().count(getEntityClass(), null)); | ||
return new Pagination(pageNumber, 20, pager.getRecordCount(), list); | ||
} | ||
|
||
public List<Role> roleList() { | ||
return dao().query(getEntityClass(), null); | ||
} | ||
|
||
public Role insert(Role role) { | ||
return dao().insert(role); | ||
} | ||
|
||
public int update(Role role) { | ||
FieldFilter filter = FieldFilter.create(getEntityClass(), FieldMatcher.make(null, "^(createTime|updateTime)$", true)); | ||
return Daos.ext(dao(), filter).update(role); | ||
} | ||
|
||
public void updateRoleRelation(Role role, List<net.wendal.nutzbook.bean.Permission> perms) { | ||
dao().clearLinks(role, "permissions"); | ||
role.getPermissions().clear(); | ||
dao().update(role); | ||
if (!Lang.isEmpty(perms)) { | ||
role.setPermissions(perms); | ||
dao().insertRelation(role, "permissions"); | ||
} | ||
} | ||
} |
Oops, something went wrong.