This commit is contained in:
adan 2024-12-05 23:54:01 +08:00
parent 665209c591
commit 2289a8c40d
7 changed files with 447 additions and 2 deletions

View File

@ -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));

View File

@ -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<MyUser> 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<MyUser> list = myUserService.selectMyUserList(myUser);
ExcelUtil<MyUser> util = new ExcelUtil<MyUser>(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));
}
}

View File

@ -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();
}
}

View File

@ -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<MyUser> 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);
}

View File

@ -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<MyUser> 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);
}

View File

@ -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<MyUser> 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);
}
}

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.MyUserMapper">
<resultMap type="MyUser" id="MyUserResult">
<result property="name" column="name" />
<result property="age" column="age" />
<result property="heading" column="heading" />
</resultMap>
<sql id="selectMyUserVo">
select name, age, heading from MyUser
</sql>
<select id="selectMyUserList" parameterType="MyUser" resultMap="MyUserResult">
<include refid="selectMyUserVo"/>
<where>
<if test="age != null "> and age = #{age}</if>
<if test="heading != null and heading != ''"> and heading = #{heading}</if>
</where>
</select>
<select id="selectMyUserByName" parameterType="String" resultMap="MyUserResult">
<include refid="selectMyUserVo"/>
where name = #{name}
</select>
<insert id="insertMyUser" parameterType="MyUser">
insert into MyUser
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null">name,</if>
<if test="age != null">age,</if>
<if test="heading != null">heading,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">#{name},</if>
<if test="age != null">#{age},</if>
<if test="heading != null">#{heading},</if>
</trim>
</insert>
<update id="updateMyUser" parameterType="MyUser">
update MyUser
<trim prefix="SET" suffixOverrides=",">
<if test="age != null">age = #{age},</if>
<if test="heading != null">heading = #{heading},</if>
</trim>
where name = #{name}
</update>
<delete id="deleteMyUserByName" parameterType="String">
delete from MyUser where name = #{name}
</delete>
<delete id="deleteMyUserByNames" parameterType="String">
delete from MyUser where name in
<foreach item="name" collection="array" open="(" separator="," close=")">
#{name}
</foreach>
</delete>
</mapper>