diff --git a/box-bps/pom.xml b/box-bps/pom.xml new file mode 100644 index 000000000..7efa32418 --- /dev/null +++ b/box-bps/pom.xml @@ -0,0 +1,28 @@ + + + + ruoyi + com.ruoyi + 4.6.1 + + 4.0.0 + + box-bps + + + bps系统模块 + + + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/box-test/pom.xml b/box-test/pom.xml new file mode 100644 index 000000000..d606da50d --- /dev/null +++ b/box-test/pom.xml @@ -0,0 +1,28 @@ + + + + ruoyi + com.ruoyi + 4.6.1 + + 4.0.0 + + box-test + + + test系统模块 + + + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/ApiController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/ApiController.java new file mode 100644 index 000000000..e3a4c9f77 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/ApiController.java @@ -0,0 +1,61 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.core.domain.AjaxResult; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * + * 测试权限登录访问请求 + * + * 登录访问(返回token) POST / http://localhost:80/jwt/login?username=ry&password=admin123 + * + * 测试任意权限(header携带token) GET / http://localhost:80/api/list + * + * 测试菜单权限(header携带token) GET / http://localhost:80/api/user/list + * + * 测试角色权限(header携带token) GET / http://localhost:80/api/role/list + * + */ + + + +@RestController +@RequestMapping("/api") +public class ApiController +{ + /** + * 无权限访问 + * + * @return + */ + @GetMapping("/list") + public AjaxResult list() + { + return AjaxResult.success("list success"); + } + + /** + * 菜单权限 system:user:list + */ + @GetMapping("/user/list") + @RequiresPermissions("system:user:list") + public AjaxResult userlist() + { + return AjaxResult.success("user list success"); + } + + /** + * 角色权限 admin + */ + @GetMapping("/role/list") + @RequiresRoles("admin") + public AjaxResult rolelist() + { + return AjaxResult.success("role list success"); + } +} \ No newline at end of file diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/BoxTestController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/BoxTestController.java new file mode 100644 index 000000000..f282d9344 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/BoxTestController.java @@ -0,0 +1,18 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.service.TestService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +public class BoxTestController { + @Autowired + private TestService testService; + @RequestMapping("test") + public String test(){ + testService.test(); + return testService.test(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/FrForCrController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/FrForCrController.java new file mode 100644 index 000000000..29915a5e8 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/FrForCrController.java @@ -0,0 +1,45 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.service.OracleDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalTime; +import java.util.Map; + +@RestController +public class FrForCrController { + @Autowired + private OracleDdlService oracleDdlService; + + @CrossOrigin + @RequestMapping("/test/frforcr") + public void frforcr(@RequestBody Map map){ + for(Object value:map.values()){ + String dbName="ds7"; + String tableName=value.toString(); + String tableNameWithDb=dbName+"."+tableName; + int isTableInDb=oracleDdlService.isTableInDb(dbName,tableName); + if(isTableInDb>0){ + try{ + oracleDdlService.dropTable(tableNameWithDb); + System.out.println(LocalTime.now()+"【"+tableNameWithDb+"】已被删除!"); + }catch (Exception e){ + System.out.println(LocalTime.now()+"【"+tableNameWithDb+"】删除异常!"); + } + } + else{ + System.out.println(LocalTime.now()+"【"+tableNameWithDb+"】不存在!"); + } + } + + } + + + +} + + diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/GetJsonReqController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetJsonReqController.java new file mode 100644 index 000000000..e5ad72c9e --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/GetJsonReqController.java @@ -0,0 +1,67 @@ +package com.ruoyi.test.conrtroller; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.test.domain.Beauty; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/test") +public class GetJsonReqController { + + @CrossOrigin + @RequestMapping(value = "simple") + // json的结构和内部字段名称可以与POJO/DTO/javabean完全对应 + public Map getJsonBean(@RequestBody Beauty beauty) { + Map result = null; + + if (beauty != null) { + System.out.println("姓名:" + beauty.getName()); + System.out.println("年龄:" + beauty.getAge()); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + System.out.println("出生日期:" + sdf.format(beauty.getDate())); + + System.out.println("年收入:" + beauty.getSalary()); + result = new HashMap<>(); + result.put("code", "1"); + result.put("msg", "ok"); + } + + return result; + } + + @CrossOrigin + @RequestMapping(value = "complex") + //json的结构较为复杂,不直接与POJO/DTO/javabean对应。 + public Map getJsonComplex(@RequestBody JSONObject param) { + Map result = null; + + if (param != null) { + JSONObject master = param.getJSONObject("master"); + Beauty beauty = (Beauty) JSONObject.toJavaObject(master, Beauty.class); + System.out.println(beauty); + + JSONArray mm = param.getJSONArray("MM"); + for (int i = 0; i < mm.size(); i++) { + // 这里不能使用get(i),因为get(i)只会得到键值对。 + JSONObject json = mm.getJSONObject(i); + Beauty bt = (Beauty) JSONObject.toJavaObject(json, Beauty.class); + System.out.println(bt); + } + + result = new HashMap<>(); + result.put("code", "1"); + result.put("msg", "ok"); + } + + return result; + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/OracleDdlController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/OracleDdlController.java new file mode 100644 index 000000000..5f0b67f56 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/OracleDdlController.java @@ -0,0 +1,55 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.test.service.OracleDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +@DataSource(value = DataSourceType.SLAVE) +public class OracleDdlController { + @Autowired + private OracleDdlService oracleDdlService; + + //查询表录数 + @RequestMapping("getRecordCount") + + public String getRecordCount() { + String tableName = "tc_user"; + int result = oracleDdlService.getRecordCount(tableName); + return result + ""; + } + + //检查表是否存在 + @RequestMapping("isTableInDb") + public String isTableInDb() { + String dbName = "ds7"; + String tableName = "tc_user"; + return (oracleDdlService.isTableInDb(dbName, tableName)>0?"实例ds7中存在表tc_user":"实例ds7中不存在表tc_user"); + } + + //复制表 + @RequestMapping("copyTable") + public String copyTable() { + String originalTalble = "tc_user"; + String newTable = "new_tc_user"; + + if (oracleDdlService.isTableInDb("ds7", originalTalble) > 0) { + try { + oracleDdlService.copyTable(newTable, originalTalble); + return "复制" + originalTalble + "成功!新表名:" + newTable; + } catch (Exception e) { + System.out.println(e); + return "复制" + originalTalble + "失败!"; + } + } else { + return "表"+originalTalble+"不存在"; + + } + + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SendJsonController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SendJsonController.java new file mode 100644 index 000000000..689d2ce84 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SendJsonController.java @@ -0,0 +1,15 @@ +package com.ruoyi.test.conrtroller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + + +@Controller +public class SendJsonController { + @RequestMapping("/test/sendjson") + public String ajaxSend(){ + return ("test/sendJson"); + + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SysCustomerController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysCustomerController.java new file mode 100644 index 000000000..9e4b8e568 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysCustomerController.java @@ -0,0 +1,123 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.test.domain.SysCustomer; +import com.ruoyi.test.service.ISysCustomerService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 客户Controller + * + * @author box + * @date 2021-02-13 + */ +@Controller +@RequestMapping("/test/customer") +public class SysCustomerController extends BaseController +{ + private String prefix = "test/customer"; + + @Autowired + private ISysCustomerService sysCustomerService; + + @RequiresPermissions("test:customer:view") + @GetMapping() + public String customer() + { + return prefix + "/customer"; + } + + /** + * 查询客户列表 + */ + @RequiresPermissions("test:customer:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysCustomer sysCustomer) + { + startPage(); + List list = sysCustomerService.selectSysCustomerList(sysCustomer); + return getDataTable(list); + } + + /** + * 导出客户列表 + */ + @RequiresPermissions("test:customer:export") + @Log(title = "客户", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysCustomer sysCustomer) + { + List list = sysCustomerService.selectSysCustomerList(sysCustomer); + ExcelUtil util = new ExcelUtil(SysCustomer.class); + return util.exportExcel(list, "customer"); + } + + /** + * 新增客户 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存客户 + */ + @RequiresPermissions("test:customer:add") + @Log(title = "客户", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(SysCustomer sysCustomer) + { + return toAjax(sysCustomerService.insertSysCustomer(sysCustomer)); + } + + /** + * 修改客户 + */ + @GetMapping("/edit/{customerId}") + public String edit(@PathVariable("customerId") Long customerId, ModelMap mmap) + { + SysCustomer sysCustomer = sysCustomerService.selectSysCustomerById(customerId); + mmap.put("sysCustomer", sysCustomer); + return prefix + "/edit"; + } + + /** + * 修改保存客户 + */ + @RequiresPermissions("test:customer:edit") + @Log(title = "客户", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(SysCustomer sysCustomer) + { + return toAjax(sysCustomerService.updateSysCustomer(sysCustomer)); + } + + /** + * 删除客户 + */ + @RequiresPermissions("test:customer:remove") + @Log(title = "客户", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(sysCustomerService.deleteSysCustomerByIds(ids)); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/SysFileInfoController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysFileInfoController.java new file mode 100644 index 000000000..e7a610ef5 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/SysFileInfoController.java @@ -0,0 +1,123 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.test.domain.SysFileInfo; +import com.ruoyi.test.service.ISysFileInfoService; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 文件信息Controller + * + * @author box + * @date 2021-05-06 + */ +@Controller +@RequestMapping("/test/fileinfo") +public class SysFileInfoController extends BaseController +{ + private String prefix = "test/fileinfo"; + + @Autowired + private ISysFileInfoService sysFileInfoService; + + @RequiresPermissions("test:fileinfo:view") + @GetMapping() + public String fileinfo() + { + return prefix + "/fileinfo"; + } + + /** + * 查询文件信息列表 + */ + @RequiresPermissions("test:fileinfo:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(SysFileInfo sysFileInfo) + { + startPage(); + List list = sysFileInfoService.selectSysFileInfoList(sysFileInfo); + return getDataTable(list); + } + + /** + * 导出文件信息列表 + */ + @RequiresPermissions("test:fileinfo:export") + @Log(title = "文件信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(SysFileInfo sysFileInfo) + { + List list = sysFileInfoService.selectSysFileInfoList(sysFileInfo); + ExcelUtil util = new ExcelUtil(SysFileInfo.class); + return util.exportExcel(list, "文件信息数据"); + } + + /** + * 新增文件信息 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存文件信息 + */ + @RequiresPermissions("test:fileinfo:add") + @Log(title = "文件信息", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(SysFileInfo sysFileInfo) + { + return toAjax(sysFileInfoService.insertSysFileInfo(sysFileInfo)); + } + + /** + * 修改文件信息 + */ + @GetMapping("/edit/{fileId}") + public String edit(@PathVariable("fileId") Long fileId, ModelMap mmap) + { + SysFileInfo sysFileInfo = sysFileInfoService.selectSysFileInfoById(fileId); + mmap.put("sysFileInfo", sysFileInfo); + return prefix + "/edit"; + } + + /** + * 修改保存文件信息 + */ + @RequiresPermissions("test:fileinfo:edit") + @Log(title = "文件信息", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(SysFileInfo sysFileInfo) + { + return toAjax(sysFileInfoService.updateSysFileInfo(sysFileInfo)); + } + + /** + * 删除文件信息 + */ + @RequiresPermissions("test:fileinfo:remove") + @Log(title = "文件信息", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(sysFileInfoService.deleteSysFileInfoByIds(ids)); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/TcUserController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/TcUserController.java new file mode 100644 index 000000000..55953e6fc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/TcUserController.java @@ -0,0 +1,64 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.domain.TcUser; +import com.ruoyi.test.service.TcUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/test") +public class TcUserController { + @Autowired + private TcUserService tcUserService; + + //查询所有 + // http://localhost/test/selectall + @RequestMapping("selectAll") + @ResponseBody + public String selectAll(){ + List users=tcUserService.selectAll(); + users.forEach(System.out::println); + return users.toString()+""; + } + + + //查询 by id + // http://localhost/test/selectById/1(此处1为要获取的id) + @RequestMapping(value = "selectById/{id}", method = RequestMethod.GET) + public String selectById(@PathVariable int id) { + return tcUserService.selectById(id).toString(); + } + + //插入新用户 + // http://localhost/test/insert?id=100&name=张三&password=20 + @RequestMapping(value = "/insert", method = RequestMethod.GET) + public TcUser insert(TcUser tcUser) { + return tcUserService.insert(tcUser); + } + + //通过用户id删除用户 + // http://localhost/test/deleteById?id=1(此处1为要删除的id) + @RequestMapping(value = "/deleteById", method = RequestMethod.GET) + public String delete(int id) { + int result = tcUserService.deleteById(id); + if (result >= 1) { + return "删除成功"; + } else { + return "删除失败"; + } + } + + //更新 by id + // http://localhost/test/updateById?id=2&name=波波&password=12 + @RequestMapping(value = "/updateById", method = RequestMethod.GET) + public String update(TcUser tcUser) { + int result = tcUserService.updateById(tcUser); + if (result >= 1) { + return "修改成功"; + } else { + return "修改失败"; + } + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/TestIndexController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestIndexController.java new file mode 100644 index 000000000..4900631cc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestIndexController.java @@ -0,0 +1,16 @@ +package com.ruoyi.test.conrtroller; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.time.LocalDateTime; + +@Controller +public class TestIndexController { + @RequestMapping("/test") + public String index(ModelMap modelMap){ + modelMap.put("date", LocalDateTime.now()); + return ("test/index"); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/conrtroller/TestVerifyController.java b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestVerifyController.java new file mode 100644 index 000000000..f2d3c63f1 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/conrtroller/TestVerifyController.java @@ -0,0 +1,34 @@ +package com.ruoyi.test.conrtroller; + +import com.ruoyi.test.service.TestVerifyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +public class TestVerifyController { + @Autowired + private TestVerifyService testVerifyService; + + @RequestMapping("/test/testVerify") + public String testVerify(){ + return "/test/testVerify"; + } + + + + + /** + * 校验用户名 + */ + + @PostMapping("/test/testVerifyName") + @ResponseBody + public int testVerifyName(String name) + { + return testVerifyService.isNameUnique(name); + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/Beauty.java b/box-test/src/main/java/com/ruoyi/test/domain/Beauty.java new file mode 100644 index 000000000..41c2ec760 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/Beauty.java @@ -0,0 +1,55 @@ +package com.ruoyi.test.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class Beauty { + private String name; + private int age; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date date; + private double salary; + + public Beauty() { + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + @Override + public String toString() { + return "Beauty [name=" + name + ", age=" + age + ", date=" + date + ", salary=" + salary + "]"; + } + +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/SysCustomer.java b/box-test/src/main/java/com/ruoyi/test/domain/SysCustomer.java new file mode 100644 index 000000000..0f34bbe05 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/SysCustomer.java @@ -0,0 +1,113 @@ +package com.ruoyi.test.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.util.Date; +import java.util.List; + +/** + * 客户对象 sys_customer + * + * @author box + * @date 2021-02-13 + */ +public class SysCustomer extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 客户id */ + private Long customerId; + + /** 客户姓名 */ + @Excel(name = "客户姓名") + private String customerName; + + /** 手机号码 */ + @Excel(name = "手机号码") + private String phonenumber; + + /** 客户性别 */ + @Excel(name = "客户性别") + private String sex; + + /** 客户生日 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "客户生日", width = 30, dateFormat = "yyyy-MM-dd") + private Date birthday; + + /** 商品信息 */ + private List sysGoodsList; + + public void setCustomerId(Long customerId) + { + this.customerId = customerId; + } + + public Long getCustomerId() + { + return customerId; + } + public void setCustomerName(String customerName) + { + this.customerName = customerName; + } + + public String getCustomerName() + { + return customerName; + } + public void setPhonenumber(String phonenumber) + { + this.phonenumber = phonenumber; + } + + public String getPhonenumber() + { + return phonenumber; + } + public void setSex(String sex) + { + this.sex = sex; + } + + public String getSex() + { + return sex; + } + public void setBirthday(Date birthday) + { + this.birthday = birthday; + } + + public Date getBirthday() + { + return birthday; + } + + public List getSysGoodsList() + { + return sysGoodsList; + } + + public void setSysGoodsList(List sysGoodsList) + { + this.sysGoodsList = sysGoodsList; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("customerId", getCustomerId()) + .append("customerName", getCustomerName()) + .append("phonenumber", getPhonenumber()) + .append("sex", getSex()) + .append("birthday", getBirthday()) + .append("remark", getRemark()) + .append("sysGoodsList", getSysGoodsList()) + .toString(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/SysFileInfo.java b/box-test/src/main/java/com/ruoyi/test/domain/SysFileInfo.java new file mode 100644 index 000000000..003c5f57a --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/SysFileInfo.java @@ -0,0 +1,65 @@ +package com.ruoyi.test.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 文件信息对象 sys_file_info + * + * @author box + * @date 2021-05-06 + */ +public class SysFileInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 文件id */ + private Long fileId; + + /** 文件名称 */ + @Excel(name = "文件名称") + private String fileName; + + /** 文件路径 */ + @Excel(name = "文件路径") + private String filePath; + + public void setFileId(Long fileId) + { + this.fileId = fileId; + } + + public Long getFileId() + { + return fileId; + } + public void setFileName(String fileName) + { + this.fileName = fileName; + } + + public String getFileName() + { + return fileName; + } + public void setFilePath(String filePath) + { + this.filePath = filePath; + } + + public String getFilePath() + { + return filePath; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("fileId", getFileId()) + .append("fileName", getFileName()) + .append("filePath", getFilePath()) + .toString(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/SysGoods.java b/box-test/src/main/java/com/ruoyi/test/domain/SysGoods.java new file mode 100644 index 000000000..85740959a --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/SysGoods.java @@ -0,0 +1,124 @@ +package com.ruoyi.test.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 商品对象 sys_goods + * + * @author box + * @date 2021-02-13 + */ +public class SysGoods extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 商品id */ + private Long goodsId; + + /** 客户id */ + @Excel(name = "客户id") + private Long customerId; + + /** 商品名称 */ + @Excel(name = "商品名称") + private String name; + + /** 商品重量 */ + @Excel(name = "商品重量") + private Integer weight; + + /** 商品价格 */ + @Excel(name = "商品价格") + private BigDecimal price; + + /** 商品时间 */ + @Excel(name = "商品时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date date; + + /** 商品种类 */ + @Excel(name = "商品种类") + private String type; + + public void setGoodsId(Long goodsId) + { + this.goodsId = goodsId; + } + + public Long getGoodsId() + { + return goodsId; + } + public void setCustomerId(Long customerId) + { + this.customerId = customerId; + } + + public Long getCustomerId() + { + return customerId; + } + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setWeight(Integer weight) + { + this.weight = weight; + } + + public Integer getWeight() + { + return weight; + } + public void setPrice(BigDecimal price) + { + this.price = price; + } + + public BigDecimal getPrice() + { + return price; + } + public void setDate(Date date) + { + this.date = date; + } + + public Date getDate() + { + return date; + } + public void setType(String type) + { + this.type = type; + } + + public String getType() + { + return type; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("goodsId", getGoodsId()) + .append("customerId", getCustomerId()) + .append("name", getName()) + .append("weight", getWeight()) + .append("price", getPrice()) + .append("date", getDate()) + .append("type", getType()) + .toString(); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/domain/TcUser.java b/box-test/src/main/java/com/ruoyi/test/domain/TcUser.java new file mode 100644 index 000000000..da8a2d3cc --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/domain/TcUser.java @@ -0,0 +1,40 @@ +package com.ruoyi.test.domain; + +public class TcUser { + private int id; + private String name; + private String password; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public String toString() { + return "TcUser{" + + "id=" + id + + ", name='" + name + '\'' + + ", age='" + password + '\'' + + '}'; + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/OracleDdlMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/OracleDdlMapper.java new file mode 100644 index 000000000..e7c2f3a16 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/OracleDdlMapper.java @@ -0,0 +1,32 @@ +package com.ruoyi.test.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +@Mapper +@Component("OracleDdlMapper") +public interface OracleDdlMapper { + // alter table + int alterTableName(@Param("originalTableName") String originalTableName, + @Param("newTableName") String newTableName); + + //truncate table + int truncateTable(@Param("tableName") String tableName); + + //drop table + int dropTable(@Param("tableName") String tableName); + + //copy table + void copyTable(@Param("newTableName") String newTableName, + @Param("originalTableName") String originalTableName); + + //获取表记录数 + int getRecordCount(@Param("tableName") String tableName); + + + + //查询数据库中表是否存在 + int isTableInDb(@Param("dataBaseName") String dataBaseName, + @Param("tableName") String tableName); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/SysCustomerMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/SysCustomerMapper.java new file mode 100644 index 000000000..3ae177354 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/SysCustomerMapper.java @@ -0,0 +1,88 @@ +package com.ruoyi.test.mapper; + +import com.ruoyi.test.domain.SysCustomer; +import com.ruoyi.test.domain.SysGoods; + +import java.util.List; + +/** + * 客户Mapper接口 + * + * @author box + * @date 2021-02-13 + */ +public interface SysCustomerMapper +{ + /** + * 查询客户 + * + * @param customerId 客户ID + * @return 客户 + */ + public SysCustomer selectSysCustomerById(Long customerId); + + /** + * 查询客户列表 + * + * @param sysCustomer 客户 + * @return 客户集合 + */ + public List selectSysCustomerList(SysCustomer sysCustomer); + + /** + * 新增客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int insertSysCustomer(SysCustomer sysCustomer); + + /** + * 修改客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int updateSysCustomer(SysCustomer sysCustomer); + + /** + * 删除客户 + * + * @param customerId 客户ID + * @return 结果 + */ + public int deleteSysCustomerById(Long customerId); + + /** + * 批量删除客户 + * + * @param customerIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysCustomerByIds(String[] customerIds); + + /** + * 批量删除商品 + * + * @param customerIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysGoodsByCustomerIds(String[] customerIds); + + /** + * 批量新增商品 + * + * @param sysGoodsList 商品列表 + * @return 结果 + */ + public int batchSysGoods(List sysGoodsList); + + + /** + * 通过客户ID删除商品信息 + * + * @param roleId 角色ID + * @return 结果 + */ + public int deleteSysGoodsByCustomerId(Long customerId); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/SysFileInfoMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/SysFileInfoMapper.java new file mode 100644 index 000000000..923f598cf --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/SysFileInfoMapper.java @@ -0,0 +1,62 @@ +package com.ruoyi.test.mapper; + +import com.ruoyi.test.domain.SysFileInfo; + +import java.util.List; + +/** + * 文件信息Mapper接口 + * + * @author box + * @date 2021-05-06 + */ +public interface SysFileInfoMapper +{ + /** + * 查询文件信息 + * + * @param fileId 文件信息ID + * @return 文件信息 + */ + public SysFileInfo selectSysFileInfoById(Long fileId); + + /** + * 查询文件信息列表 + * + * @param sysFileInfo 文件信息 + * @return 文件信息集合 + */ + public List selectSysFileInfoList(SysFileInfo sysFileInfo); + + /** + * 新增文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int insertSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 修改文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int updateSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 删除文件信息 + * + * @param fileId 文件信息ID + * @return 结果 + */ + public int deleteSysFileInfoById(Long fileId); + + /** + * 批量删除文件信息 + * + * @param fileIds 需要删除的数据ID + * @return 结果 + */ + public int deleteSysFileInfoByIds(String[] fileIds); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/TcUserMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/TcUserMapper.java new file mode 100644 index 000000000..39f541866 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/TcUserMapper.java @@ -0,0 +1,26 @@ +package com.ruoyi.test.mapper; + +import com.ruoyi.test.domain.TcUser; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Mapper +@Component("TCUserMapper") +public interface TcUserMapper { + //查询所有 + List selectAll(); + + //查询 by id + TcUser selectById(int id); + + //增加 + int insert(TcUser tcUser); + + //删除 by id + int deleteById(int id); + + //更新 by id + int updateById(TcUser tcUser); +} diff --git a/box-test/src/main/java/com/ruoyi/test/mapper/TestVerifyMapper.java b/box-test/src/main/java/com/ruoyi/test/mapper/TestVerifyMapper.java new file mode 100644 index 000000000..36327dd82 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/mapper/TestVerifyMapper.java @@ -0,0 +1,11 @@ +package com.ruoyi.test.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +@Mapper +@Component("TestVerifyMapper") +public interface TestVerifyMapper { + //检查姓名是否唯一 + int isNameUnique(String name); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/ISysCustomerService.java b/box-test/src/main/java/com/ruoyi/test/service/ISysCustomerService.java new file mode 100644 index 000000000..4a3aafa4d --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/ISysCustomerService.java @@ -0,0 +1,62 @@ +package com.ruoyi.test.service; + +import com.ruoyi.test.domain.SysCustomer; + +import java.util.List; + +/** + * 客户Service接口 + * + * @author box + * @date 2021-02-13 + */ +public interface ISysCustomerService +{ + /** + * 查询客户 + * + * @param customerId 客户ID + * @return 客户 + */ + public SysCustomer selectSysCustomerById(Long customerId); + + /** + * 查询客户列表 + * + * @param sysCustomer 客户 + * @return 客户集合 + */ + public List selectSysCustomerList(SysCustomer sysCustomer); + + /** + * 新增客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int insertSysCustomer(SysCustomer sysCustomer); + + /** + * 修改客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + public int updateSysCustomer(SysCustomer sysCustomer); + + /** + * 批量删除客户 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysCustomerByIds(String ids); + + /** + * 删除客户信息 + * + * @param customerId 客户ID + * @return 结果 + */ + public int deleteSysCustomerById(Long customerId); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/ISysFileInfoService.java b/box-test/src/main/java/com/ruoyi/test/service/ISysFileInfoService.java new file mode 100644 index 000000000..7df14d3ac --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/ISysFileInfoService.java @@ -0,0 +1,62 @@ +package com.ruoyi.test.service; + +import com.ruoyi.test.domain.SysFileInfo; + +import java.util.List; + +/** + * 文件信息Service接口 + * + * @author box + * @date 2021-05-06 + */ +public interface ISysFileInfoService +{ + /** + * 查询文件信息 + * + * @param fileId 文件信息ID + * @return 文件信息 + */ + public SysFileInfo selectSysFileInfoById(Long fileId); + + /** + * 查询文件信息列表 + * + * @param sysFileInfo 文件信息 + * @return 文件信息集合 + */ + public List selectSysFileInfoList(SysFileInfo sysFileInfo); + + /** + * 新增文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int insertSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 修改文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + public int updateSysFileInfo(SysFileInfo sysFileInfo); + + /** + * 批量删除文件信息 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteSysFileInfoByIds(String ids); + + /** + * 删除文件信息信息 + * + * @param fileId 文件信息ID + * @return 结果 + */ + public int deleteSysFileInfoById(Long fileId); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/OracleDdlService.java b/box-test/src/main/java/com/ruoyi/test/service/OracleDdlService.java new file mode 100644 index 000000000..e6b5b6200 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/OracleDdlService.java @@ -0,0 +1,22 @@ +package com.ruoyi.test.service; + +public interface OracleDdlService { + //修改表名 + int alterTableName(String originalTableName, String newTableName); + + // truncate指定数据库表的数据 + int truncateTable(String tableName); + + //drop 指定定数据库表 + int dropTable(String tableName); + + + //根据传入的表明,创建新的表并且将原表的数据插入到新的Occur表中 + void copyTable(String newTableName,String originalTableName); + + //统计某张表中的总数据条数 + int getRecordCount(String tableName); + + //从指定数据库中,查询是否存在某张表 + int isTableInDb(String dataBaseName, String tableName); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/TcUserService.java b/box-test/src/main/java/com/ruoyi/test/service/TcUserService.java new file mode 100644 index 000000000..2f32e20cd --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/TcUserService.java @@ -0,0 +1,22 @@ +package com.ruoyi.test.service; + +import com.ruoyi.test.domain.TcUser; + +import java.util.List; + +public interface TcUserService { + //查询所有用户 + List selectAll(); + + //根据id查询用户信息 + TcUser selectById(int id); + + //新增用户 + TcUser insert (TcUser tcUser); + + // 根据id删除 + int deleteById (int id); + + //更新用户信息 + int updateById(TcUser tcUser); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/TestService.java b/box-test/src/main/java/com/ruoyi/test/service/TestService.java new file mode 100644 index 000000000..8b6b40b97 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/TestService.java @@ -0,0 +1,10 @@ +package com.ruoyi.test.service; + +import org.springframework.stereotype.Service; + +@Service +public class TestService { + public String test(){ + return "hello,box-test.test"; + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/TestVerifyService.java b/box-test/src/main/java/com/ruoyi/test/service/TestVerifyService.java new file mode 100644 index 000000000..6f6e9b0b4 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/TestVerifyService.java @@ -0,0 +1,9 @@ +package com.ruoyi.test.service; + +import org.springframework.stereotype.Service; + +@Service +public interface TestVerifyService { + //检查姓名是否唯一 + int isNameUnique(String name); +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/OracleDdlServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/OracleDdlServiceImpl.java new file mode 100644 index 000000000..1ebf0b930 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/OracleDdlServiceImpl.java @@ -0,0 +1,45 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.test.mapper.OracleDdlMapper; +import com.ruoyi.test.service.OracleDdlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +//@DataSource(value = DataSourceType.SLAVE) +public class OracleDdlServiceImpl implements OracleDdlService { + @Autowired + private OracleDdlMapper oracleDdlMapper; + + //修改表名 + public int alterTableName(String originalTableName, String newTableName) + { + return oracleDdlMapper.alterTableName(originalTableName,newTableName); + } + + // truncate指定数据库表的数据 + public int truncateTable(String tableName){ + return oracleDdlMapper.truncateTable(tableName); + } + + //drop 指定定数据库表 + public int dropTable(String tableName){ + return oracleDdlMapper.dropTable(tableName); + } + + + //根据传入的表明,创建新的表并且将原表的数据插入到新的Occur表中 + public void copyTable(String newTableName,String originalTableName){ + return ; + } + + //统计某张表中的总数据条数 + public int getRecordCount(String tableName){ + return oracleDdlMapper.getRecordCount(tableName); + } + + //从指定数据库中,查询是否存在某张表 + public int isTableInDb(String dataBaseName, String tableName){ + return oracleDdlMapper.isTableInDb(dataBaseName,tableName); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/SysCustomerServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/SysCustomerServiceImpl.java new file mode 100644 index 000000000..a7d13ef6b --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/SysCustomerServiceImpl.java @@ -0,0 +1,132 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.test.domain.SysCustomer; +import com.ruoyi.test.domain.SysGoods; +import com.ruoyi.test.mapper.SysCustomerMapper; +import com.ruoyi.test.service.ISysCustomerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.List; + +/** + * 客户Service业务层处理 + * + * @author box + * @date 2021-02-13 + */ +@Service +public class SysCustomerServiceImpl implements ISysCustomerService +{ + @Autowired + private SysCustomerMapper sysCustomerMapper; + + /** + * 查询客户 + * + * @param customerId 客户ID + * @return 客户 + */ + @Override + public SysCustomer selectSysCustomerById(Long customerId) + { + return sysCustomerMapper.selectSysCustomerById(customerId); + } + + /** + * 查询客户列表 + * + * @param sysCustomer 客户 + * @return 客户 + */ + @Override + public List selectSysCustomerList(SysCustomer sysCustomer) + { + return sysCustomerMapper.selectSysCustomerList(sysCustomer); + } + + /** + * 新增客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + @Transactional + @Override + public int insertSysCustomer(SysCustomer sysCustomer) + { + int rows = sysCustomerMapper.insertSysCustomer(sysCustomer); + insertSysGoods(sysCustomer); + return rows; + } + + /** + * 修改客户 + * + * @param sysCustomer 客户 + * @return 结果 + */ + @Transactional + @Override + public int updateSysCustomer(SysCustomer sysCustomer) + { + sysCustomerMapper.deleteSysGoodsByCustomerId(sysCustomer.getCustomerId()); + insertSysGoods(sysCustomer); + return sysCustomerMapper.updateSysCustomer(sysCustomer); + } + + /** + * 删除客户对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Transactional + @Override + public int deleteSysCustomerByIds(String ids) + { + sysCustomerMapper.deleteSysGoodsByCustomerIds(Convert.toStrArray(ids)); + return sysCustomerMapper.deleteSysCustomerByIds(Convert.toStrArray(ids)); + } + + /** + * 删除客户信息 + * + * @param customerId 客户ID + * @return 结果 + */ + @Override + public int deleteSysCustomerById(Long customerId) + { + sysCustomerMapper.deleteSysGoodsByCustomerId(customerId); + return sysCustomerMapper.deleteSysCustomerById(customerId); + } + + /** + * 新增商品信息 + * + * @param sysCustomer 客户对象 + */ + public void insertSysGoods(SysCustomer sysCustomer) + { + List sysGoodsList = sysCustomer.getSysGoodsList(); + Long customerId = sysCustomer.getCustomerId(); + if (StringUtils.isNotNull(sysGoodsList)) + { + List list = new ArrayList(); + for (SysGoods sysGoods : sysGoodsList) + { + sysGoods.setCustomerId(customerId); + list.add(sysGoods); + } + if (list.size() > 0) + { + sysCustomerMapper.batchSysGoods(list); + } + } + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/SysFileInfoServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/SysFileInfoServiceImpl.java new file mode 100644 index 000000000..a7407bbce --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/SysFileInfoServiceImpl.java @@ -0,0 +1,95 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.test.domain.SysFileInfo; +import com.ruoyi.test.mapper.SysFileInfoMapper; +import com.ruoyi.test.service.ISysFileInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 文件信息Service业务层处理 + * + * @author box + * @date 2021-05-06 + */ +@Service +public class SysFileInfoServiceImpl implements ISysFileInfoService +{ + @Autowired + private SysFileInfoMapper sysFileInfoMapper; + + /** + * 查询文件信息 + * + * @param fileId 文件信息ID + * @return 文件信息 + */ + @Override + public SysFileInfo selectSysFileInfoById(Long fileId) + { + return sysFileInfoMapper.selectSysFileInfoById(fileId); + } + + /** + * 查询文件信息列表 + * + * @param sysFileInfo 文件信息 + * @return 文件信息 + */ + @Override + public List selectSysFileInfoList(SysFileInfo sysFileInfo) + { + return sysFileInfoMapper.selectSysFileInfoList(sysFileInfo); + } + + /** + * 新增文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + @Override + public int insertSysFileInfo(SysFileInfo sysFileInfo) + { + return sysFileInfoMapper.insertSysFileInfo(sysFileInfo); + } + + /** + * 修改文件信息 + * + * @param sysFileInfo 文件信息 + * @return 结果 + */ + @Override + public int updateSysFileInfo(SysFileInfo sysFileInfo) + { + return sysFileInfoMapper.updateSysFileInfo(sysFileInfo); + } + + /** + * 删除文件信息对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteSysFileInfoByIds(String ids) + { + return sysFileInfoMapper.deleteSysFileInfoByIds(Convert.toStrArray(ids)); + } + + /** + * 删除文件信息信息 + * + * @param fileId 文件信息ID + * @return 结果 + */ + @Override + public int deleteSysFileInfoById(Long fileId) + { + return sysFileInfoMapper.deleteSysFileInfoById(fileId); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/TcUserServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/TcUserServiceImpl.java new file mode 100644 index 000000000..ca691ce98 --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/TcUserServiceImpl.java @@ -0,0 +1,48 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.test.domain.TcUser; +import com.ruoyi.test.mapper.TcUserMapper; +import com.ruoyi.test.service.TcUserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@DataSource(value = DataSourceType.SQLSVR) +public class TcUserServiceImpl implements TcUserService { + @Autowired + private TcUserMapper tcUserMapper; + + //查询所有用户 + @Override + public List selectAll() { + return tcUserMapper.selectAll(); + } + + //查询 by id + @Override + public TcUser selectById(int id) { + return tcUserMapper.selectById(id); + } + + //新增 + @Override + public TcUser insert(TcUser tcUser) { + int user=tcUserMapper.insert(tcUser); + return tcUser; + } + + //删除by id + @Override + public int deleteById(int id) { + return tcUserMapper.deleteById(id); + } + //更新 by id + @Override + public int updateById(TcUser tcUser) { + return tcUserMapper.updateById(tcUser); + } +} diff --git a/box-test/src/main/java/com/ruoyi/test/service/impl/TestVerifyServiceImpl.java b/box-test/src/main/java/com/ruoyi/test/service/impl/TestVerifyServiceImpl.java new file mode 100644 index 000000000..0293b1c6d --- /dev/null +++ b/box-test/src/main/java/com/ruoyi/test/service/impl/TestVerifyServiceImpl.java @@ -0,0 +1,19 @@ +package com.ruoyi.test.service.impl; + +import com.ruoyi.common.annotation.DataSource; +import com.ruoyi.common.enums.DataSourceType; +import com.ruoyi.test.mapper.TestVerifyMapper; +import com.ruoyi.test.service.TestVerifyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +@DataSource(value = DataSourceType.SQLSVR) +public class TestVerifyServiceImpl implements TestVerifyService { + @Autowired + private TestVerifyMapper testVerifyMapper; + @Override + public int isNameUnique(String name) { + return testVerifyMapper.isNameUnique(name); + } +} diff --git a/box-test/src/main/resources/mapper/test/OracleDdlMapper.xml b/box-test/src/main/resources/mapper/test/OracleDdlMapper.xml new file mode 100644 index 000000000..08cb35d57 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/OracleDdlMapper.xml @@ -0,0 +1,29 @@ + + + + + + alter table ${originalTableName} rename ${newTableName} + + + + truncate table ${tableName} + + + + drop table ${tableName} + + + + create table ${newTableName} as select * from ${originalTableName} + + + + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/SysCustomerMapper.xml b/box-test/src/main/resources/mapper/test/SysCustomerMapper.xml new file mode 100644 index 000000000..d4e97c0b1 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/SysCustomerMapper.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select customer_id, customer_name, phonenumber, sex, birthday, remark from sys_customer + + + + + + + + insert into sys_customer + + customer_name, + phonenumber, + sex, + birthday, + remark, + + + #{customerName}, + #{phonenumber}, + #{sex}, + #{birthday}, + #{remark}, + + + + + update sys_customer + + customer_name = #{customerName}, + phonenumber = #{phonenumber}, + sex = #{sex}, + birthday = #{birthday}, + remark = #{remark}, + + where customer_id = #{customerId} + + + + delete from sys_customer where customer_id = #{customerId} + + + + delete from sys_customer where customer_id in + + #{customerId} + + + + + delete from sys_goods where customer_id in + + #{customerId} + + + + + delete from sys_goods where customer_id = #{customerId} + + + + insert into sys_goods( goods_id, customer_id, name, weight, price, date, type) values + + ( #{item.goodsId}, #{item.customerId}, #{item.name}, #{item.weight}, #{item.price}, #{item.date}, #{item.type}) + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/SysFileInfoMapper.xml b/box-test/src/main/resources/mapper/test/SysFileInfoMapper.xml new file mode 100644 index 000000000..1fa4beeac --- /dev/null +++ b/box-test/src/main/resources/mapper/test/SysFileInfoMapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + select file_id, file_name, file_path from sys_file_info + + + + + + + + insert into sys_file_info + + file_name, + file_path, + + + #{fileName}, + #{filePath}, + + + + + update sys_file_info + + file_name = #{fileName}, + file_path = #{filePath}, + + where file_id = #{fileId} + + + + delete from sys_file_info where file_id = #{fileId} + + + + delete from sys_file_info where file_id in + + #{fileId} + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/TcUserMapper.xml b/box-test/src/main/resources/mapper/test/TcUserMapper.xml new file mode 100644 index 000000000..ee5f415f7 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/TcUserMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + insert into tc_user + + + id, + + + name, + + + password, + + + + + #{id,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{password,jdbcType=VARCHAR}, + + + + + + + delete from tc_user where id=#{id} + + + + + update tc_user + + + name = #{name,jdbcType=VARCHAR}, + + + password = #{password,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/mapper/test/TestVerifyMapper.xml b/box-test/src/main/resources/mapper/test/TestVerifyMapper.xml new file mode 100644 index 000000000..9995edb00 --- /dev/null +++ b/box-test/src/main/resources/mapper/test/TestVerifyMapper.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/customer/add.html b/box-test/src/main/resources/templates/test/customer/add.html new file mode 100644 index 000000000..c22d83716 --- /dev/null +++ b/box-test/src/main/resources/templates/test/customer/add.html @@ -0,0 +1,167 @@ + + + + + + + +
+
+

