基于上篇的脚手架数据库移植

说明

在移植过程中,最重要的两点是数据库表的设计和一点sql语句的修改,大佬的脚手架地址奉上:https://gitee.com/duxiaod/irs。以下介绍我觉得比较重要的代码修改和数据库表的修改,其他的问题运行项目报错修改即可。记得引入ojdbc14_11g.jar,否则Oracle数据库连接不成功。

代码修改

MainMapper代码的修改,主要是修改了sql。其他的Mapper.xml文件中insert语句主键改为序列.nextval。

public interface MainMapper {

@Select("SELECT * FROM tb_users WHERE TRUNC(create_time) = TRUNC(SYSDATE)")

List selUsersToday();

@Select("SELECT * FROM TB_USERS WHERE TRUNC(SYSDATE) - TRUNC(CREATE_TIME) = 1")

List selUsersYesterday();

@Select("SELECT * FROM TB_USERS WHERE TO_CHAR(CREATE_TIME, 'yyyyiw') = TO_CHAR(SYSDATE, 'yyyyiw')")

List selUsersYearWeek();

@Select("SELECT * FROM TB_USERS WHERE TO_CHAR(CREATE_TIME,'yyyymm') = TO_CHAR(SYSDATE,'yyyymm')")

List selUsersMonth();

}

配置修改

1、resource/mybatis文件夹下的SqlMapConfig.xml中修改

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

       

       

2、resource/recource中db.properties修改

jdbc.driver=oracle.jdbc.driver.OracleDriver

jdbc.url=

jdbc.username=

jdbc.password=

数据库表以及序列

序列要最后创建,根据数据库中的主键的值进行创建。

create table TB_ROLES

