From 2289a8c40d4cacb4ca653128c309c1225476f25d Mon Sep 17 00:00:00 2001 From: adan <3126044859@qq.com> Date: Thu, 5 Dec 2024 23:54:01 +0800 Subject: [PATCH] 5 --- .../system/controller/Item2Controller.java | 5 +- .../system/controller/MyUserController.java | 101 ++++++++++++++++++ .../java/com/ruoyi/system/domain/MyUser.java | 65 +++++++++++ .../com/ruoyi/system/mapper/MyUserMapper.java | 61 +++++++++++ .../ruoyi/system/service/IMyUserService.java | 61 +++++++++++ .../service/impl/MyUserServiceImpl.java | 93 ++++++++++++++++ .../resources/mapper/system/MyUserMapper.xml | 63 +++++++++++ 7 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/controller/MyUserController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/MyUser.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/MyUserMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/IMyUserService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MyUserServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/system/MyUserMapper.xml diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/Item2Controller.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/Item2Controller.java index dcad9a4..20b36f2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/controller/Item2Controller.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/Item2Controller.java @@ -75,9 +75,10 @@ public class Item2Controller extends BaseController /** * 新增item2 */ - @PreAuthorize("@ss.hasPermi('system:item2:add')") + @Anonymous + /*@PreAuthorize("@ss.hasPermi('system:item2:add')")*/ @Log(title = "item2", businessType = BusinessType.INSERT) - @PostMapping + @PostMapping("/add") public AjaxResult add(@RequestBody Item2 item2) { return toAjax(item2Service.insertItem2(item2)); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyUserController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyUserController.java new file mode 100644 index 0000000..b0990e6 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/MyUserController.java @@ -0,0 +1,101 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; + +import com.ruoyi.common.annotation.Anonymous; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.MyUser; +import com.ruoyi.system.service.IMyUserService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * MyUserController + * + * @author ruoyi + * @date 2024-12-05 + */ +@CrossOrigin +@RestController +@RequestMapping("/system/MyUser") +public class MyUserController extends BaseController +{ + @Autowired + private IMyUserService myUserService; + + /** + * 查询MyUser列表 + */ + /*@PreAuthorize("@ss.hasPermi('system:MyUser:list')")*/ + @Anonymous + @GetMapping("/list") + public TableDataInfo list(MyUser myUser) + { + startPage(); + List list = myUserService.selectMyUserList(myUser); + return getDataTable(list); + } + + /** + * 导出MyUser列表 + */ + @PreAuthorize("@ss.hasPermi('system:MyUser:export')") + @Log(title = "MyUser", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MyUser myUser) + { + List list = myUserService.selectMyUserList(myUser); + ExcelUtil util = new ExcelUtil(MyUser.class); + util.exportExcel(response, list, "MyUser数据"); + } + + /** + * 获取MyUser详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:MyUser:query')") + @GetMapping(value = "/{name}") + public AjaxResult getInfo(@PathVariable("name") String name) + { + return success(myUserService.selectMyUserByName(name)); + } + + /** + * 新增MyUser + */ + @PreAuthorize("@ss.hasPermi('system:MyUser:add')") + @Log(title = "MyUser", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MyUser myUser) + { + return toAjax(myUserService.insertMyUser(myUser)); + } + + /** + * 修改MyUser + */ + @PreAuthorize("@ss.hasPermi('system:MyUser:edit')") + @Log(title = "MyUser", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MyUser myUser) + { + return toAjax(myUserService.updateMyUser(myUser)); + } + + /** + * 删除MyUser + */ + @PreAuthorize("@ss.hasPermi('system:MyUser:remove')") + @Log(title = "MyUser", businessType = BusinessType.DELETE) + @DeleteMapping("/{names}") + public AjaxResult remove(@PathVariable String[] names) + { + return toAjax(myUserService.deleteMyUserByNames(names)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/MyUser.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/MyUser.java new file mode 100644 index 0000000..c083d5f --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/MyUser.java @@ -0,0 +1,65 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * MyUser对象 MyUser + * + * @author ruoyi + * @date 2024-12-05 + */ +public class MyUser extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** name */ + private String name; + + /** age */ + @Excel(name = "age") + private Integer age; + + /** heading */ + @Excel(name = "heading") + private String heading; + + public void setName(String name) + { + this.name = name; + } + + public String getName() + { + return name; + } + public void setAge(Integer age) + { + this.age = age; + } + + public Integer getAge() + { + return age; + } + public void setHeading(String heading) + { + this.heading = heading; + } + + public String getHeading() + { + return heading; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("name", getName()) + .append("age", getAge()) + .append("heading", getHeading()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MyUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MyUserMapper.java new file mode 100644 index 0000000..2d79889 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/MyUserMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.MyUser; + +/** + * MyUserMapper接口 + * + * @author ruoyi + * @date 2024-12-05 + */ +public interface MyUserMapper +{ + /** + * 查询MyUser + * + * @param name MyUser主键 + * @return MyUser + */ + public MyUser selectMyUserByName(String name); + + /** + * 查询MyUser列表 + * + * @param myUser MyUser + * @return MyUser集合 + */ + public List selectMyUserList(MyUser myUser); + + /** + * 新增MyUser + * + * @param myUser MyUser + * @return 结果 + */ + public int insertMyUser(MyUser myUser); + + /** + * 修改MyUser + * + * @param myUser MyUser + * @return 结果 + */ + public int updateMyUser(MyUser myUser); + + /** + * 删除MyUser + * + * @param name MyUser主键 + * @return 结果 + */ + public int deleteMyUserByName(String name); + + /** + * 批量删除MyUser + * + * @param names 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMyUserByNames(String[] names); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IMyUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IMyUserService.java new file mode 100644 index 0000000..4ddf684 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IMyUserService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.MyUser; + +/** + * MyUserService接口 + * + * @author ruoyi + * @date 2024-12-05 + */ +public interface IMyUserService +{ + /** + * 查询MyUser + * + * @param name MyUser主键 + * @return MyUser + */ + public MyUser selectMyUserByName(String name); + + /** + * 查询MyUser列表 + * + * @param myUser MyUser + * @return MyUser集合 + */ + public List selectMyUserList(MyUser myUser); + + /** + * 新增MyUser + * + * @param myUser MyUser + * @return 结果 + */ + public int insertMyUser(MyUser myUser); + + /** + * 修改MyUser + * + * @param myUser MyUser + * @return 结果 + */ + public int updateMyUser(MyUser myUser); + + /** + * 批量删除MyUser + * + * @param names 需要删除的MyUser主键集合 + * @return 结果 + */ + public int deleteMyUserByNames(String[] names); + + /** + * 删除MyUser信息 + * + * @param name MyUser主键 + * @return 结果 + */ + public int deleteMyUserByName(String name); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MyUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MyUserServiceImpl.java new file mode 100644 index 0000000..193745e --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/MyUserServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.MyUserMapper; +import com.ruoyi.system.domain.MyUser; +import com.ruoyi.system.service.IMyUserService; + +/** + * MyUserService业务层处理 + * + * @author ruoyi + * @date 2024-12-05 + */ +@Service +public class MyUserServiceImpl implements IMyUserService +{ + @Autowired + private MyUserMapper myUserMapper; + + /** + * 查询MyUser + * + * @param name MyUser主键 + * @return MyUser + */ + @Override + public MyUser selectMyUserByName(String name) + { + return myUserMapper.selectMyUserByName(name); + } + + /** + * 查询MyUser列表 + * + * @param myUser MyUser + * @return MyUser + */ + @Override + public List selectMyUserList(MyUser myUser) + { + return myUserMapper.selectMyUserList(myUser); + } + + /** + * 新增MyUser + * + * @param myUser MyUser + * @return 结果 + */ + @Override + public int insertMyUser(MyUser myUser) + { + return myUserMapper.insertMyUser(myUser); + } + + /** + * 修改MyUser + * + * @param myUser MyUser + * @return 结果 + */ + @Override + public int updateMyUser(MyUser myUser) + { + return myUserMapper.updateMyUser(myUser); + } + + /** + * 批量删除MyUser + * + * @param names 需要删除的MyUser主键 + * @return 结果 + */ + @Override + public int deleteMyUserByNames(String[] names) + { + return myUserMapper.deleteMyUserByNames(names); + } + + /** + * 删除MyUser信息 + * + * @param name MyUser主键 + * @return 结果 + */ + @Override + public int deleteMyUserByName(String name) + { + return myUserMapper.deleteMyUserByName(name); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/MyUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/MyUserMapper.xml new file mode 100644 index 0000000..e9529a6 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/MyUserMapper.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + select name, age, heading from MyUser + + + + + + + + insert into MyUser + + name, + age, + heading, + + + #{name}, + #{age}, + #{heading}, + + + + + update MyUser + + age = #{age}, + heading = #{heading}, + + where name = #{name} + + + + delete from MyUser where name = #{name} + + + + delete from MyUser where name in + + #{name} + + + \ No newline at end of file