客户信息

+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+

商品信息

+
+
+ + +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/customer/customer.html b/box-test/src/main/resources/templates/test/customer/customer.html new file mode 100644 index 000000000..484e01d18 --- /dev/null +++ b/box-test/src/main/resources/templates/test/customer/customer.html @@ -0,0 +1,117 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • + + +
  • +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/customer/edit.html b/box-test/src/main/resources/templates/test/customer/edit.html new file mode 100644 index 000000000..41c5e9093 --- /dev/null +++ b/box-test/src/main/resources/templates/test/customer/edit.html @@ -0,0 +1,186 @@ + + + + + + + + +
+
+

客户信息

+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+

商品信息

+
+
+ + +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/fileinfo/add.html b/box-test/src/main/resources/templates/test/fileinfo/add.html new file mode 100644 index 000000000..a3a91273a --- /dev/null +++ b/box-test/src/main/resources/templates/test/fileinfo/add.html @@ -0,0 +1,37 @@ + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/fileinfo/edit.html b/box-test/src/main/resources/templates/test/fileinfo/edit.html new file mode 100644 index 000000000..3d7f13c34 --- /dev/null +++ b/box-test/src/main/resources/templates/test/fileinfo/edit.html @@ -0,0 +1,38 @@ + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/fileinfo/fileinfo.html b/box-test/src/main/resources/templates/test/fileinfo/fileinfo.html new file mode 100644 index 000000000..a4b81a52c --- /dev/null +++ b/box-test/src/main/resources/templates/test/fileinfo/fileinfo.html @@ -0,0 +1,94 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/index.html b/box-test/src/main/resources/templates/test/index.html new file mode 100644 index 000000000..4b05e873e --- /dev/null +++ b/box-test/src/main/resources/templates/test/index.html @@ -0,0 +1,33 @@ + + + + + BPS后台管理系统-测试首页 + + +

