fix: Address
This commit is contained in:
@@ -31,7 +31,6 @@ public class AddressController {
|
||||
@GetMapping
|
||||
@Log("查询接口方法地址")
|
||||
@ApiOperation("查询接口方法地址")
|
||||
//@PreAuthorize("@el.check('Address:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(addressService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
@@ -39,7 +38,6 @@ public class AddressController {
|
||||
@PostMapping
|
||||
@Log("新增接口方法地址")
|
||||
@ApiOperation("新增接口方法地址")
|
||||
//@PreAuthorize("@el.check('Address:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody AddressDto dto) {
|
||||
addressService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
@@ -48,7 +46,6 @@ public class AddressController {
|
||||
@PutMapping
|
||||
@Log("修改接口方法地址")
|
||||
@ApiOperation("修改接口方法地址")
|
||||
//@PreAuthorize("@el.check('Address:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody AddressDto dto) {
|
||||
addressService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
@@ -56,7 +53,6 @@ public class AddressController {
|
||||
|
||||
@Log("删除接口方法地址")
|
||||
@ApiOperation("删除接口方法地址")
|
||||
//@PreAuthorize("@el.check('Address:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
addressService.deleteAll(ids);
|
||||
@@ -66,7 +62,6 @@ public class AddressController {
|
||||
@Log("导出接口方法地址")
|
||||
@ApiOperation("导出接口方法地址")
|
||||
@GetMapping(value = "/download")
|
||||
//@PreAuthorize("@el.check('Address:list')")
|
||||
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
|
||||
addressService.download(addressService.queryAll(whereJson), response);
|
||||
}
|
||||
|
||||
@@ -38,19 +38,40 @@ public interface AddressService extends CommonService<Address> {
|
||||
*/
|
||||
List<AddressDto> queryAll(AddressQueryParam query);
|
||||
|
||||
/**
|
||||
* 根据id查地址
|
||||
* @param id
|
||||
* @return Address
|
||||
*/
|
||||
Address getById(String id);
|
||||
|
||||
AddressDto findById(String id);
|
||||
|
||||
/**
|
||||
* 插入一条新数据。
|
||||
* 新增
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
int insert(AddressDto resources);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
int updateById(AddressDto resources);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int removeById(String id);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int removeByIds(Set<String> ids);
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -28,10 +29,6 @@ import org.nl.config.language.LangProcess;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
// 默认不使用缓存
|
||||
//import org.springframework.cache.annotation.CacheConfig;
|
||||
//import org.springframework.cache.annotation.CacheEvict;
|
||||
//import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -44,14 +41,11 @@ import java.util.*;
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
// @CacheConfig(cacheNames = SysInterfaceMethodsAddressService.CACHE_KEY)
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address> implements AddressService {
|
||||
|
||||
// private final RedisUtils redisUtils;
|
||||
private final AddressMapper sysInterfaceMethodsAddressMapper;
|
||||
|
||||
private final String delete = "";
|
||||
|
||||
@Override
|
||||
public PageInfo<AddressDto> queryAll(AddressQueryParam query, Pageable pageable) {
|
||||
@@ -67,88 +61,43 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
|
||||
|
||||
@Override
|
||||
public Address getById(String id) {
|
||||
Assert.notEmpty(id,LangProcess.msg("error_checkNumber","id"));
|
||||
return sysInterfaceMethodsAddressMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Cacheable(key = "'id:' + #p0")
|
||||
public AddressDto findById(String id) {
|
||||
return ConvertUtil.convert(getById(id), AddressDto.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insert(AddressDto resources) {
|
||||
Address entity = ConvertUtil.convert(resources, Address.class);
|
||||
return sysInterfaceMethodsAddressMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateById(AddressDto resources) {
|
||||
Address entity = ConvertUtil.convert(resources, Address.class);
|
||||
int ret = sysInterfaceMethodsAddressMapper.updateById(entity);
|
||||
// delCaches(resources.id);
|
||||
return ret;
|
||||
return sysInterfaceMethodsAddressMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int removeByIds(Set<String> ids) {
|
||||
// delCaches(ids);
|
||||
return sysInterfaceMethodsAddressMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int removeById(String id) {
|
||||
Set<String> set = new HashSet<>(1);
|
||||
set.add(id);
|
||||
return this.removeByIds(set);
|
||||
}
|
||||
|
||||
/*
|
||||
private void delCaches(String id) {
|
||||
redisUtils.delByKey(CACHE_KEY + "::id:", id);
|
||||
}
|
||||
|
||||
private void delCaches(Set<String> ids) {
|
||||
for (String id: ids) {
|
||||
delCaches(id);
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void download(List<SysInterfaceMethodsAddressDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SysInterfaceMethodsAddressDto sysInterfaceMethodsAddress : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("方法编码", sysInterfaceMethodsAddress.getMethodsCode());
|
||||
map.put("方法名称", sysInterfaceMethodsAddress.getMethodsName());
|
||||
map.put("请求地址", sysInterfaceMethodsAddress.getMethodsUrl());
|
||||
map.put("备注", sysInterfaceMethodsAddress.getRemark());
|
||||
map.put("创建人", sysInterfaceMethodsAddress.getCreateId());
|
||||
map.put("创建人姓名", sysInterfaceMethodsAddress.getCreateName());
|
||||
map.put("创建时间", sysInterfaceMethodsAddress.getCreateTime());
|
||||
map.put("修改人", sysInterfaceMethodsAddress.getUpdateOptid());
|
||||
map.put("修改人姓名", sysInterfaceMethodsAddress.getUpdateOptname());
|
||||
map.put("修改时间", sysInterfaceMethodsAddress.getUpdateTime());
|
||||
map.put("是否删除", sysInterfaceMethodsAddress.getIsDelete());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}*/
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
// String blurry = "";
|
||||
// if (whereJson.get("blurry") != null) {
|
||||
// blurry = (String) whereJson.get("blurry");
|
||||
// }
|
||||
// JSONObject jo = WQL.getWO("Qdevice_query_002").addParam("flag", "3").addParam("blurry", blurry).pageQuery(WqlUtil.getHttpContext(page), "update_time desc");
|
||||
// return jo;
|
||||
|
||||
IPage<Address> queryPage = PageUtil.toMybatisPage(page);
|
||||
LambdaQueryWrapper<Address> wrapper = new LambdaQueryWrapper<>();
|
||||
@@ -161,32 +110,16 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
|
||||
|
||||
@Override
|
||||
public List<AddressDto> queryAll(Map whereJson) {
|
||||
// WQLObject wo = WQLObject.getWQLObject("sys_interface_methods_address");
|
||||
// JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
// List<AddressDto> list = arr.toJavaList(AddressDto.class);
|
||||
// return list;
|
||||
|
||||
List<Address> addressList = new LambdaQueryChainWrapper<>(sysInterfaceMethodsAddressMapper)
|
||||
.list();
|
||||
return ConvertUtil.convertList(addressList, AddressDto.class);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public AddressDto findById(String methods_id) {
|
||||
// WQLObject wo = WQLObject.getWQLObject("sys_interface_methods_address");
|
||||
// JSONObject json = wo.query("methods_id ='" + methods_id + "'").uniqueResult(0);
|
||||
// final AddressDto obj = json.toJavaObject(AddressDto.class);
|
||||
// return obj;
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public AddressDto findByCode(String code) {
|
||||
// WQLObject wo = WQLObject.getWQLObject("sys_interface_methods_address");
|
||||
// JSONObject json = wo.query("methods_code ='" + code + "'").uniqueResult(0);
|
||||
// if (ObjectUtil.isNotEmpty(json)){
|
||||
// final AddressDto obj = json.toJavaObject(AddressDto.class);
|
||||
// return obj;
|
||||
// }
|
||||
// return null;
|
||||
|
||||
Address address = new LambdaQueryChainWrapper<>(sysInterfaceMethodsAddressMapper)
|
||||
.eq(Address::getMethods_code, code)
|
||||
@@ -199,7 +132,6 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(AddressDto dto) {
|
||||
CommonFinalParam commonFinalParam = new CommonFinalParam();
|
||||
String Methods_code = dto.getMethods_code();
|
||||
@@ -214,25 +146,19 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
|
||||
dto.setMethods_id(IdUtil.simpleUUID());
|
||||
dto.setCreate_id(userId);
|
||||
dto.setCreate_name(currentUsername);
|
||||
// dto.setCreate_by(userId);
|
||||
// dto.setUpdate_by(userId);
|
||||
dto.setUpdate_optid(userId);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
// WQLObject wo = WQLObject.getWQLObject("sys_interface_methods_address");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
//
|
||||
// wo.insert(json);
|
||||
|
||||
Address entity = ConvertUtil.convert(dto, Address.class);
|
||||
sysInterfaceMethodsAddressMapper.insert(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(AddressDto dto) {
|
||||
AddressDto entity = this.findById(dto.getMethods_id());
|
||||
Address addressSelect = this.getById(dto.getMethods_id());
|
||||
AddressDto entity = ConvertUtil.convert(addressSelect, AddressDto.class);
|
||||
if (entity == null) {
|
||||
throw new BadRequestException(LangProcess.msg("error_sysAuth"));
|
||||
}
|
||||
@@ -243,7 +169,6 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
|
||||
dto.setUpdate_optid(userId);
|
||||
dto.setUpdate_optname(currentUsername);
|
||||
dto.setUpdate_time(now);
|
||||
// dto.setUpdate_by(userId);
|
||||
dto.setUpdate_optid(userId);
|
||||
|
||||
Address address = ConvertUtil.convert(dto, Address.class);
|
||||
@@ -251,7 +176,6 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(String[] ids) {
|
||||
for (String methods_id : ids) {
|
||||
this.removeById(methods_id);
|
||||
|
||||
Reference in New Issue
Block a user