国家信息

dev
masong 3 years ago
parent a636ca23ba
commit 48dd71f89d
  1. 62
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/CountryController.java
  2. 70
      ruoyi-system/src/main/java/com/ruoyi/system/domain/Country.java
  3. 61
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/CountryMapper.java
  4. 62
      ruoyi-system/src/main/java/com/ruoyi/system/service/ICountryService.java
  5. 94
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CountryServiceImpl.java
  6. 61
      ruoyi-system/src/main/resources/mapper/system/CountryMapper.xml

@ -0,0 +1,62 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.system.domain.Country;
import com.ruoyi.system.service.ICountryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 国家名称信息Controller
*
* @author ms
* @date 2023-03-24
*/
@RestController
@RequestMapping("/system/country")
public class CountryController extends BaseController
{
@Autowired
private ICountryService countryService;
/**
* 查询国家名称信息列表
*/
@GetMapping("/list")
public TableDataInfo list(Country country)
{
List<Country> list = countryService.selectCountryList(country);
return getDataTable(list);
}
/**
* 获取国家名称信息详细信息
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(countryService.selectCountryById(id));
}
}

@ -0,0 +1,70 @@
package com.ruoyi.system.domain;
import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.core.page.TableDataInfo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 国家名称信息对象 sys_country
*
* @author ms
* @date 2023-03-24
*/
public class Country
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 国家名称 */
@Excel(name = "国家名称")
private String name;
/** 区域编码 */
@Excel(name = "区域编码")
private String regionId;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setRegionId(String regionId)
{
this.regionId = regionId;
}
public String getRegionId()
{
return regionId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("regionId", getRegionId())
.toString();
}
}

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.Country;
/**
* 国家名称信息Mapper接口
*
* @author ms
* @date 2023-03-24
*/
public interface CountryMapper
{
/**
* 查询国家名称信息
*
* @param id 国家名称信息主键
* @return 国家名称信息
*/
public Country selectCountryById(Long id);
/**
* 查询国家名称信息列表
*
* @param country 国家名称信息
* @return 国家名称信息集合
*/
public List<Country> selectCountryList(Country country);
/**
* 新增国家名称信息
*
* @param country 国家名称信息
* @return 结果
*/
public int insertCountry(Country country);
/**
* 修改国家名称信息
*
* @param country 国家名称信息
* @return 结果
*/
public int updateCountry(Country country);
/**
* 删除国家名称信息
*
* @param id 国家名称信息主键
* @return 结果
*/
public int deleteCountryById(Long id);
/**
* 批量删除国家名称信息
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteCountryByIds(Long[] ids);
}

@ -0,0 +1,62 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.Country;
/**
* 国家名称信息Service接口
*
* @author ms
* @date 2023-03-24
*/
public interface ICountryService
{
/**
* 查询国家名称信息
*
* @param id 国家名称信息主键
* @return 国家名称信息
*/
public Country selectCountryById(Long id);
/**
* 查询国家名称信息列表
*
* @param country 国家名称信息
* @return 国家名称信息集合
*/
public List<Country> selectCountryList(Country country);
/**
* 新增国家名称信息
*
* @param country 国家名称信息
* @return 结果
*/
public int insertCountry(Country country);
/**
* 修改国家名称信息
*
* @param country 国家名称信息
* @return 结果
*/
public int updateCountry(Country country);
/**
* 批量删除国家名称信息
*
* @param ids 需要删除的国家名称信息主键集合
* @return 结果
*/
public int deleteCountryByIds(Long[] ids);
/**
* 删除国家名称信息信息
*
* @param id 国家名称信息主键
* @return 结果
*/
public int deleteCountryById(Long id);
}

@ -0,0 +1,94 @@
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.CountryMapper;
import com.ruoyi.system.domain.Country;
import com.ruoyi.system.service.ICountryService;
/**
* 国家名称信息Service业务层处理
*
* @author ms
* @date 2023-03-24
*/
@Service
public class CountryServiceImpl implements ICountryService
{
@Autowired
private CountryMapper countryMapper;
/**
* 查询国家名称信息
*
* @param id 国家名称信息主键
* @return 国家名称信息
*/
@Override
public Country selectCountryById(Long id)
{
return countryMapper.selectCountryById(id);
}
/**
* 查询国家名称信息列表
*
* @param country 国家名称信息
* @return 国家名称信息
*/
@Override
public List<Country> selectCountryList(Country country)
{
return countryMapper.selectCountryList(country);
}
/**
* 新增国家名称信息
*
* @param country 国家名称信息
* @return 结果
*/
@Override
public int insertCountry(Country country)
{
return countryMapper.insertCountry(country);
}
/**
* 修改国家名称信息
*
* @param country 国家名称信息
* @return 结果
*/
@Override
public int updateCountry(Country country)
{
return countryMapper.updateCountry(country);
}
/**
* 批量删除国家名称信息
*
* @param ids 需要删除的国家名称信息主键
* @return 结果
*/
@Override
public int deleteCountryByIds(Long[] ids)
{
return countryMapper.deleteCountryByIds(ids);
}
/**
* 删除国家名称信息信息
*
* @param id 国家名称信息主键
* @return 结果
*/
@Override
public int deleteCountryById(Long id)
{
return countryMapper.deleteCountryById(id);
}
}

@ -0,0 +1,61 @@
<?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.CountryMapper">
<resultMap type="Country" id="CountryResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="regionId" column="region_id" />
</resultMap>
<sql id="selectCountryVo">
select id, name, region_id from sys_country
</sql>
<select id="selectCountryList" parameterType="Country" resultMap="CountryResult">
<include refid="selectCountryVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="regionId != null and regionId != ''"> and region_id = #{regionId}</if>
</where>
</select>
<select id="selectCountryById" parameterType="Long" resultMap="CountryResult">
<include refid="selectCountryVo"/>
where id = #{id}
</select>
<insert id="insertCountry" parameterType="Country" useGeneratedKeys="true" keyProperty="id">
insert into sys_country
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if>
<if test="regionId != null and regionId != ''">region_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if>
<if test="regionId != null and regionId != ''">#{regionId},</if>
</trim>
</insert>
<update id="updateCountry" parameterType="Country">
update sys_country
<trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if>
<if test="regionId != null and regionId != ''">region_id = #{regionId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCountryById" parameterType="Long">
delete from sys_country where id = #{id}
</delete>
<delete id="deleteCountryByIds" parameterType="String">
delete from sys_country where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save