- 1、不同服务之间通过feign调用
1.1 所有前端访问web服务、web 根据不同业务通过feign 调用其他服务。比如admin服务. 下面是web服务的代码
@RestController
@RequestMapping("/config/test")
public class TestConfigController {
@Autowired
private TestConfigRemote TestConfigRemote;
@RequestMapping("/list")
public R list(@RequestParam Map params) {
return TestConfigRemote.list(params);
}
@FeignClient(name = "admin-service")
public interface TestConfigRemote {
@RequestMapping(value = "/wms-service/config/test/list", method = RequestMethod.POST, produces =MediaType.APPLICATION_JSON_VALUE)
R list(@RequestParam Map params);
1.2 下面是admin服务的代码
entity--pgsql--oracle
@TableName("WMS_TEST")
@KeySequence("SEQ_WMS_TEST")
@Data
public class TestEntity implements Serializable {
//这里type用INPUT.是为了个oracle兼容。因为是从oracle切换到pgsql。所以做兼容
//实际pgsql可以用AUTO,自增。也不需要@KeySequence("SEQ_WMS_TEST")这个序列
// 此处疑惑id为啥用long类型?我用了Integer.会出现类型转换异常
@TableId(value = "id", type = IdType.INPUT)
private Long id;
private String name;
private String staffNo;
private String editor;
// 是否删除标志。数据库默认查询='0' 的数据
@TableField(value = "rfid_flag")
@TableLogic
private String del;
controller
@RestController
@RequestMapping("/config/testConfig")
public class TestConfigController {
@Autowired
private TestConfigService testConfigService;
@RequestMapping("/list")
public R list(@RequestParam Map params) {
PageUtils page = testConfigService.list(params);
return R.ok().put("page", page);
}
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids) {
testConfigService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
service public interface TestConfigService extends IService{ PageUtils list(Map params);
serviceImpl @Service public class TestConfigServiceImpl extends ServiceImplimplements TestConfigService { @Override public PageUtils list(Map params) { Page page = new Query (params).getPage(); String name = (String) params.get("name"); String staffNo = (String) params.get("staffNo"); page = this.selectPage(page, new EntityWrapper () .eq(StringUtils.isNotBlank(name ), "name", name) .eq(StringUtils.isNotBlank(staffNo), "staff_no", staffNo) ); return new PageUtils(page); }
Dao @Repository public interface TestConfigDao extends baseMapper{ }



