Skip to content

Commit

Permalink
change: 为了兼容oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizzercn committed Aug 31, 2016
1 parent 30fd72d commit eec05ad
Show file tree
Hide file tree
Showing 31 changed files with 155 additions and 118 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cn/wizzer/common/base/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class Model implements Serializable {
@Column
@Comment("操作时间")
@Prev(els = @EL("$me.now()"))
@ColDefine(type = ColType.INT, width = 5)
@ColDefine(type = ColType.INT)
private Integer opAt;

@Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class CmsChannelController {
@Ok("beetl:/private/cms/channel/index.html")
@RequiresAuthentication
public void index(HttpServletRequest req) {
req.setAttribute("list", cmsChannelService.query(Cnd.where("parentId", "=", "").asc("location").asc("path")));
req.setAttribute("list", cmsChannelService.query(Cnd.where("parentId", "=", "").or("parentId", "is", null).asc("location").asc("path")));

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.cms.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -55,12 +56,15 @@ public class Cms_article extends Model implements Serializable {

@Column
@Comment("发布时间")
@ColDefine(type = ColType.INT, width = 5)
@ColDefine(type = ColType.INT)
private Integer publishAt;

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM cms_article"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM cms_article"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM cms_article")
})
private Integer location;

@Column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.cms.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -66,7 +67,10 @@ public class Cms_channel extends Model implements Serializable {

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM cms_channel"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM cms_channel"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM cms_channel")
})
private Integer location;

@Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void deleteAndChild(Cms_channel channel) {
if (!Strings.isEmpty(channel.getParentId())) {
int count = count(Cnd.where("parentId", "=", channel.getParentId()));
if (count < 1) {
dao().execute(Sqls.create("update cms_channel set hasChildren=false where id=@pid").setParam("pid", channel.getParentId()));
dao().execute(Sqls.create("update cms_channel set hasChildren=0 where id=@pid").setParam("pid", channel.getParentId()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DictController {
@Ok("beetl:/private/sys/dict/index.html")
@RequiresAuthentication
public Object index() {
return dictService.query(Cnd.where("parentId", "=", "").asc("location").asc("path"));
return dictService.query(Cnd.where("parentId", "=", "").or("parentId", "is", null).asc("location").asc("path"));
}

@At
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public Object doLogin(@Attr("loginToken") AuthenticationToken token, HttpServlet
int count = user.getLoginCount() == null ? 0 : user.getLoginCount();
sysLogService.async(Sys_log.c("info", "用户登陆", "成功登录系统!", null));
userService.update(Chain.make("loginIp", user.getLoginIp()).add("loginAt", (int) (System.currentTimeMillis() / 1000))
.add("loginCount", count + 1).add("online", true)
.add("loginCount", count + 1).add("isOnline", true)
, Cnd.where("id", "=", user.getId()));
return Result.success("login.success");
} catch (IncorrectCaptchaException e) {
Expand Down Expand Up @@ -194,9 +194,9 @@ public void logout(HttpSession session) {
try {
Subject currentUser = SecurityUtils.getSubject();
Sys_user user = (Sys_user) currentUser.getPrincipal();
sysLogService.sync(Sys_log.c("info", "用户登出", "退出系统!", null));
userService.update(Chain.make("online", false), Cnd.where("id", "=", user.getId()));
currentUser.logout();
sysLogService.sync(Sys_log.c("info", "用户登出", "退出系统!", null));
userService.update(Chain.make("isOnline", false), Cnd.where("id", "=", user.getId()));
} catch (SessionException ise) {
log.debug("Encountered session exception during logout. This can generally safely be ignored.", ise);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MenuController {
@Ok("beetl:/private/sys/menu/index.html")
@RequiresAuthentication
public void index(HttpServletRequest req) {
req.setAttribute("list", menuService.query(Cnd.where("parentId", "=", "").asc("location").asc("path")));
req.setAttribute("list", menuService.query(Cnd.where("parentId", "=", "").or("parentId", "is", null).asc("location").asc("path")));
}

@At
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Object add(@Param("unitid") String unitid, HttpServletRequest req) {
map.put("id", menu.getId());
map.put("text", menu.getName());
map.put("icon", Strings.sBlank(menu.getIcon()));
map.put("parent", menu.getParentId().equals("") ? "#" : menu.getParentId());
map.put("parent", "".equals(Strings.sNull(menu.getParentId())) ? "#" : menu.getParentId());
map.put("data", menu.getHref());
menus.add(map);
}
Expand Down Expand Up @@ -153,7 +153,7 @@ public Object editMenu(String roleId, HttpServletRequest req) {
map.put("id", menu.getId());
map.put("text", menu.getName());
map.put("icon", Strings.sBlank(menu.getIcon()));
map.put("parent", menu.getParentId().equals("") ? "#" : menu.getParentId());
map.put("parent", "".equals(Strings.sNull(menu.getParentId())) ? "#" : menu.getParentId());
map.put("data", menu.getHref());
menus.add(map);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class UnitController {
@Ok("beetl:/private/sys/unit/index.html")
@RequiresAuthentication
public Object index() {
return unitService.query(Cnd.where("parentId", "=", "").asc("path"));
return unitService.query(Cnd.where("parentId", "=", "").or("parentId", "is", null).asc("path"));
}

@At
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.sys.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -42,7 +43,10 @@ public class Sys_dict extends Model implements Serializable {

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM sys_dict"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_dict"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_dict")
})
private Integer location;

@Column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.sys.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -82,7 +83,10 @@ public class Sys_menu extends Model implements Serializable {

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM sys_menu"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_menu"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_menu")
})
private Integer location;

@Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Sys_task extends Model implements Serializable {

@Column
@Comment("执行时间")
@ColDefine(type = ColType.INT, width = 5)
@ColDefine(type = ColType.INT)
private Integer exeAt;

@Column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.sys.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -72,7 +73,10 @@ public class Sys_unit extends Model implements Serializable {

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM sys_unit"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM sys_unit"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM sys_unit")
})
private Integer location;

@Column
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/cn/wizzer/modules/back/sys/models/Sys_user.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Sys_user extends Model implements Serializable {
@Column
@Comment("是否在线")
@ColDefine(type = ColType.BOOLEAN)
private boolean online;
private boolean isOnline;

@Column
@Comment("是否禁用")
Expand All @@ -57,7 +57,7 @@ public class Sys_user extends Model implements Serializable {

@Column
@Comment("登陆时间")
@ColDefine(type = ColType.INT, width = 5)
@ColDefine(type = ColType.INT)
private Integer loginAt;

@Column
Expand All @@ -67,7 +67,7 @@ public class Sys_user extends Model implements Serializable {

@Column
@Comment("登陆次数")
@ColDefine(type = ColType.INT, width = 5)
@ColDefine(type = ColType.INT)
private Integer loginCount;

@Column
Expand Down Expand Up @@ -151,11 +151,11 @@ public void setNickname(String nickname) {
}

public boolean isOnline() {
return online;
return isOnline;
}

public void setOnline(boolean online) {
this.online = online;
public void setIsOnline(boolean isOnline) {
this.isOnline = isOnline;
}

public boolean isDisabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void deleteAndChild(Sys_dict dict) {
if (!Strings.isEmpty(dict.getParentId())) {
int count = count(Cnd.where("parentId", "=", dict.getParentId()));
if (count < 1) {
dao().execute(Sqls.create("update sys_dict set hasChildren=false where id=@pid").setParam("pid", dict.getParentId()));
dao().execute(Sqls.create("update sys_dict set hasChildren=0 where id=@pid").setParam("pid", dict.getParentId()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void deleteAndChild(Sys_menu unit) {
if (!Strings.isEmpty(unit.getParentId())) {
int count = count(Cnd.where("parentId", "=", unit.getParentId()));
if (count < 1) {
dao().execute(Sqls.create("update sys_menu set hasChildren=false where id=@pid").setParam("pid", unit.getParentId()));
dao().execute(Sqls.create("update sys_menu set hasChildren=0 where id=@pid").setParam("pid", unit.getParentId()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public RoleService(Dao dao) {

public List<Sys_menu> getMenusAndButtons(String roleId) {
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
" b.roleId=@roleId and a.disabled=false order by a.location ASC,a.path asc");
" b.roleId=@roleId and a.disabled=0 order by a.location ASC,a.path asc");
sql.params().set("roleId", roleId);
Entity<Sys_menu> entity = dao().getEntity(Sys_menu.class);
sql.setEntity(entity);
Expand All @@ -35,7 +35,7 @@ public List<Sys_menu> getMenusAndButtons(String roleId) {

public List<Sys_menu> getDatas(String roleId) {
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
" b.roleId=@roleId and a.type='data' and a.disabled=false order by a.location ASC,a.path asc");
" b.roleId=@roleId and a.type='data' and a.disabled=0 order by a.location ASC,a.path asc");
sql.params().set("roleId", roleId);
Entity<Sys_menu> entity = dao().getEntity(Sys_menu.class);
sql.setEntity(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void deleteAndChild(Sys_unit unit) {
if (!Strings.isEmpty(unit.getParentId())) {
int count = count(Cnd.where("parentId", "=", unit.getParentId()));
if (count < 1) {
dao().execute(Sqls.create("update sys_unit set hasChildren=false where id=@pid").setParam("pid", unit.getParentId()));
dao().execute(Sqls.create("update sys_unit set hasChildren=0 where id=@pid").setParam("pid", unit.getParentId()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public UserService(Dao dao) {
*/
public List<Sys_menu> getMenus(String userId) {
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
" b.roleId in(select c.roleId from sys_user_role c,sys_role d where c.roleId=d.id and c.userId=@userId and d.disabled=false) and a.disabled=false and a.isShow=true and a.type='menu' order by a.location ASC,a.path asc");
" b.roleId in(select c.roleId from sys_user_role c,sys_role d where c.roleId=d.id and c.userId=@userId and d.disabled=0) and a.disabled=0 and a.isShow=1 and a.type='menu' order by a.location ASC,a.path asc");
sql.params().set("userId", userId);
Entity<Sys_menu> entity = dao().getEntity(Sys_menu.class);
sql.setEntity(entity);
Expand All @@ -50,7 +50,7 @@ public List<Sys_menu> getMenus(String userId) {
*/
public List<Sys_menu> getMenusAndButtons(String userId) {
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
" b.roleId in(select c.roleId from sys_user_role c,sys_role d where c.roleId=d.id and c.userId=@userId and d.disabled=false) and a.disabled=false order by a.location ASC,a.path asc");
" b.roleId in(select c.roleId from sys_user_role c,sys_role d where c.roleId=d.id and c.userId=@userId and d.disabled=0) and a.disabled=0 order by a.location ASC,a.path asc");
sql.params().set("userId", userId);
Entity<Sys_menu> entity = dao().getEntity(Sys_menu.class);
sql.setEntity(entity);
Expand All @@ -67,7 +67,7 @@ public List<Sys_menu> getMenusAndButtons(String userId) {
*/
public List<Sys_menu> getDatas(String userId) {
Sql sql = Sqls.create("select distinct a.* from sys_menu a,sys_role_menu b where a.id=b.menuId and" +
" b.roleId in(select c.roleId from sys_user_role c,sys_role d where c.roleId=d.id and c.userId=@userId and d.disabled=false) and a.disabled=false and a.type='data' order by a.location ASC,a.path asc");
" b.roleId in(select c.roleId from sys_user_role c,sys_role d where c.roleId=d.id and c.userId=@userId and d.disabled=0) and a.disabled=0 and a.type='data' order by a.location ASC,a.path asc");
sql.params().set("userId", userId);
Entity<Sys_menu> entity = dao().getEntity(Sys_menu.class);
sql.setEntity(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Wx_mass extends Model implements Serializable {

@Column
@Comment("发送状态")
@ColDefine(type = ColType.INT, width = 1)
@ColDefine(type = ColType.INT)
protected Integer status;

@Column
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.wx.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -50,12 +51,15 @@ public class Wx_mass_news extends Model implements Serializable {

@Column
@Comment("显示封面")
@ColDefine(type = ColType.INT,width = 1)
@ColDefine(type = ColType.INT)
protected Integer show_cover_pic;

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM wx_mass_news"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM wx_mass_news"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM wx_mass_news")
})
private Integer location;

@Column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Wx_mass_send extends Model implements Serializable {

@Column
@Comment("发送状态")
@ColDefine(type = ColType.INT, width = 1)
@ColDefine(type = ColType.INT)
protected Integer status;

@Column
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/cn/wizzer/modules/back/wx/models/Wx_menu.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cn.wizzer.modules.back.wx.models;

import cn.wizzer.common.base.Model;
import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
Expand Down Expand Up @@ -50,7 +51,10 @@ public class Wx_menu extends Model implements Serializable {

@Column
@Comment("排序字段")
@Prev(@SQL("SELECT IFNULL(MAX(location),0)+1 FROM wx_menu"))
@Prev({
@SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(location),0)+1 FROM wx_menu"),
@SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(location),0)+1 FROM wx_menu")
})
private Integer location;

@Column
Expand Down
Loading

0 comments on commit eec05ad

Please sign in to comment.