BPS后台管理系统-测试首页



+一、Mybaits配置DML测试-Oracle(第二数据源) +
  • 查询所有用户
  • +
  • 新增ID为1000的用户
  • +
  • 根据ID查询用户,查询id=1000的用户
  • +
  • 修改用户为1000的用户姓名为Xia
  • +
  • 删除ID为1000的用户
  • + +

    +二、Mybaits配置DDL测试-Oracle +
  • 查询表中的记录数
  • +
  • 查询tc_user是否存在
  • +

    +Ajax发送获取Json配置测试 +

    +二、输入后验证测试 + +

  • 验证数据表中是否有记录
  • +

    + + +三、当前系统时间 + + + + \ No newline at end of file diff --git a/box-test/src/main/resources/templates/test/sendJson.html b/box-test/src/main/resources/templates/test/sendJson.html new file mode 100644 index 000000000..9c01a77e4 --- /dev/null +++ b/box-test/src/main/resources/templates/test/sendJson.html @@ -0,0 +1,99 @@ + + + + + 发送json + + + + + + +
    +


    + +
    +
    + + + diff --git a/box-test/src/main/resources/templates/test/testVerify.html b/box-test/src/main/resources/templates/test/testVerify.html new file mode 100644 index 000000000..b58ae6111 --- /dev/null +++ b/box-test/src/main/resources/templates/test/testVerify.html @@ -0,0 +1,65 @@ + + + + + + +
    +
    +
    +
    用户名: + + +
    + +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 39b46e9ec..403d891cf 100644 --- a/pom.xml +++ b/pom.xml @@ -229,6 +229,20 @@ ${ruoyi.version} + + + com.ruoyi + box-test + ${ruoyi.version} + + + + + com.ruoyi + box-bps + ${ruoyi.version} + + @@ -239,6 +253,8 @@ ruoyi-quartz ruoyi-generator ruoyi-common + box-test + box-bps pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index bec326bca..a45b2253c 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -61,6 +61,21 @@ mysql-connector-java + + + + com.oracle.database.jdbc + ojdbc6 + 11.2.0.4 + + + + + com.microsoft.sqlserver + mssql-jdbc + 8.4.1.jre8 + + com.ruoyi @@ -79,6 +94,18 @@ ruoyi-generator + + + com.ruoyi + box-test + + + + + com.ruoyi + box-bps + + diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 3c46fd50b..0c7535d6b 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -2,20 +2,48 @@ spring: datasource: type: com.alibaba.druid.pool.DruidDataSource - driverClassName: com.mysql.cj.jdbc.Driver + #driverClassName: com.mysql.cj.jdbc.Driver druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://192.168.2.18:3306/bps?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: password + password: abc.123 # 从库数据源 slave: # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: + enabled: true + url: jdbc:oracle:thin:@192.168.2.91:1521/toptest + username: ds7 + password: ds7 + driverClassName: oracle.jdbc.driver.OracleDriver + #SQlServer数据源 + sqlsvr: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:sqlserver://192.168.2.84:1433;SelectMethod=cursor;DatabaseName=ITDemo + username: sa + password: abc.123 + driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver + + # Topprod_ds_report + topproddsreport: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:oracle:thin:@192.168.2.91:1521/topprod + username: ds_report + password: ds_report + driverClassName: oracle.jdbc.driver.OracleDriver + + # Toptest_ds_report + toptestdsreport: + # 从数据源开关/默认关闭 + enabled: true + url: jdbc:oracle:thin:@192.168.2.91:1521/toptest + username: ds_report + password: ds_report + driverClassName: oracle.jdbc.driver.OracleDriver + # 初始连接数 initialSize: 5 # 最小连接池数量 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 764a13fd2..8c26d5c40 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -9,7 +9,7 @@ ruoyi: # 实例演示开关 demoEnabled: true # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/uploadPath + profile: C:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false @@ -19,7 +19,7 @@ server: port: 80 servlet: # 应用的访问路径 - context-path: / + context-path: /it_war tomcat: # tomcat的URI编码 uri-encoding: UTF-8 @@ -96,7 +96,7 @@ shiro: # 首页地址 indexUrl: /index # 验证码开关 - captchaEnabled: true + captchaEnabled: false # 验证码类型 math 数组计算 char 字符 captchaType: math cookie: diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java index 4b5341d19..ef66ad86b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java @@ -15,5 +15,20 @@ public enum DataSourceType /** * 从库 */ - SLAVE + SLAVE, + + /** + * SQLSERVER数据库 + */ + SQLSVR, + + /** + * TOPPROD_DS_REPORT数据库 + */ + TOPPRODDSREPORT, + + /** + * TOPTEST_DS_REPORT数据库 + */ + TOPTESTDSREPORT } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java index b4c356bb0..3a6d1f99f 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java @@ -49,6 +49,39 @@ public class DruidConfig return druidProperties.dataSource(dataSource); } + //add yangbo 新增SQLSERVER数据源 --Begin + @Bean + @ConfigurationProperties("spring.datasource.druid.sqlsvr") + @ConditionalOnProperty(prefix = "spring.datasource.druid.sqlsvr", name = "enabled", havingValue = "true") + public DataSource sqlsvrDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + //add yangbo 新增SQLSERVER数据源 --End + + //add yangbo 新增topprod ds_report数据源 --Begin + @Bean + @ConfigurationProperties("spring.datasource.druid.topproddsreport") + @ConditionalOnProperty(prefix = "spring.datasource.druid.topproddsreport", name = "enabled", havingValue = "true") + public DataSource topproddsreportDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + //add yangbo 新增topprod ds_report数据源 --End + + //add yangbo 新增toptest ds_report数据源 --Begin + @Bean + @ConfigurationProperties("spring.datasource.druid.toptestdsreport") + @ConditionalOnProperty(prefix = "spring.datasource.druid.toptestdsreport", name = "enabled", havingValue = "true") + public DataSource toptestdsreportDataSource(DruidProperties druidProperties) + { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + //add yangbo 新增toptest ds_report数据源 --End + @Bean(name = "dynamicDataSource") @Primary public DynamicDataSource dataSource(DataSource masterDataSource) @@ -56,6 +89,11 @@ public class DruidConfig Map targetDataSources = new HashMap<>(); targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); + //add yangbo 新增SQLSERVER、topproddsreport、toptestdsreport数据源 --Begin + setDataSource(targetDataSources, DataSourceType.SQLSVR.name(), "sqlsvrDataSource"); + setDataSource(targetDataSources, DataSourceType.TOPPRODDSREPORT.name(), "topproddsreportDataSource"); + setDataSource(targetDataSources, DataSourceType.TOPTESTDSREPORT.name(), "toptestdsreportDataSource"); + //add yangbo 新增SQLSERVER、topproddsreport、toptestdsreport数据源 --End return new DynamicDataSource(masterDataSource, targetDataSources); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java index d69672785..a3a233584 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java @@ -274,6 +274,8 @@ public class ShiroConfig filterChainDefinitionMap.put("/js/**", "anon"); filterChainDefinitionMap.put("/ruoyi/**", "anon"); filterChainDefinitionMap.put("/captcha/captchaImage**", "anon"); + filterChainDefinitionMap.put("/test/**", "anon"); //为防便测试,配置test路径可以匿名访问 + filterChainDefinitionMap.put("/anon/**", "anon"); //为防便测试,配置anon路径可以匿名访问 // 退出 logout地址,shiro去清除session filterChainDefinitionMap.put("/logout", "logout"); // 不需要拦截的访问