(

  role_id    NUMBER(20) not null,

  role_name  VARCHAR2(50) not null,

  role_remark VARCHAR2(100)

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

comment on column TB_ROLES.role_id

  is '角色编号';

comment on column TB_ROLES.role_name

  is '角色名';

alter table TB_ROLES

  add constraint PK_ROLEID primary key (ROLE_ID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

create table TB_ADMIN

(

  id      NUMBER(20) not null,

  username VARCHAR2(50) not null,

  password VARCHAR2(50) not null,

  salt    VARCHAR2(5),

  fullname VARCHAR2(50) not null,

  e_mail  VARCHAR2(100),

  sex      VARCHAR2(1) not null,

  birthday VARCHAR2(50) not null,

  address  VARCHAR2(100) not null,

  phone    VARCHAR2(20) not null,

  role_id  NUMBER(20)

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

comment on column TB_ADMIN.id

  is '管理员ID';

comment on column TB_ADMIN.username

  is '用户名';

comment on column TB_ADMIN.password

  is '密码';

comment on column TB_ADMIN.fullname

  is '全名';

comment on column TB_ADMIN.sex

  is '性别,0:女,1:男,2:保密';

comment on column TB_ADMIN.address

  is '地址';

comment on column TB_ADMIN.phone

  is '手机号';

comment on column TB_ADMIN.role_id

  is '角色编号';

alter table TB_ADMIN

  add constraint PK_ADMINID primary key (ID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

alter table TB_ADMIN

  add constraint F_ROLEID foreign key (ROLE_ID)

  references TB_ROLES (ROLE_ID) on delete cascade;

create table TB_LOG

(

  id          NUMBER(20) not null,

  username    VARCHAR2(50) not null,

  operation  VARCHAR2(50) not null,

  method      VARCHAR2(100),

  params      VARCHAR2(500),

  ip          VARCHAR2(64),

  create_time VARCHAR2(50) not null

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

comment on column TB_LOG.operation

  is '操作';

comment on column TB_LOG.method

  is '执行方法';

comment on column TB_LOG.params

  is '请求参数';

comment on column TB_LOG.ip

  is 'ip';

comment on column TB_LOG.create_time

  is '操作时间';

alter table TB_LOG

  add constraint PK_LOGID primary key (ID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

create table TB_MENUS

(

  menu_id  NUMBER(20) not null,

  title    VARCHAR2(20) not null,

  icon      VARCHAR2(20),

  href      VARCHAR2(100),

  perms    VARCHAR2(500),

  spread    VARCHAR2(10) not null,

  parent_id NUMBER(20) not null,

  sorting  NUMBER(20)

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

comment on column TB_MENUS.menu_id

  is '菜单编号';

comment on column TB_MENUS.title

  is '菜单名';

comment on column TB_MENUS.icon

  is '图标';

comment on column TB_MENUS.href

  is '资源地址';

comment on column TB_MENUS.perms

  is '权限';

comment on column TB_MENUS.spread

  is 'true:展开,false:不展开';

comment on column TB_MENUS.parent_id

  is '父节点';

alter table TB_MENUS

  add constraint PK_MENUID primary key (MENU_ID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

create table TB_ROLES_MENUS

(

  menu_id NUMBER(20) not null,

  role_id NUMBER(20) not null

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

alter table TB_ROLES_MENUS

  add constraint PK_RMID primary key (ROLE_ID, MENU_ID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

alter table TB_ROLES_MENUS

  add constraint F_MID foreign key (MENU_ID)

  references TB_MENUS (MENU_ID) on delete cascade;

alter table TB_ROLES_MENUS

  add constraint F_RID foreign key (ROLE_ID)

  references TB_ROLES (ROLE_ID) on delete cascade;

create table TB_USERS

(

  userid      NUMBER(20) not null,

  e_mail      VARCHAR2(50) not null,

  nickname    VARCHAR2(50) not null,

  password    VARCHAR2(50) not null,

  sex        VARCHAR2(1) not null,

  birthday    VARCHAR2(50) not null,

  address    VARCHAR2(100) not null,

  phone      VARCHAR2(20),

  e_code      VARCHAR2(50) not null,

  status      VARCHAR2(1),

  create_time DATE not null

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

comment on column TB_USERS.nickname

  is '昵称:唯一';

comment on column TB_USERS.sex

  is '0:女,1:男,2:保密';

comment on column TB_USERS.status

  is '0:未激活,1:正常,2:禁用';

alter table TB_USERS

  add constraint PK_UID primary key (USERID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

create table TB_JOBS

(

  job_id            VARCHAR2(50) not null,

  job_name          VARCHAR2(50),

  job_group_name    VARCHAR2(50),

  trigger_name      VARCHAR2(50),

  trigger_group_name VARCHAR2(50),

  cron              VARCHAR2(50),

  class_name        VARCHAR2(50),

  status            VARCHAR2(2)

)

tablespace WMS

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

    initial 64K

    next 8K

    minextents 1

    maxextents unlimited

  );

comment on column LKM.TB_JOBS.job_id

  is '任务编号';

comment on column LKM.TB_JOBS.job_name

  is '任务名称';

comment on column LKM.TB_JOBS.job_group_name

  is '任务分组代码';

comment on column LKM.TB_JOBS.trigger_name

  is '触发器名称';

comment on column LKM.TB_JOBS.trigger_group_name

  is '触发器分组代码';

comment on column LKM.TB_JOBS.cron

  is '时间表达式';

comment on column LKM.TB_JOBS.class_name

  is '任务类';

comment on column LKM.TB_JOBS.status

  is '状态,0:启用,1:停用';

alter table TB_JOBS

  add constraint PK_JOB_ID primary key (JOB_ID)

  using index

  tablespace WMS

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

    initial 64K

    next 1M

    minextents 1

    maxextents unlimited

  );

create sequence SEQ_TB_ADMIN

minvalue 1

maxvalue 9999999999999999999999999999

start with 40

increment by 1

cache 20;

create sequence SEQ_TB_LOG

minvalue 1

maxvalue 99999999999999999999999999

start with 61

increment by 1

cache 20;

create sequence SEQ_TB_MENU

minvalue 1

maxvalue 99999999999999999999999999

start with 71

increment by 1

cache 20;

create sequence SEQ_TB_ROLES

minvalue 1

maxvalue 999999999999999999999999999

start with 81

increment by 1

cache 20;

create sequence SEQ_TB_USERS

minvalue 1

maxvalue 9999999999999999999999999999

start with 21

increment by 1

cache 20;

create sequence SEQ_TB_JOBS

minvalue 1

maxvalue 9999999999999999999999999999

start with 25

increment by 1

cache 20;

insert into TB_ROLES (role_id, role_name, role_remark)values (1, '超级管理员', '超级管理员');

insert into TB_ROLES (role_id, role_name, role_remark)values (61, 'ccccc', 'bbbbbb');

commit;

insert into TB_ADMIN (id, username, password, salt, fullname, e_mail, sex, birthday, address, phone, role_id)values (1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', null, 'admin', '[email protected]', '1', '1994-11-08', '北京市通州区科创十四街', '17693109997', 1);

insert into TB_ADMIN (id, username, password, salt, fullname, e_mail, sex, birthday, address, phone, role_id)values (18, 'test', 'e10adc3949ba59abbe56e057f20f883e', null, 'test', '[email protected]', '1', '2018-02-25', '甘肃省兰州市榆中县和平镇', '17601038192', null);

insert into TB_ADMIN (id, username, password, salt, fullname, e_mail, sex, birthday, address, phone, role_id)values (19, 'zgh.zhang', '5917270981938dc69698032acdccbe36', null, '张国辉', '[email protected]', '1', '2019-04-29', 'aaaa', '15552298054', 61);

commit;

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (2, '系统管理', '', null, null, 'false', 0, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (4, '账户管理', '', 'sys/adminList', null, 'false', 2, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (3, '角色管理', '', 'sys/roleList', null, 'false', 2, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (9, '用户管理', '', null, null, 'false', 0, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (10, '添加用户', '', 'user/addUser', null, 'false', 9, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (11, '管理用户', '', 'user/userList', null, 'false', 9, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (14, '系统日志', '', null, null, 'false', 0, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (15, '日志管理', '', 'log/logList', null, 'false', 14, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (43, 'SQL监控', '', null, null, 'false', 0, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (44, 'SQL监控', '', 'sys/druid', null, 'false', 43, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (46, '菜单管理', '', 'sys/menuList', null, 'false', 2, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (16, '查看', null, null, 'sys:role:list', 'false', 3, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (17, '新增', null, null, 'sys:role:save', 'false', 3, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (18, '修改', null, null, 'sys:role:update', 'false', 3, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (19, '删除', null, null, 'sys:role:delete', 'false', 3, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (20, '查看', null, null, 'sys:admin:list', 'false', 4, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (21, '新增', null, null, 'sys:admin:save', 'false', 4, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (22, '修改', null, null, 'sys:admin:update', 'false', 4, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (23, '删除', null, null, 'sys:admin:delete', 'false', 4, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (33, '新增', null, null, 'user:user:save', 'false', 10, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (34, '查看', null, null, 'user:user:list', 'false', 11, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (35, '新增', null, null, 'user:user:save', 'false', 11, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (36, '修改', null, null, 'user:user:update', 'false', 11, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (37, '删除', null, null, 'user:user:delete', 'false', 11, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (42, '查看', null, null, 'log:log:list', 'false', 15, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (45, '查看', null, null, 'sys:druid:list', 'false', 44, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (47, '查看', null, null, 'sys:menu:list', 'false', 46, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (48, '新增', null, null, 'sys:menu:save', 'false', 46, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (49, '修改', null, null, 'sys:menu:update', 'false', 46, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (50, '删除', null, null, 'sys:menu:delete', 'false', 46, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (1, '后台首页', '', 'page/main.html', null, 'false', 0, 9999);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (59, '任务调度', '', 'job/jobList', null, 'false', 2, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (60, '查看', null, null, 'job:job:list', 'false', 59, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (61, '新增', null, null, 'job:job:save', 'false', 59, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (62, '修改', null, null, 'job:job:update', 'false', 59, null);

insert into TB_MENUS (menu_id, title, icon, href, perms, spread, parent_id, sorting)values (63, '删除', null, null, 'job:job:delete', 'false', 59, null);

commit;

insert into TB_ROLES_MENUS (menu_id, role_id)values (1, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (2, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (3, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (4, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (9, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (10, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (11, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (14, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (15, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (16, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (17, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (18, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (19, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (20, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (21, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (22, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (23, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (33, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (34, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (35, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (36, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (37, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (42, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (43, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (44, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (45, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (46, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (47, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (48, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (49, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (50, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (1, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (2, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (3, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (4, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (9, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (10, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (11, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (16, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (17, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (18, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (19, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (20, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (21, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (22, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (23, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (33, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (34, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (35, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (36, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (37, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (46, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (47, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (48, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (49, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (50, 61);

insert into TB_ROLES_MENUS (menu_id, role_id)values (59, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (60, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (61, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (62, 1);

insert into TB_ROLES_MENUS (menu_id, role_id)values (63, 1);

commit;

你可能感兴趣的:(基于上篇的脚手架数据库移植)