forked from rongchao/epmet-cloud-rizhao
9 changed files with 592 additions and 0 deletions
@ -0,0 +1,63 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
@Data |
|||
public class KeyEnterpriseDTO implements Serializable { |
|||
|
|||
|
|||
private static final long serialVersionUID = 5507035235435852045L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 单位名称 |
|||
*/ |
|||
private String unitName; |
|||
|
|||
/** |
|||
* 单位类型 |
|||
*/ |
|||
private String unitType; |
|||
|
|||
/** |
|||
* 主营业务 |
|||
*/ |
|||
private String business; |
|||
|
|||
/** |
|||
* 法人代表 |
|||
*/ |
|||
private String legalPerson; |
|||
|
|||
/** |
|||
* 电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
} |
@ -0,0 +1,65 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author yan Lu |
|||
* @description 描述 |
|||
* @create 2023/6/19 10:41 |
|||
*/ |
|||
@Data |
|||
public class KeyEnterpriseFormDTO extends PageFormDTO implements Serializable { |
|||
|
|||
|
|||
private static final long serialVersionUID = -6171428732538388855L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 单位名称 |
|||
*/ |
|||
private String unitName; |
|||
|
|||
/** |
|||
* 单位类型 |
|||
*/ |
|||
private String unitType; |
|||
|
|||
/** |
|||
* 主营业务 |
|||
*/ |
|||
private String business; |
|||
|
|||
/** |
|||
* 法人代表 |
|||
*/ |
|||
private String legalPerson; |
|||
|
|||
/** |
|||
* 电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
|
|||
} |
@ -0,0 +1,99 @@ |
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.aop.NoRepeatSubmit; |
|||
import com.epmet.commons.tools.enums.DictTypeEnum; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.AssertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.dto.KeyEnterpriseDTO; |
|||
import com.epmet.dto.form.KeyEnterpriseFormDTO; |
|||
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|||
import com.epmet.service.KeyEnterpriseService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("keyEnterprise") |
|||
public class KeyEnterpriseController { |
|||
|
|||
@Autowired |
|||
private KeyEnterpriseService keyEnterpriseService; |
|||
|
|||
@Autowired |
|||
private EpmetAdminOpenFeignClient adminOpenFeignClient; |
|||
|
|||
@RequestMapping("page") |
|||
public Result<PageData<KeyEnterpriseDTO>> page(@RequestParam Map<String, Object> params) { |
|||
PageData<KeyEnterpriseDTO> page = keyEnterpriseService.page(params); |
|||
if (null != page && page.getList().size() > 0) { |
|||
buildData(page.getList()); |
|||
} |
|||
return new Result<PageData<KeyEnterpriseDTO>>().ok(page); |
|||
} |
|||
|
|||
@RequestMapping(value = "{id}", method = {RequestMethod.POST, RequestMethod.GET}) |
|||
public Result<KeyEnterpriseDTO> get(@PathVariable("id") String id) { |
|||
KeyEnterpriseDTO data = keyEnterpriseService.get(id); |
|||
return new Result<KeyEnterpriseDTO>().ok(data); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("save") |
|||
public Result save(@RequestBody KeyEnterpriseFormDTO dto) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
keyEnterpriseService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@NoRepeatSubmit |
|||
@PostMapping("update") |
|||
public Result update(@RequestBody KeyEnterpriseFormDTO dto) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
keyEnterpriseService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("delete") |
|||
public Result delete(@RequestBody String[] ids) { |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
keyEnterpriseService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PostMapping("search") |
|||
public Result<PageData<KeyEnterpriseDTO>> search(@RequestBody KeyEnterpriseFormDTO formDto) { |
|||
PageData<KeyEnterpriseDTO> page = keyEnterpriseService.search(formDto); |
|||
if (null != page && page.getList().size() > 0) { |
|||
buildData(page.getList()); |
|||
} |
|||
return new Result().ok(page); |
|||
} |
|||
|
|||
private void buildData(List<KeyEnterpriseDTO> dtoList) { |
|||
Result<Map<String, String>> dictMapRes = adminOpenFeignClient.dictMap(DictTypeEnum.UNIT_TYPE.getCode()); |
|||
if (null != dictMapRes.getData() && dictMapRes.getData().size() > 0) { |
|||
Map<String, String> dictMap = dictMapRes.getData(); |
|||
for (KeyEnterpriseDTO dto : dtoList) { |
|||
if (null != dto.getUnitType()) { |
|||
dto.setUnitType(dictMap.get(dto.getUnitType())); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.KeyEnterpriseDTO; |
|||
import com.epmet.entity.KeyEnterpriseEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
@Mapper |
|||
public interface KeyEnterpriseDao extends BaseDao<KeyEnterpriseEntity> { |
|||
|
|||
List<KeyEnterpriseDTO> search(@Param("unitName") String unitName, @Param("unitType") String unitType); |
|||
|
|||
} |
@ -0,0 +1,61 @@ |
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("key_enterprise") |
|||
public class KeyEnterpriseEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 单位名称 |
|||
*/ |
|||
private String unitName; |
|||
|
|||
/** |
|||
* 单位类型 |
|||
*/ |
|||
private String unitType; |
|||
|
|||
/** |
|||
* 主营业务 |
|||
*/ |
|||
private String business; |
|||
|
|||
/** |
|||
* 法人代表 |
|||
*/ |
|||
private String legalPerson; |
|||
|
|||
/** |
|||
* 电话 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 经度 |
|||
*/ |
|||
private String longitude; |
|||
|
|||
/** |
|||
* 纬度 |
|||
*/ |
|||
private String latitude; |
|||
|
|||
} |
@ -0,0 +1,63 @@ |
|||
package com.epmet.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
@Data |
|||
public class KeyEnterpriseExcel { |
|||
|
|||
@Excel(name = "主键ID") |
|||
private String id; |
|||
|
|||
@Excel(name = "单位名称") |
|||
private String unitName; |
|||
|
|||
@Excel(name = "单位类型") |
|||
private Integer unitType; |
|||
|
|||
@Excel(name = "主营业务") |
|||
private String business; |
|||
|
|||
@Excel(name = "法人代表") |
|||
private String legalPerson; |
|||
|
|||
@Excel(name = "电话") |
|||
private String mobile; |
|||
|
|||
@Excel(name = "地址") |
|||
private String address; |
|||
|
|||
@Excel(name = "经度") |
|||
private String longitude; |
|||
|
|||
@Excel(name = "纬度") |
|||
private String latitude; |
|||
|
|||
@Excel(name = "删除标识:0.未删除 1.已删除") |
|||
private Integer delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
|
|||
} |
@ -0,0 +1,79 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.KeyEnterpriseDTO; |
|||
import com.epmet.dto.form.KeyEnterpriseFormDTO; |
|||
import com.epmet.entity.KeyEnterpriseEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
public interface KeyEnterpriseService extends BaseService<KeyEnterpriseEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<KeyEnterpriseDTO> |
|||
* @author generator |
|||
* @date 2023-06-19 |
|||
*/ |
|||
PageData<KeyEnterpriseDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<KeyEnterpriseDTO> |
|||
* @author generator |
|||
* @date 2023-06-19 |
|||
*/ |
|||
List<KeyEnterpriseDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return KeyEnterpriseDTO |
|||
* @author generator |
|||
* @date 2023-06-19 |
|||
*/ |
|||
KeyEnterpriseDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-06-19 |
|||
*/ |
|||
void save(KeyEnterpriseFormDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-06-19 |
|||
*/ |
|||
void update(KeyEnterpriseFormDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2023-06-19 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
PageData<KeyEnterpriseDTO> search(KeyEnterpriseFormDTO formDto); |
|||
} |
@ -0,0 +1,91 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.dao.KeyEnterpriseDao; |
|||
import com.epmet.dto.KeyEnterpriseDTO; |
|||
import com.epmet.dto.form.KeyEnterpriseFormDTO; |
|||
import com.epmet.entity.KeyEnterpriseEntity; |
|||
import com.epmet.service.KeyEnterpriseService; |
|||
import com.github.pagehelper.PageHelper; |
|||
import com.github.pagehelper.PageInfo; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2023-06-19 |
|||
*/ |
|||
@Service |
|||
public class KeyEnterpriseServiceImpl extends BaseServiceImpl<KeyEnterpriseDao, KeyEnterpriseEntity> implements KeyEnterpriseService { |
|||
|
|||
@Override |
|||
public PageData<KeyEnterpriseDTO> page(Map<String, Object> params) { |
|||
IPage<KeyEnterpriseEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, KeyEnterpriseDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<KeyEnterpriseDTO> list(Map<String, Object> params) { |
|||
List<KeyEnterpriseEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, KeyEnterpriseDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<KeyEnterpriseEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<KeyEnterpriseEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public KeyEnterpriseDTO get(String id) { |
|||
KeyEnterpriseEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, KeyEnterpriseDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(KeyEnterpriseFormDTO dto) { |
|||
KeyEnterpriseEntity entity = ConvertUtils.sourceToTarget(dto, KeyEnterpriseEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(KeyEnterpriseFormDTO dto) { |
|||
KeyEnterpriseEntity entity = ConvertUtils.sourceToTarget(dto, KeyEnterpriseEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
@Override |
|||
public PageData<KeyEnterpriseDTO> search(KeyEnterpriseFormDTO formDto) { |
|||
PageInfo<KeyEnterpriseDTO> pageInfo = PageHelper.startPage(formDto.getPageNo(), formDto.getPageSize(), formDto.getIsPage()) |
|||
.doSelectPageInfo(() -> baseDao.search(formDto.getUnitName(), formDto.getUnitType())); |
|||
return new PageData<>(pageInfo.getList() == null ? new ArrayList<>() : pageInfo.getList(), pageInfo.getTotal()); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
<?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.epmet.dao.KeyEnterpriseDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.KeyEnterpriseEntity" id="keyEnterpriseMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="unitName" column="UNIT_NAME"/> |
|||
<result property="unitType" column="UNIT_TYPE"/> |
|||
<result property="business" column="BUSINESS"/> |
|||
<result property="legalPerson" column="LEGAL_PERSON"/> |
|||
<result property="mobile" column="MOBILE"/> |
|||
<result property="address" column="ADDRESS"/> |
|||
<result property="longitude" column="LONGITUDE"/> |
|||
<result property="latitude" column="LATITUDE"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
<sql id="returnMap"> |
|||
ke.ID, |
|||
ke.UNIT_NAME, |
|||
ke.UNIT_TYPE, |
|||
ke.BUSINESS, |
|||
ke.LEGAL_PERSON, |
|||
ke.MOBILE, |
|||
ke.ADDRESS, |
|||
ke.LONGITUDE, |
|||
ke.LATITUDE |
|||
</sql> |
|||
<select id="search" resultType="com.epmet.dto.KeyEnterpriseDTO"> |
|||
SELECT |
|||
<include refid="returnMap"/> |
|||
FROM key_enterprise ke |
|||
<where> |
|||
ke.DEL_FLAG = 0 |
|||
<if test="null != unitName and unitName !=''"> |
|||
AND ke.UNIT_NAME LIKE concat( '%', #{unitName}, '%') |
|||
</if> |
|||
<if test="null != unitType and unitType !=''"> |
|||
AND ke.UNIT_TYPE = #{unitType} |
|||
</if> |
|||
</where> |
|||
|
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue