Skip to content

Commit

Permalink
格式化代码
Browse files Browse the repository at this point in the history
去除无用的import
  • Loading branch information
tomoya committed Mar 25, 2016
1 parent 72f3249 commit a0c8da3
Show file tree
Hide file tree
Showing 51 changed files with 790 additions and 815 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/jfinalbbs/common/BaseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void clearCache(String cacheName, Object cacheKey) {

/**
* 根据用户令牌获取用户信息
*
* @param token
* @return
*/
Expand All @@ -58,6 +59,7 @@ public User getUser(String token) {

/**
* 根据用户名查询后台用户
*
* @return
*/
public AdminUser getAdminUser() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jfinalbbs/common/BaseModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BaseModel<T extends Model> extends Model<T> {

public String formatDate(Date date) {
String dateStr = "";
if(date != null) {
if (date != null) {
PrettyTime prettyTime = new PrettyTime(Locale.CHINA);
dateStr = prettyTime.format(date);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/jfinalbbs/common/JFinalbbsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.jfinal.kit.HashKit;
import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.ehcache.EhCachePlugin;
import com.jfinal.render.FreeMarkerRender;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class ClientInterceptor implements Interceptor {
public void intercept(Invocation inv) {
String token = inv.getController().getPara("token");
Result result = new Result(Constants.CODE_SUCCESS, Constants.DESC_SUCCESS, null);
if(StrUtil.isBlank(token)) {
if (StrUtil.isBlank(token)) {
result.setCode(Constants.CODE_FAILURE);
result.setDescription("用户令牌不能为空");
inv.getController().renderJson(result);
} else {
//验证token 的合法性
User user = User.me.findByToken(token);
if(user == null) {
if (user == null) {
result.setCode(Constants.CODE_FAILURE);
result.setDescription("用户令牌无效");
inv.getController().renderJson(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class CollectClientController extends BaseController {

public void index() {
String tid = getPara("tid");
if(StrUtil.isBlank(tid)) {
if (StrUtil.isBlank(tid)) {
error("话题id不能为空");
} else if(Topic.me.findById(tid) == null) {
} else if (Topic.me.findById(tid) == null) {
error("无效话题");
} else {
String token = getPara("token");
Expand All @@ -48,9 +48,9 @@ public void index() {

public void delete() {
String tid = getPara("tid");
if(StrUtil.isBlank(tid)) {
if (StrUtil.isBlank(tid)) {
error("话题id不能为空");
} else if(Topic.me.findById(tid) == null) {
} else if (Topic.me.findById(tid) == null) {
error("无效话题");
} else {
String token = getPara("token");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void index() {
}
Page<Topic> page = Topic.me.paginate(getParaToInt("p", 1),
getParaToInt("size", defaultPageSize()), tab, q, 1, l);
for(Topic t : page.getList()) {
for (Topic t : page.getList()) {
// t.set("content", )
}
success(page);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/jfinalbbs/module/index/IndexController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.jfinalbbs.utils.DateUtil;
import com.jfinalbbs.utils.EmailSender;
import com.jfinalbbs.utils.StrUtil;
import com.jfinalbbs.utils.ext.plugin.shiro.ShiroKit;
import com.jfinalbbs.utils.ext.route.ControllerBind;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
Expand Down Expand Up @@ -46,11 +45,11 @@ public void index() {
tab = "all";
setAttr("_label", Label.me.findById(l));
}
if(tab.equals("all") || tab.equals("good")) {
if (tab.equals("all") || tab.equals("good")) {
setAttr("sectionName", "板块");
} else {
Section section = Section.me.findByTab(tab);
setAttr("sectionName", section!=null?section.get("name"):"板块");
setAttr("sectionName", section != null ? section.get("name") : "板块");
}
Page<Topic> page = Topic.me.paginate(getParaToInt("p", 1),
getParaToInt("size", defaultPageSize()), tab, q, 1, l);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jfinalbbs/module/label/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public List<Topic> findByLabels(String id, List<Label> labels, int limit) {
}
labels_str = labels_str.substring(0, labels_str.length() - 1);
List<LabelTopicId> labelTopicIds = LabelTopicId.me.find(
"select * from jfbbs_label_topic_id where lid in ("+labels_str+");");
if(labelTopicIds.size() > 0) {
"select * from jfbbs_label_topic_id where lid in (" + labels_str + ");");
if (labelTopicIds.size() > 0) {
String topics_id_str = "";
for(LabelTopicId labelTopicId: labelTopicIds) {
for (LabelTopicId labelTopicId : labelTopicIds) {
topics_id_str += "'" + labelTopicId.getStr("tid") + "',";
}
topics_id_str = topics_id_str.substring(0, topics_id_str.length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public class LabelClientController extends BaseController {

public void index() {
String name = getPara("name");
if(StrUtil.isBlank(name)) {
if (StrUtil.isBlank(name)) {
List<Label> labels = Label.me.findAll();
setAttr("labels", labels);
success(labels);
} else {
Label label = Label.me.findByName(name);
Page<Topic> page = null;
if(label != null) {
if (label != null) {
page = Topic.me.paginate(getParaToInt("p", 1),
getParaToInt("size", defaultPageSize()), null, null, 1, label.getInt("id"));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jfinalbbs/module/label/LabelController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public class LabelController extends BaseController {

public void index() throws UnsupportedEncodingException {
String name = getPara(0);
if(StrUtil.isBlank(name)) {
if (StrUtil.isBlank(name)) {
List<Label> labels = Label.me.findAll();
setAttr("labels", labels);
render("front/label/list.ftl");
} else {
name = URLDecoder.decode(name, "UTF-8");
Label label = Label.me.findByName(name);
setAttr("label", label);
if(label != null) {
if (label != null) {
Page<Topic> page = Topic.me.paginate(getParaToInt("p", 1),
getParaToInt("size", defaultPageSize()), null, null, 1, label.getInt("id"));
setAttr("page", page);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/jfinalbbs/module/message/MsgContact.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public MsgContact findByAuthorIdAndToAuthorId(String authorId, String toAuthorId

/**
* 根据用户id查询此用户的会话列表
*
* @param authorId
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void delete() {
Integer contactId = getParaToInt("contactId");
if (contactId != null) {
MsgContact msgContact = MsgContact.me.findById(contactId);
if(msgContact != null) {
if (msgContact != null) {
msgContact.set("is_delete", 1).update();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void delete() {
Integer contactId = getParaToInt(0);
if (contactId != null) {
MsgContact msgContact = MsgContact.me.findById(contactId);
if(msgContact != null) {
if (msgContact != null) {
msgContact.set("is_delete", 1).update();
redirect("/message");
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jfinalbbs/module/topic/Topic.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public Page<Topic> paginate(int pageNumber, int pageSize, String tab, String q,
}
if (!StrKit.isBlank(tab) && tab.equals("good")) {
condition.append(" and t.good = 1 ");
} else if(!StrKit.isBlank(tab) && tab.equals("noreply")) {
} else if (!StrKit.isBlank(tab) && tab.equals("noreply")) {
condition.append(" and t.id not in (select tid from jfbbs_reply) ");
}
if (!StrKit.isBlank(tab) && (tab.equals("all") || tab.equals("good") || tab.equals("noreply"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
import com.jfinalbbs.module.user.User;
import com.jfinalbbs.utils.StrUtil;
import com.jfinalbbs.utils.ext.route.ControllerBind;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;

import java.io.IOException;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ public void delete() {
String tid = getPara("tid");
String token = getPara("token");
User user = getUser(token);
if(StrUtil.isBlank(tid)) {
if (StrUtil.isBlank(tid)) {
error("话题id不能为空");
} else {
Topic topic = Topic.me.findById(tid);
if(topic == null) {
if (topic == null) {
error("话题不存在");
} else {
if(user.get("id").equals(topic.get("author_id"))) {
if (user.get("id").equals(topic.get("author_id"))) {
//删除关联的标签
LabelTopicId.me.deleteByTid(tid);
topic.delete();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jfinalbbs/module/topic/TopicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void index() {
List<Label> labels = Label.me.findByTid(id);
setAttr("labels", labels);
//根据当前话题的标签查询相关话题
if(labels.size() > 0) {
if (labels.size() > 0) {
List<Topic> xgTopics = Label.me.findByLabels(id, labels, 10);
setAttr("xgTopics", xgTopics);
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public void index() {
@Before(UserInterceptor.class)
public void create() {
String labelName = getPara(0);
if(!StrUtil.isBlank(labelName)) {
if (!StrUtil.isBlank(labelName)) {
Label label = Label.me.findByName(labelName);
setAttr("label", label);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jfinalbbs/module/user/AdminUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void correlationRole(Integer userId, Integer[] roles) {
//先删除已经存在的关联
Db.update("delete from jfbbs_user_role where uid = ?", userId);
//建立新的关联关系
for(Integer rid : roles) {
for (Integer rid : roles) {
UserRole userRole = new UserRole();
userRole.set("uid", userId)
.set("rid", rid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.jfinalbbs.utils.StrUtil;
import com.jfinalbbs.utils.ext.route.ControllerBind;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;

Expand All @@ -34,7 +33,7 @@ public void index() {
@Before(Tx.class)
public void add() {
String method = getRequest().getMethod();
if(method.equalsIgnoreCase(Constants.GET)) {
if (method.equalsIgnoreCase(Constants.GET)) {
setAttr("roles", Role.me.findAll());
render("add.ftl");
} else {
Expand All @@ -57,7 +56,7 @@ public void add() {
public void edit() {
Integer id = getParaToInt("id");
String method = getRequest().getMethod();
if(method.equalsIgnoreCase(Constants.GET)) {
if (method.equalsIgnoreCase(Constants.GET)) {
setAttr("adminUser", AdminUser.me.findById(id));
setAttr("roles", Role.me.findAll());
setAttr("uroles", UserRole.me.findByUserId(id));
Expand All @@ -69,7 +68,7 @@ public void edit() {
adminUser.set("id", id)
.set("username", username)
.set("in_time", new Date());
if(StrUtil.notBlank(password)) {
if (StrUtil.notBlank(password)) {
adminUser.set("password", password);
PasswordHelper passwordHelper = new PasswordHelper();
passwordHelper.encryptPassword(adminUser);
Expand All @@ -88,7 +87,7 @@ public void edit() {
@Before(Tx.class)
public void delete() {
Integer id = getParaToInt("id");
if(id == null) {
if (id == null) {
renderError(500);
} else {
AdminUser.me.deleteById(id);
Expand All @@ -103,13 +102,13 @@ public void modifypwd() {
Subject subject = SecurityUtils.getSubject();
String username = subject.getPrincipal().toString();
String method = getRequest().getMethod();
if(method.equalsIgnoreCase(Constants.GET)) {
if (method.equalsIgnoreCase(Constants.GET)) {
AdminUser adminUser = AdminUser.me.findByUsername(username);
setAttr("adminUser", adminUser);
render("modifypwd.ftl");
} else if(method.equalsIgnoreCase(Constants.POST)) {
} else if (method.equalsIgnoreCase(Constants.POST)) {
String password = getPara("password");
if(StrUtil.isBlank(password)) {
if (StrUtil.isBlank(password)) {
setAttr("errMsg", "密码不能为空");
render("modifypwd.ftl");
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/jfinalbbs/module/user/Permission.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public List<Permission> findByPid(Object pid) {

public List<Permission> findAll() {
List<Permission> permissions = this.findByPid(0);
for(Permission p: permissions) {
for (Permission p : permissions) {
List<Permission> permissionList = this.findByPid(p.get("id"));
p.put("childPermission", permissionList);
}
Expand All @@ -32,9 +32,9 @@ public List<Permission> findAll() {
public Set<String> findPermissions(String username) {
List<Permission> permissions = super.findByCache(Constants.SHIROCACHE, Constants.PERMISSIONCACHEKEY + username,
"select p.* from jfbbs_admin_user u, jfbbs_role r, jfbbs_permission p, " +
"jfbbs_user_role ur, jfbbs_role_permission rp where u.id = ur.uid and r.id = ur.rid and r.id = rp.rid and p.id = rp.pid and u.username = ?", username);
"jfbbs_user_role ur, jfbbs_role_permission rp where u.id = ur.uid and r.id = ur.rid and r.id = rp.rid and p.id = rp.pid and u.username = ?", username);
Set<String> set = new HashSet<String>();
for(Permission p: permissions) {
for (Permission p : permissions) {
set.add(p.getStr("name"));
}
return set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class PermissionAdminController extends BaseController {
public void index() {
Integer permissionId = getParaToInt("permissionId");
List<Permission> permissions = Permission.me.findAll();
if(permissionId == null) {
if (permissionId == null) {
Permission permission = permissions.get(0);
permissionId = permission.getInt("id");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jfinalbbs/module/user/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Set<String> findRoles(String username) {
List<Role> roles = super.findByCache(Constants.SHIROCACHE, Constants.ROLECACHEKEY + username,
"select r.* from jfbbs_admin_user u, jfbbs_role r, jfbbs_user_role ur where u.id = ur.uid and r.id = ur.rid and u.username = ?", username);
Set<String> set = new HashSet<String>();
for(Role r: roles) {
for (Role r : roles) {
set.add(r.getStr("name"));
}
return set;
Expand All @@ -40,7 +40,7 @@ public void correlationPermission(Integer roleId, Integer[] permissionIds) {
//先删除已经存在的关联
Db.update("delete from jfbbs_role_permission where rid = ?", roleId);
//建立新的关联关系
for(Integer pid : permissionIds) {
for (Integer pid : permissionIds) {
RolePermission rolePermission = new RolePermission();
rolePermission.set("rid", roleId)
.set("pid", pid)
Expand Down
Loading

0 comments on commit a0c8da3

Please sign in to comment.