9 changed files with 290 additions and 9 deletions
@ -0,0 +1,59 @@ |
|||||
|
package org.nl.wms.basedata.master.interfaceback.controller; |
||||
|
|
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.common.TableDataInfo; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.modules.logging.annotation.Log; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.IInterfaceBackService; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.dao.InterfaceBack; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @Author: lyd |
||||
|
* @Date: 2024/10/15 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@RequestMapping("/api/interfaceback") |
||||
|
@Slf4j |
||||
|
public class InterfaceBackController { |
||||
|
@Autowired |
||||
|
private IInterfaceBackService interfaceBackService; |
||||
|
@GetMapping |
||||
|
@Log("查询接口回传设置") |
||||
|
//@SaCheckPermission("@el.check('interfaceback:list')")
|
||||
|
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) { |
||||
|
return new ResponseEntity<>(TableDataInfo.build(interfaceBackService.queryAll(whereJson, page)), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
@Log("新增接口回传设置") |
||||
|
//@SaCheckPermission("@el.check('interfaceback:add')")
|
||||
|
public ResponseEntity<Object> create(@Validated @RequestBody InterfaceBack dto) { |
||||
|
interfaceBackService.create(dto); |
||||
|
return new ResponseEntity<>(HttpStatus.CREATED); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
@Log("修改接口回传设置") |
||||
|
//@SaCheckPermission("@el.check('interfaceback:edit')")
|
||||
|
public ResponseEntity<Object> update(@Validated @RequestBody InterfaceBack dto) { |
||||
|
interfaceBackService.update(dto); |
||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
||||
|
} |
||||
|
|
||||
|
@Log("删除接口回传设置") |
||||
|
//@SaCheckPermission("@el.check('interfaceback:del')")
|
||||
|
@DeleteMapping |
||||
|
public ResponseEntity<Object> delete(@RequestBody String[] ids) { |
||||
|
interfaceBackService.deleteAll(ids); |
||||
|
return new ResponseEntity<>(HttpStatus.OK); |
||||
|
} |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
/** |
||||
|
* 接口回传 |
||||
|
*/ |
||||
|
package org.nl.wms.basedata.master.interfaceback; |
@ -0,0 +1,57 @@ |
|||||
|
package org.nl.wms.basedata.master.interfaceback.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.dao.InterfaceBack; |
||||
|
import org.nl.wms.basedata.master.service.dto.InterfacebackDto; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 接口回传 |
||||
|
* @Author: lyd |
||||
|
* @Date: 2024/10/15 |
||||
|
*/ |
||||
|
public interface IInterfaceBackService extends IService<InterfaceBack> { |
||||
|
/** |
||||
|
* 查询数据分页 |
||||
|
* |
||||
|
* @param whereJson 条件 |
||||
|
* @param page 分页参数 |
||||
|
* @return Map<String, Object> |
||||
|
*/ |
||||
|
IPage<InterfaceBack> queryAll(Map whereJson, PageQuery page); |
||||
|
|
||||
|
/** |
||||
|
* 根据编码查询 |
||||
|
* |
||||
|
* @param code code |
||||
|
* @return Interfaceback |
||||
|
*/ |
||||
|
InterfaceBack findByCode(String code); |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 创建 |
||||
|
* |
||||
|
* @param dto / |
||||
|
*/ |
||||
|
void create(InterfaceBack dto); |
||||
|
|
||||
|
/** |
||||
|
* 编辑 |
||||
|
* |
||||
|
* @param dto / |
||||
|
*/ |
||||
|
void update(InterfaceBack dto); |
||||
|
|
||||
|
/** |
||||
|
* 多选删除 |
||||
|
* |
||||
|
* @param ids / |
||||
|
*/ |
||||
|
void deleteAll(String[] ids); |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package org.nl.wms.basedata.master.interfaceback.service.dao; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableField; |
||||
|
import com.baomidou.mybatisplus.annotation.TableId; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author: lyd |
||||
|
* @Date: 2024/10/15 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = false) |
||||
|
@TableName("md_pb_interfaceback") |
||||
|
public class InterfaceBack { |
||||
|
/** 标识 */ |
||||
|
/** |
||||
|
* 防止精度丢失 |
||||
|
*/ |
||||
|
@TableId |
||||
|
private String interface_id; |
||||
|
|
||||
|
/** |
||||
|
* 类型 |
||||
|
*/ |
||||
|
private String interface_type; |
||||
|
|
||||
|
/** |
||||
|
* 接口名称 |
||||
|
*/ |
||||
|
private String interface_name; |
||||
|
|
||||
|
/** |
||||
|
* 接口描述 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 是否回传 |
||||
|
*/ |
||||
|
private String is_back; |
||||
|
|
||||
|
/** |
||||
|
* 业务说明 |
||||
|
*/ |
||||
|
private String business_comment; |
||||
|
|
||||
|
/** |
||||
|
* 业务说明 |
||||
|
*/ |
||||
|
private String product_area; |
||||
|
@TableField(exist = false) |
||||
|
private String[] product_areas; |
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package org.nl.wms.basedata.master.interfaceback.service.dao.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.dao.InterfaceBack; |
||||
|
|
||||
|
/** |
||||
|
* @Author: lyd |
||||
|
* @Date: 2024/10/15 |
||||
|
*/ |
||||
|
public interface InterfaceBackMapper extends BaseMapper<InterfaceBack> { |
||||
|
} |
@ -0,0 +1,5 @@ |
|||||
|
<?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="org.nl.wms.basedata.master.interfaceback.service.dao.mapper.InterfaceBackMapper"> |
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,87 @@ |
|||||
|
package org.nl.wms.basedata.master.interfaceback.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.map.MapUtil; |
||||
|
import cn.hutool.core.util.IdUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import org.nl.common.domain.query.PageQuery; |
||||
|
import org.nl.modules.common.exception.BadRequestException; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.IInterfaceBackService; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.dao.InterfaceBack; |
||||
|
import org.nl.wms.basedata.master.interfaceback.service.dao.mapper.InterfaceBackMapper; |
||||
|
import org.nl.wms.basedata.master.service.dto.InterfacebackDto; |
||||
|
import org.nl.wms.basedata.master.standard.service.dao.ClassStandard; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.data.domain.Pageable; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @Author: lyd |
||||
|
* @Date: 2024/10/15 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class InterfaceBackServiceImpl extends ServiceImpl<InterfaceBackMapper, InterfaceBack> implements IInterfaceBackService { |
||||
|
@Autowired |
||||
|
private InterfaceBackMapper interfaceBackMapper; |
||||
|
@Override |
||||
|
public IPage<InterfaceBack> queryAll(Map whereJson, PageQuery page) { |
||||
|
String interface_name = MapUtil.getStr(whereJson, "interface_name"); |
||||
|
LambdaQueryWrapper<InterfaceBack> lam = new QueryWrapper<InterfaceBack>().lambda(); |
||||
|
lam.like(ObjectUtil.isNotEmpty(interface_name), InterfaceBack::getInterface_name, interface_name); |
||||
|
IPage<InterfaceBack> pages = new Page<>(page.getPage() + 1, page.getSize()); |
||||
|
interfaceBackMapper.selectPage(pages, lam); |
||||
|
pages.getRecords().forEach(ib -> { |
||||
|
if (ObjectUtil.isEmpty(ib.getProduct_area())) { |
||||
|
return; |
||||
|
} |
||||
|
String product_area = (ib.getProduct_area().replace("[", "").replace("]", "")).replaceAll("\\\"", ""); |
||||
|
ib.setProduct_areas(product_area.split(",")); |
||||
|
}); |
||||
|
return pages; |
||||
|
} |
||||
|
@Override |
||||
|
public InterfaceBack findByCode(String code) { |
||||
|
LambdaQueryWrapper<InterfaceBack> lam = new LambdaQueryWrapper<>(); |
||||
|
lam.eq(InterfaceBack::getInterface_name, code); |
||||
|
InterfaceBack one = getOne(lam); |
||||
|
if (ObjectUtil.isNotEmpty(one.getProduct_area())) { |
||||
|
String product_area = (one.getProduct_area().replace("[", "").replace("]", "")).replaceAll("\\\"", ""); |
||||
|
one.setProduct_areas(product_area.split(",")); |
||||
|
} |
||||
|
return one; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void create(InterfaceBack dto) { |
||||
|
dto.setInterface_id(IdUtil.getSnowflake(1, 1).nextIdStr()); |
||||
|
String result = Arrays.toString(dto.getProduct_areas()); |
||||
|
result = result.replaceAll(" ", ""); |
||||
|
dto.setProduct_area(result); |
||||
|
interfaceBackMapper.insert(dto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void update(InterfaceBack dto) { |
||||
|
InterfaceBack entity = this.getById(dto.getInterface_id()); |
||||
|
if (entity == null) { |
||||
|
throw new BadRequestException("被删除或无权限,操作失败!"); |
||||
|
} |
||||
|
String result = Arrays.toString(dto.getProduct_areas()); |
||||
|
result = result.replaceAll(" ", ""); |
||||
|
dto.setProduct_area(result); |
||||
|
interfaceBackMapper.updateById(dto); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void deleteAll(String[] ids) { |
||||
|
removeByIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue